Compare commits
671
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a954e2b48 | ||
|
|
867c0a0e7e | ||
|
|
270c4d5175 | ||
|
|
0779fbbc72 | ||
|
|
7d80dfd93d | ||
|
|
a4638d6d61 | ||
|
|
5cd7f88da0 | ||
|
|
cc6a34b575 | ||
|
|
40ae2ffb7b | ||
|
|
b500757b68 | ||
|
|
445a8ba801 | ||
|
|
519e9185df | ||
|
|
2d98f8c8ae | ||
|
|
fa9fdc6576 | ||
|
|
e25f778f7b | ||
|
|
b5baebd0b3 | ||
|
|
c9ecc5b466 | ||
|
|
f38de5059e | ||
|
|
0ff0e1c76b | ||
|
|
983096e0a4 | ||
|
|
d4bd939578 | ||
|
|
91aa10b7eb | ||
|
|
b527d78a2c | ||
|
|
fcca0eaa71 | ||
|
|
0bfa06f87d | ||
|
|
3aed584bf7 | ||
|
|
c4d944cfad | ||
|
|
c05114555f | ||
|
|
dfc15d77e5 | ||
|
|
25e5ac7db0 | ||
|
|
d0533903f3 | ||
|
|
48e258a60c | ||
|
|
e1b9c355e6 | ||
|
|
c3db6ed873 | ||
|
|
56b3e1ecc6 | ||
|
|
5385e090f7 | ||
|
|
ecb7767b70 | ||
|
|
42bf39cd8c | ||
|
|
716f92d636 | ||
|
|
efdc17ce07 | ||
|
|
ffab9d82fa | ||
|
|
891eaf2829 | ||
|
|
053804f759 | ||
|
|
a8af93c4ec | ||
|
|
00a1f5ed64 | ||
|
|
a76b0dbc0e | ||
|
|
59ce107b33 | ||
|
|
ce1036ccc8 | ||
|
|
b6861ed26f | ||
|
|
8522cceb89 | ||
|
|
dec9509a5d | ||
|
|
5f02c6f64b | ||
|
|
8271da1517 | ||
|
|
05c0941cbb | ||
|
|
8e565163ec | ||
|
|
8a69b52f48 | ||
|
|
51a0f8accb | ||
|
|
8777bc0810 | ||
|
|
596b75282d | ||
|
|
de97775bd0 | ||
|
|
2ed23cec01 | ||
|
|
11fbd1f65c | ||
|
|
d3556dc2ac | ||
|
|
ad453255a5 | ||
|
|
2143ed5ca8 | ||
|
|
2aa8372cdc | ||
|
|
80c7331a29 | ||
|
|
9e31083745 | ||
|
|
fc8272216b | ||
|
|
0176c7664c | ||
|
|
e1c0705785 | ||
|
|
8efa320470 | ||
|
|
a4d114ad6e | ||
|
|
1e5609f6c9 | ||
|
|
c21d90589b | ||
|
|
bef7183ce7 | ||
|
|
c6ea42a681 | ||
|
|
f6eda1fce6 | ||
|
|
a1bcd7443d | ||
|
|
51955e88ce | ||
|
|
61bb7755a3 | ||
|
|
a7fa61464c | ||
|
|
93329a7ba0 | ||
|
|
9c4d742db8 | ||
|
|
16ac6c40a3 | ||
|
|
9a69d92756 | ||
|
|
fb93e21a0c | ||
|
|
ee2484383c | ||
|
|
1863dafeca | ||
|
|
a4c7828ac2 | ||
|
|
0a02f5737a | ||
|
|
154a1840d0 | ||
|
|
13e83cbd14 | ||
|
|
19d60f95ec | ||
|
|
f64405ebb6 | ||
|
|
92f2057650 | ||
|
|
861d318162 | ||
|
|
f3558cb78c | ||
|
|
3c5acae825 | ||
|
|
9a749f8936 | ||
|
|
c095d055a1 | ||
|
|
d29e914146 | ||
|
|
a2491a0e43 | ||
|
|
4475a8c6d4 | ||
|
|
d5ddb83c9d | ||
|
|
b5e99d8d83 | ||
|
|
91f58c293d | ||
|
|
4836e7cb53 | ||
|
|
6451e64637 | ||
|
|
b7ac1963bb | ||
|
|
869b0e48a6 | ||
|
|
baefb786fb | ||
|
|
99523b3a97 | ||
|
|
f67c1e5beb | ||
|
|
50af02454c | ||
|
|
aa94eb11b7 | ||
|
|
b73cc75635 | ||
|
|
75180606f8 | ||
|
|
3cac4326e4 | ||
|
|
da5e8b5844 | ||
|
|
081a90d1fa | ||
|
|
7b5f050bdc | ||
|
|
d06a3eec7f | ||
|
|
637fa7cc35 | ||
|
|
3f332d50b5 | ||
|
|
782e468325 | ||
|
|
0c59b93ecf | ||
|
|
5a0e89cf31 | ||
|
|
4c3bfce583 | ||
|
|
59d6820ff3 | ||
|
|
9ec379f176 | ||
|
|
2766e56f2d | ||
|
|
72cc503eb9 | ||
|
|
0c781120a2 | ||
|
|
449c9f5903 | ||
|
|
5aff935c98 | ||
|
|
6f793edfb7 | ||
|
|
6455a0c1fc | ||
|
|
b19c3c7e01 | ||
|
|
fb7c8af59e | ||
|
|
d56298ba17 | ||
|
|
b9d67dec34 | ||
|
|
5b664e393d | ||
|
|
c582282084 | ||
|
|
944ece4090 | ||
|
|
f225d0c3ef | ||
|
|
a9c98c2e3a | ||
|
|
ac8c2948e7 | ||
|
|
f75b4c10d2 | ||
|
|
f6ea1ea0da | ||
|
|
ecf6b0b44f | ||
|
|
ef6510b42e | ||
|
|
27ce32de07 | ||
|
|
341f6ec683 | ||
|
|
8c88e1e26a | ||
|
|
cabdb42bb4 | ||
|
|
e4a69c6245 | ||
|
|
5a52c676e1 | ||
|
|
5be9693235 | ||
|
|
5421abc4c4 | ||
|
|
f2d3fb45dc | ||
|
|
e447f090cc | ||
|
|
239c83a742 | ||
|
|
c315028a09 | ||
|
|
99b66f4f45 | ||
|
|
c3096d08bf | ||
|
|
67b906ea3b | ||
|
|
e7be50eb91 | ||
|
|
2dd3915ad5 | ||
|
|
29b572819a | ||
|
|
0a0acfda66 | ||
|
|
9167fc0c58 | ||
|
|
e48ffe3579 | ||
|
|
a7697c1db1 | ||
|
|
36c1cce132 | ||
|
|
7dbce44472 | ||
|
|
c67bd21219 | ||
|
|
38f257cf87 | ||
|
|
a0022e0330 | ||
|
|
38f5b93520 | ||
|
|
a078dfd59e | ||
|
|
3a2f286e2d | ||
|
|
66818f5525 | ||
|
|
b810a5e540 | ||
|
|
e63e421343 | ||
|
|
7031f7cb80 | ||
|
|
afaced7cd6 | ||
|
|
d671ca4712 | ||
|
|
1095aee346 | ||
|
|
176958144b | ||
|
|
9d191edf06 | ||
|
|
86609f139b | ||
|
|
420fcba457 | ||
|
|
ba8764300c | ||
|
|
510477a204 | ||
|
|
95acb1f85f | ||
|
|
0b9ae2202c | ||
|
|
60641259b2 | ||
|
|
99e2b5023d | ||
|
|
1c7261db07 | ||
|
|
e1b678664a | ||
|
|
4c59f6cfe6 | ||
|
|
d3e43a6423 | ||
|
|
8f06539b6e | ||
|
|
1f6d115d78 | ||
|
|
cee913cc04 | ||
|
|
686c8416c2 | ||
|
|
30a8eb5ccf | ||
|
|
bd5d928084 | ||
|
|
5e62d62c3d | ||
|
|
078e59a33b | ||
|
|
5faba43544 | ||
|
|
4b61294dc2 | ||
|
|
fced53cd29 | ||
|
|
f47447d92d | ||
|
|
a523710117 | ||
|
|
20805d87b4 | ||
|
|
0119d25dfc | ||
|
|
da4e1b5137 | ||
|
|
22c15267f9 | ||
|
|
6c83fec2da | ||
|
|
54b0a83ffd | ||
|
|
bc845844ea | ||
|
|
b5a1660c2d | ||
|
|
20ba3f3d0c | ||
|
|
07cd99fc3d | ||
|
|
f6eb88574f | ||
|
|
2631ba93ca | ||
|
|
5ea36c8fd6 | ||
|
|
b07fc2bb8e | ||
|
|
53b1b8f9a9 | ||
|
|
5ffc2ef502 | ||
|
|
35ceed5193 | ||
|
|
ce52e1f51f | ||
|
|
16a21b366e | ||
|
|
d540fa5a12 | ||
|
|
1221dea58e | ||
|
|
a5b9a7948f | ||
|
|
386e7e8c6a | ||
|
|
a709bdb9ee | ||
|
|
46c01f196a | ||
|
|
26077ab9aa | ||
|
|
240955c2cb | ||
|
|
da4a8e3412 | ||
|
|
59cef5f9e3 | ||
|
|
05be944a86 | ||
|
|
258bd917ad | ||
|
|
b9cf853dd3 | ||
|
|
915967925c | ||
|
|
87bdb90bcc | ||
|
|
848b54d13a | ||
|
|
88bc3b5833 | ||
|
|
bdd36c8982 | ||
|
|
c103cfa84a | ||
|
|
62214f61ae | ||
|
|
40bcad05c4 | ||
|
|
6c1c98e4fb | ||
|
|
9b93f1c1e1 | ||
|
|
be03c9703f | ||
|
|
b885fdc50f | ||
|
|
3888cba7c4 | ||
|
|
932b30e163 | ||
|
|
e4c0069ad9 | ||
|
|
395e4b0d0e | ||
|
|
a7988aa845 | ||
|
|
4ec768c82b | ||
|
|
9fe53c2403 | ||
|
|
e32ea54e00 | ||
|
|
630a75440f | ||
|
|
3ef3c8e6b4 | ||
|
|
00b9678b1d | ||
|
|
fe01ebf36c | ||
|
|
905de04020 | ||
|
|
145efc313d | ||
|
|
26b2aa5cea | ||
|
|
476c148949 | ||
|
|
faa3e22816 | ||
|
|
5e15a2e29b | ||
|
|
d168f5b489 | ||
|
|
7a5d13e86a | ||
|
|
2e0d1697b9 | ||
|
|
87168f51ab | ||
|
|
2558e32ee0 | ||
|
|
7521efeff9 | ||
|
|
8ed259be31 | ||
|
|
67025d49ff | ||
|
|
de1dea610e | ||
|
|
9f3f5c0372 | ||
|
|
3b23fd4941 | ||
|
|
d6a084322b | ||
|
|
d2a38dd3d4 | ||
|
|
17aab43082 | ||
|
|
e5c3cf4ee3 | ||
|
|
b09cc88bab | ||
|
|
620904124e | ||
|
|
6e55cfdc39 | ||
|
|
bef23c5770 | ||
|
|
a6fcf162a6 | ||
|
|
29caf08098 | ||
|
|
ba9af41877 | ||
|
|
2762b9dbfc | ||
|
|
d75a153df8 | ||
|
|
76d225439a | ||
|
|
5ee3f03902 | ||
|
|
d3a1144d10 | ||
|
|
20e38f3b10 | ||
|
|
9205efab48 | ||
|
|
1ccc27226a | ||
|
|
b20f61b3b8 | ||
|
|
1d0b49e5dd | ||
|
|
a9dcb20e84 | ||
|
|
68f6ce14a6 | ||
|
|
78905d471c | ||
|
|
61806ff1f7 | ||
|
|
0d3195e69b | ||
|
|
e217864f16 | ||
|
|
de8aacddce | ||
|
|
7b1656e19f | ||
|
|
c228538c17 | ||
|
|
a8f5fac0bb | ||
|
|
206eb51618 | ||
|
|
02226f934b | ||
|
|
3d0ba2251a | ||
|
|
b400ee6741 | ||
|
|
f40335f9e7 | ||
|
|
f0de33e33b | ||
|
|
b170c6ae54 | ||
|
|
c4b4ad3224 | ||
|
|
cecd75aff6 | ||
|
|
f37a596173 | ||
|
|
c982aa2448 | ||
|
|
94d1238637 | ||
|
|
d218d38af3 | ||
|
|
04dd962b6d | ||
|
|
383914db9a | ||
|
|
f77d238a5d | ||
|
|
84996ce32f | ||
|
|
5fa7ab3602 | ||
|
|
48cb5996b7 | ||
|
|
8e36285a98 | ||
|
|
27db27b088 | ||
|
|
8339ee0fe9 | ||
|
|
f2b64de28f | ||
|
|
3415b0f3d4 | ||
|
|
9f18d7e044 | ||
|
|
90820b76cf | ||
|
|
3adb2add4c | ||
|
|
5979dd1cce | ||
|
|
be999694b0 | ||
|
|
5d3b9ea727 | ||
|
|
a4d01470d8 | ||
|
|
a055c7ec63 | ||
|
|
50b197e754 | ||
|
|
69dc2b5142 | ||
|
|
fc26f0a773 | ||
|
|
6ea799e385 | ||
|
|
4e83a1604c | ||
|
|
dd0d879e7b | ||
|
|
d160b88706 | ||
|
|
007d5e3e43 | ||
|
|
fd78d48dfb | ||
|
|
f1561e47d1 | ||
|
|
f1174bfbf5 | ||
|
|
c1d1df3d80 | ||
|
|
abf5fedc5b | ||
|
|
4195e4ea2f | ||
|
|
d183f43c96 | ||
|
|
a545b94ad7 | ||
|
|
c0d32918b0 | ||
|
|
03937d0dc2 | ||
|
|
94828dbdd0 | ||
|
|
63e24c2a25 | ||
|
|
c202f9244a | ||
|
|
76cf9a2d00 | ||
|
|
4f796b3708 | ||
|
|
12eefe3c41 | ||
|
|
8e33891c07 | ||
|
|
62fbabe3a5 | ||
|
|
7b4df2d374 | ||
|
|
2d7460bde1 | ||
|
|
65acd08d38 | ||
|
|
0acc85d962 | ||
|
|
3c45d59813 | ||
|
|
63acbeb8c0 | ||
|
|
9bf6819f7a | ||
|
|
bed2cc5735 | ||
|
|
4e35641c28 | ||
|
|
8594867ab6 | ||
|
|
6e0fbbd3bf | ||
|
|
d8fd6d95c0 | ||
|
|
a2b34ab650 | ||
|
|
f478f687ff | ||
|
|
0bf998510f | ||
|
|
2399e5e294 | ||
|
|
205b694162 | ||
|
|
f2b661ca05 | ||
|
|
c8ef971f03 | ||
|
|
10aa1133b2 | ||
|
|
05c3a2c83f | ||
|
|
dbaff07ae9 | ||
|
|
d916299a49 | ||
|
|
10840ac6b4 | ||
|
|
d194a26542 | ||
|
|
a3a368dfd9 | ||
|
|
e8f39487b9 | ||
|
|
ec6e2a7c74 | ||
|
|
b437016f6e | ||
|
|
5170bbe010 | ||
|
|
f8fcdf6a97 | ||
|
|
fdfc019cc1 | ||
|
|
d10c908b38 | ||
|
|
cb1f54ed2b | ||
|
|
73aceea741 | ||
|
|
89f85cee21 | ||
|
|
0e9a9d9f7c | ||
|
|
c25be44dd6 | ||
|
|
00da00b93a | ||
|
|
4eca673111 | ||
|
|
4507a02249 | ||
|
|
9a18da5aaa | ||
|
|
4e31111827 | ||
|
|
0cbf5b5562 | ||
|
|
d81bbc1214 | ||
|
|
41255f308e | ||
|
|
96be0cafdf | ||
|
|
55fc2f806c | ||
|
|
3eac6fe764 | ||
|
|
f1ed582828 | ||
|
|
07e0d7cd4f | ||
|
|
c68cc62143 | ||
|
|
2c02b41d71 | ||
|
|
d71d1005f9 | ||
|
|
b8f1071168 | ||
|
|
d88529d632 | ||
|
|
7bd028b7fe | ||
|
|
339f20ea7f | ||
|
|
336d80e93a | ||
|
|
b64a189215 | ||
|
|
fc76ff8b2f | ||
|
|
e0a65ffaaf | ||
|
|
61c7187a86 | ||
|
|
a6bad19b8f | ||
|
|
174d991451 | ||
|
|
4fbefc6987 | ||
|
|
8dd75d2548 | ||
|
|
b0c2ec505f | ||
|
|
a03095d84d | ||
|
|
9ee63d6521 | ||
|
|
9917fa8306 | ||
|
|
d0324074c1 | ||
|
|
983d0f4361 | ||
|
|
eb95b46fad | ||
|
|
30016c83b8 | ||
|
|
cf5d93604e | ||
|
|
a0778c759e | ||
|
|
a922c1f2c3 | ||
|
|
17600f59f2 | ||
|
|
6cfec88f47 | ||
|
|
f11009d674 | ||
|
|
5df384f6ef | ||
|
|
daa555b68d | ||
|
|
76cfafe700 | ||
|
|
ada42c9fd8 | ||
|
|
0b802d8fce | ||
|
|
58976c6f41 | ||
|
|
9cdb604796 | ||
|
|
c55e3fa7d2 | ||
|
|
7b47ee4cf5 | ||
|
|
0114739e5e | ||
|
|
708b642be2 | ||
|
|
d78357494d | ||
|
|
9398b1a6e0 | ||
|
|
b23a087f42 | ||
|
|
72203ebb5c | ||
|
|
86b2ad3a61 | ||
|
|
75be9250a9 | ||
|
|
35ba876ecf | ||
|
|
2886c4b211 | ||
|
|
9455ed83b2 | ||
|
|
cc46bfdfcc | ||
|
|
010e96b6f0 | ||
|
|
211470966c | ||
|
|
be887d05a4 | ||
|
|
edf551c40a | ||
|
|
df386413a9 | ||
|
|
fa7fbdf36b | ||
|
|
30f1ad7c2c | ||
|
|
11debd6bf8 | ||
|
|
44a783993e | ||
|
|
2bbb317831 | ||
|
|
36835e62e0 | ||
|
|
70867ab87b | ||
|
|
4b59c90b08 | ||
|
|
b538e9d34c | ||
|
|
505661eb5f | ||
|
|
a3e229ef82 | ||
|
|
5e9d32a0f7 | ||
|
|
724866141a | ||
|
|
f17c9eef12 | ||
|
|
00b6dcdd37 | ||
|
|
d9913262df | ||
|
|
69c1d0d15b | ||
|
|
5f7d138aef | ||
|
|
4659602e63 | ||
|
|
1771a26426 | ||
|
|
b42a383201 | ||
|
|
19f444489f | ||
|
|
deae7e4997 | ||
|
|
6142015168 | ||
|
|
305a7f1e02 | ||
|
|
0bff07026c | ||
|
|
32c3e5dfd8 | ||
|
|
ee78679277 | ||
|
|
185f8b099d | ||
|
|
89a0f18b30 | ||
|
|
4cbc345ba6 | ||
|
|
abe3843712 | ||
|
|
3c2d1e4814 | ||
|
|
a8c4ed3c79 | ||
|
|
0aa73fa285 | ||
|
|
f1652b5ba0 | ||
|
|
fed0baf6b6 | ||
|
|
49a8ee5b54 | ||
|
|
c9569a0629 | ||
|
|
a4e83b5836 | ||
|
|
8b285047bd | ||
|
|
f999be0372 | ||
|
|
e639cfd75b | ||
|
|
2753692303 | ||
|
|
2722e979fc | ||
|
|
144c0ce106 | ||
|
|
b64172e12e | ||
|
|
c0072fcb84 | ||
|
|
37cd34a0e1 | ||
|
|
005be84af4 | ||
|
|
0ef682c156 | ||
|
|
3faa838774 | ||
|
|
f10c2793c9 | ||
|
|
9f4b83362a | ||
|
|
8ef423ca65 | ||
|
|
aff5173656 | ||
|
|
2164f07f01 | ||
|
|
fc0037da31 | ||
|
|
795a1a29a3 | ||
|
|
476d9c5111 | ||
|
|
64625f7333 | ||
|
|
4ae8c1bc2b | ||
|
|
4ae97f1834 | ||
|
|
816e8e4bea | ||
|
|
c14d630f14 | ||
|
|
899433f79f | ||
|
|
ff9294e5b0 | ||
|
|
16db883427 | ||
|
|
1834268091 | ||
|
|
947e25f769 | ||
|
|
9fbe90527a | ||
|
|
10c637837c | ||
|
|
076f1450e5 | ||
|
|
bfa672c644 | ||
|
|
30ac5d8d38 | ||
|
|
5a2b05cc35 | ||
|
|
afe388a573 | ||
|
|
50a9cce9f4 | ||
|
|
8ee2fdbfd9 | ||
|
|
d6b4594150 | ||
|
|
771e263db8 | ||
|
|
ee13fec158 | ||
|
|
665ba30f65 | ||
|
|
0162a6727d | ||
|
|
d6de2c1a1d | ||
|
|
c4b4cfdc2f | ||
|
|
3435475ae0 | ||
|
|
31fae9d195 | ||
|
|
6ce5fe8fac | ||
|
|
e43b58fa02 | ||
|
|
1739cebfdb | ||
|
|
27c8412439 | ||
|
|
4b9299188a | ||
|
|
5aaef22cc0 | ||
|
|
f9df36a6de | ||
|
|
b3a75a9295 | ||
|
|
b8c90d24f1 | ||
|
|
e0b2ba5e54 | ||
|
|
5cdc7499ca | ||
|
|
ee859d044d | ||
|
|
cf8d1ddd10 | ||
|
|
a7ca72c59f | ||
|
|
8267c7ea64 | ||
|
|
d2cf8fef73 | ||
|
|
2df3fc8ddb | ||
|
|
987f1636aa | ||
|
|
15faf0d225 | ||
|
|
a8eba594d2 | ||
|
|
1783050f9a | ||
|
|
52291cadbf | ||
|
|
1865b430b0 | ||
|
|
d8734b4b18 | ||
|
|
eae1fa217b | ||
|
|
59ee0d93c6 | ||
|
|
d8164fd158 | ||
|
|
23ce5f08e7 | ||
|
|
e059253549 | ||
|
|
7dc8b0d9fe | ||
|
|
3f236b406f | ||
|
|
47dcdd8159 | ||
|
|
d93d36d6d3 | ||
|
|
c89807da1e | ||
|
|
53de3bde2c | ||
|
|
56414350e2 | ||
|
|
6bcad07a5c | ||
|
|
d56493c2c5 | ||
|
|
42f2594430 | ||
|
|
5ba3e4de97 | ||
|
|
02938c9cce | ||
|
|
65313cd7d3 | ||
|
|
5246f9dbc3 | ||
|
|
4d352bf726 | ||
|
|
eed3bc067f | ||
|
|
7bd256e17c | ||
|
|
7dbad4da3e | ||
|
|
fb85c34ca4 | ||
|
|
6401ca5847 | ||
|
|
496e240837 | ||
|
|
016ebe62cc | ||
|
|
28ab39cf96 | ||
|
|
ec67fe536e | ||
|
|
eff793d6fa | ||
|
|
e5e7280a17 | ||
|
|
773dc57712 | ||
|
|
98a043b195 | ||
|
|
c2a3c83099 | ||
|
|
3ea90aff27 | ||
|
|
23a362d6ad | ||
|
|
9b90a7980b | ||
|
|
cf2c43b5c7 | ||
|
|
2cb6a6e899 | ||
|
|
3ec6292520 | ||
|
|
7011d623d3 | ||
|
|
d4326eddd3 | ||
|
|
39dcdb18e2 | ||
|
|
fb0abff1c2 | ||
|
|
8a615b8742 | ||
|
|
f24d9d8c0d | ||
|
|
85cf7b41d5 | ||
|
|
dff07dd1e3 | ||
|
|
f17c25caf0 | ||
|
|
929c7baf16 | ||
|
|
dfa845a91c | ||
|
|
7fe9733e4d | ||
|
|
1b3c326784 | ||
|
|
0fd42364ca | ||
|
|
7e2c9641c2 | ||
|
|
a0d18d4d52 | ||
|
|
7adea0556c | ||
|
|
1e8efef66b | ||
|
|
f14747eead | ||
|
|
d1151c09a3 | ||
|
|
a9501ed65f | ||
|
|
d16deb42f5 | ||
|
|
b8f88a6560 | ||
|
|
1653781a9d | ||
|
|
fcff34045e | ||
|
|
ae675a05ef | ||
|
|
7f370e8193 | ||
|
|
870732a5aa | ||
|
|
2bf4de6db4 | ||
|
|
41d15a3a0a | ||
|
|
daca70bf80 | ||
|
|
0e02aa947a | ||
|
|
44ca1fbf8f | ||
|
|
27b84d79b8 |
@@ -94,6 +94,16 @@ inputs:
|
||||
description: If true, do not set any CXXFLAGS or LDFLAGS.
|
||||
default: false
|
||||
|
||||
# Unfortunately, "uses:" fields cannot have references to variables like
|
||||
# ${{env.MFEM_ACTIONS_VERSION}}, so the branch/tag name has to be hard coded.
|
||||
# Therefore, in the future, when updating the version of the
|
||||
# mfem/github-actions to use, we'll have to replace:
|
||||
# - all definitions of MFEM_ACTIONS_VERSION and
|
||||
# - all "uses:" fields that refer to mfem/github-actions.
|
||||
MFEM_ACTIONS_VERSION:
|
||||
description: Version (branch or tag) of the mfem/github-actions to use.
|
||||
default: v2.7
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
@@ -118,6 +128,7 @@ runs:
|
||||
echo UBSAN_LDFLAGS=${{inputs.UBSAN_LDFLAGS}} >> $GITHUB_ENV
|
||||
echo MSAN_CXXFLAGS=${{inputs.MSAN_CXXFLAGS}} >> $GITHUB_ENV
|
||||
echo MSAN_LDFLAGS=${{inputs.MSAN_LDFLAGS}} >> $GITHUB_ENV
|
||||
echo MFEM_ACTIONS_VERSION=${{inputs.MFEM_ACTIONS_VERSION}} >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Env (dir)
|
||||
|
||||
@@ -53,7 +53,7 @@ runs:
|
||||
run: echo CXXFLAGS=${{env.CXXFLAGS}} ${{env.UBSAN_CXXFLAGS}} >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- uses: mfem/github-actions/build-mfem@v2.5
|
||||
- uses: mfem/github-actions/build-mfem@v2.7
|
||||
if: ${{steps.debug.outputs.cache-hit != 'true'}}
|
||||
env:
|
||||
CXXFLAGS: ${{env.CXXFLAGS}}
|
||||
@@ -82,7 +82,7 @@ runs:
|
||||
run: find . -type f -name '*.o' -delete
|
||||
shell: bash
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: build-${{inputs.par}}-${{inputs.sanitizer}}
|
||||
path: mfem/build
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
name: 'Install MPI'
|
||||
description: 'Installs MPI and set up its environment variables'
|
||||
|
||||
inputs:
|
||||
NO_FLAGS:
|
||||
description: If true, do not set any CXXFLAGS or LDFLAGS.
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
@@ -27,6 +32,7 @@ runs:
|
||||
shell: bash
|
||||
|
||||
- name: Env (bis)
|
||||
if: ${{ inputs.NO_FLAGS != 'true' }}
|
||||
run: |
|
||||
echo CXXFLAGS=${{env.CXXFLAGS}} ${{env.MPI_INC}} >> $GITHUB_ENV
|
||||
echo LDFLAGS=${{env.LDFLAGS}} ${{env.MPI_LIB}} >> $GITHUB_ENV
|
||||
|
||||
@@ -49,7 +49,7 @@ runs:
|
||||
par: ${{inputs.par}}
|
||||
sanitizer: ${{inputs.sanitizer}}
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: build-${{inputs.par}}-${{inputs.sanitizer}}
|
||||
path: mfem/build
|
||||
|
||||
@@ -37,14 +37,14 @@ runs:
|
||||
with:
|
||||
path: ${{env.HYPRE_DIR}}
|
||||
fail-on-cache-miss: true
|
||||
key: ${{runner.os}}-ompi-build-${{env.HYPRE_DIR}}-int32-fp64-v2.5
|
||||
key: ${{runner.os}}-ompi-build-${{env.HYPRE_DIR}}-int32-fp64-${{env.MFEM_ACTIONS_VERSION}}
|
||||
|
||||
- uses: actions/cache/restore@v5 # Cache for Metis
|
||||
if: ${{inputs.par == 'true'}}
|
||||
with:
|
||||
path: ${{env.METIS_DIR}}
|
||||
fail-on-cache-miss: true
|
||||
key: ${{runner.os}}-build-${{env.METIS_DIR}}-v2.5
|
||||
key: ${{runner.os}}-build-${{env.METIS_DIR}}-${{env.MFEM_ACTIONS_VERSION}}
|
||||
|
||||
- name: Hypre/Metis links
|
||||
if: ${{inputs.par == 'true'}}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# MFEM Pull Request Review Agent Guide
|
||||
|
||||
## Purpose and scope
|
||||
Review MFEM PRs for correctness, maintainability, performance, portability, test coverage, and MFEM consistency. Use the diff and PR context; reference source files, tests, and CI results when available. Follow `CONTRIBUTING.md`, especially Developer Guidelines, PR rules, checklist, and testing.
|
||||
|
||||
## Critical review pillars
|
||||
- Correctness and numerical behavior
|
||||
- API and user-facing impact
|
||||
- Performance implications
|
||||
- Maintainability and portability
|
||||
|
||||
## Review workflow
|
||||
1. Read the PR description, linked issues, and intended behavior.
|
||||
2. Inspect the diff before commenting.
|
||||
3. Identify affected MFEM components, examples, tests, build or docs changes, and downstream APIs.
|
||||
4. Analyze the code against the critical review pillars.
|
||||
5. Compare the change against nearby code and MFEM patterns; flag unmotivated deviations.
|
||||
6. Check whether tests and documentation were updated appropriately.
|
||||
7. Review CI results and suggest actions.
|
||||
8. Produce a structured review with prioritized findings.
|
||||
9. Always limit conclusions to available evidence.
|
||||
|
||||
## MFEM-specific review checklist
|
||||
- Component-aware scope: identify the touched subsystem (FEM, solvers, preconditioners, linear algebra, mesh, examples, miniapps, build, or docs) and assess its impact against the review pillars.
|
||||
- Numerical and algorithmic behavior: assess issues in convergence, stability, tolerances, precision, iteration limits, and failure handling. If clear opportunities exist to improve the algorithmic approach, call them out with expected impact.
|
||||
- API and user-facing impact: assess backward compatibility, user-visible behavior and default changes, migration impact, deprecations, and whether documentation clearly explains user-facing API changes.
|
||||
- Data structure and memory semantics: assess ownership, lifetime, aliasing, container behavior, and device-host synchronization.
|
||||
- Parallel and serial behavior: assess whether the change preserves equivalent semantics in serial and parallel modes where applicable; if logic is currently mode-specific, check whether extension to the other mode is straightforward (clear abstractions, no hard-wired assumptions), document constraints, and call out expected behavior differences explicitly.
|
||||
- Backend and portability impact: assess likely cross-backend risks in CPU, CUDA, HIP, OCCA, RAJA, partial assembly, fallback paths, compiler compatibility, and platform assumptions.
|
||||
- Build, dependency, and configuration impact: assess CMake or make changes, optional dependency behavior, and feature-flag interactions.
|
||||
- Tests and docs alignment: check available regression or unit coverage evidence for changed behavior, and ensure docs are updated for new flags, APIs, options, or behavior changes.
|
||||
- MFEM developer-guideline fit: keep code lean, simple, general, logically separated, and portable; suggest C++17 improvements when they clearly improve safety, clarity, or maintainability.
|
||||
- New source files, examples, or miniapps: if a PR adds source/header files, verify they are properly wired into the relevant `makefile` and `CMakeLists.txt`, referenced in docs where applicable (including `doc/CodeDocumentation.dox`), and added to top-level `.gitignore` only when generated artifacts require it.
|
||||
- Changelog: verify `CHANGELOG` is updated if the PR introduces significant new features or user-facing changes.
|
||||
- MFEM conventions: use `real_t`; use `mfem::out`/`mfem::err` instead of `std::cout`/`std::cerr` in library code; flag large/binary files; if AI assistance is apparent but undisclosed, suggest following `CONTRIBUTING.md`.
|
||||
- Edge cases: if the PR touches complex or error-prone areas, suggest additional tests for edge cases, failure modes, and parallel behavior.
|
||||
|
||||
## Commenting guidelines
|
||||
- Keep comments concise, actionable, and grounded in the diff.
|
||||
- Focus on correctness, behavior changes, and user impact over style nits.
|
||||
- Be professional, concise, collaborative, technically precise, and avoid unsupported assumptions.
|
||||
|
||||
@@ -13,7 +13,7 @@ Note that some of these scripts use the shared MFEM GitHub Actions from the exte
|
||||
|
||||
<https://github.com/mfem/github-actions>
|
||||
|
||||
For a particular action, e.g. `mfem/github-actions/build-mfem@v2.5`, the `v2.5` suffix denotes the branch in the above from which the action is taken.
|
||||
For a particular action, e.g. `mfem/github-actions/build-mfem@v2.5`, the `v2.5` suffix denotes the branch (or tag) in the above from which the action is taken.
|
||||
|
||||
The current CI workflows are:
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ env:
|
||||
METIS_ARCHIVE_MAC: metis-4.0.3-mac.tgz
|
||||
METIS_TOP_DIR: metis-4.0.3
|
||||
MFEM_TOP_DIR: mfem
|
||||
MFEM_ACTIONS_VERSION: v2.7
|
||||
|
||||
# Note for future improvements:
|
||||
#
|
||||
@@ -170,20 +171,6 @@ jobs:
|
||||
env
|
||||
shell: bash
|
||||
|
||||
# For info on Xcode see:
|
||||
# - https://github.com/actions/runner-images/issues/12541
|
||||
# - https://github.com/actions/runner-images/blob/releases/macos-15-arm64/20250811/images/macos/macos-15-arm64-Readme.md#xcode
|
||||
- name: Xcode version setup (MacOS)
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
XCODE_PATH="/Applications/Xcode_16.4.app"
|
||||
echo "> sudo xcode-select -s ${XCODE_PATH}"
|
||||
sudo xcode-select -s ${XCODE_PATH}
|
||||
echo "> g++ -v"
|
||||
g++ -v
|
||||
echo "> clang++ -v"
|
||||
clang++ -v
|
||||
|
||||
# Only get MPI if defined for the job.
|
||||
# TODO: It would be nice to have only one step, e.g. with a dedicated
|
||||
# action, but I (@adrienbernede) don't see how at the moment.
|
||||
@@ -228,11 +215,11 @@ jobs:
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ env.HYPRE_TOP_DIR }}
|
||||
key: ${{ runner.os }}-ompi-build-${{ env.HYPRE_TOP_DIR }}-${{ matrix.hypre-target }}-${{ matrix.precision }}-v2.5
|
||||
key: ${{ runner.os }}-ompi-build-${{ env.HYPRE_TOP_DIR }}-${{ matrix.hypre-target }}-${{ matrix.precision }}-${{ env.MFEM_ACTIONS_VERSION }}
|
||||
|
||||
- name: get hypre
|
||||
if: matrix.mpi == 'par' && steps.hypre-cache.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
|
||||
uses: mfem/github-actions/build-hypre@v2.5
|
||||
uses: mfem/github-actions/build-hypre@v2.7
|
||||
with:
|
||||
archive: ${{ env.HYPRE_ARCHIVE }}
|
||||
dir: ${{ env.HYPRE_TOP_DIR }}
|
||||
@@ -242,7 +229,7 @@ jobs:
|
||||
|
||||
- name: get hypre (Windows)
|
||||
if: matrix.mpi == 'par' && steps.hypre-cache.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
|
||||
uses: mfem/github-actions/build-hypre@v2.5
|
||||
uses: mfem/github-actions/build-hypre@v2.7
|
||||
with:
|
||||
archive: ${{ env.HYPRE_ARCHIVE }}
|
||||
dir: ${{ env.HYPRE_TOP_DIR }}
|
||||
@@ -258,11 +245,11 @@ jobs:
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ env.METIS_TOP_DIR }}
|
||||
key: ${{ runner.os }}-build-${{ env.METIS_TOP_DIR }}-v2.5
|
||||
key: ${{ runner.os }}-build-${{ env.METIS_TOP_DIR }}-${{ env.MFEM_ACTIONS_VERSION }}
|
||||
|
||||
- name: install metis
|
||||
if: matrix.mpi == 'par' && matrix.os != 'windows-latest' && steps.metis-cache.outputs.cache-hit != 'true'
|
||||
uses: mfem/github-actions/build-metis@v2.5
|
||||
uses: mfem/github-actions/build-metis@v2.7
|
||||
with:
|
||||
archive: ${{ matrix.os != 'macos-latest' && env.METIS_ARCHIVE || env.METIS_ARCHIVE_MAC }}
|
||||
dir: ${{ env.METIS_TOP_DIR }}
|
||||
@@ -304,7 +291,7 @@ jobs:
|
||||
|
||||
# MFEM build and test
|
||||
- name: build
|
||||
uses: mfem/github-actions/build-mfem@v2.5
|
||||
uses: mfem/github-actions/build-mfem@v2.7
|
||||
env:
|
||||
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg_cache
|
||||
with:
|
||||
@@ -375,8 +362,10 @@ jobs:
|
||||
# Code coverage (process and upload reports)
|
||||
- name: codecov
|
||||
if: matrix.codecov == 'YES'
|
||||
uses: mfem/github-actions/upload-coverage@v2.5
|
||||
uses: mfem/github-actions/upload-coverage@v2.7
|
||||
with:
|
||||
name: ${{ matrix.os }}-${{ matrix.build-system }}-${{ matrix.target }}-${{ matrix.mpi }}-${{ matrix.hypre-target }}
|
||||
name: ${{ matrix.os }}-${{ matrix.build-system }}-${{ matrix.target }}-${{ matrix.mpi }}-${{ matrix.hypre-target }}-${{ matrix.precision }}
|
||||
project_dir: ${{ env.MFEM_TOP_DIR }}
|
||||
directories: "fem general linalg mesh"
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
@@ -32,6 +32,7 @@ env:
|
||||
METIS_ARCHIVE: metis-4.0.3.tar.gz
|
||||
METIS_TOP_DIR: metis-4.0.3
|
||||
COVERAGE_ENV: mfem-coverage
|
||||
MFEM_ACTIONS_VERSION: v2.7
|
||||
|
||||
jobs:
|
||||
gitignore:
|
||||
@@ -53,33 +54,34 @@ jobs:
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ env.HYPRE_TOP_DIR }}
|
||||
key: ${{ runner.os }}-ompi-build-${{ env.HYPRE_TOP_DIR }}-v2.5
|
||||
key: ${{ runner.os }}-ompi-build-${{ env.HYPRE_TOP_DIR }}-int32-fp64-${{ env.MFEM_ACTIONS_VERSION }}
|
||||
|
||||
- name: Get Hypre
|
||||
if: steps.hypre-cache.outputs.cache-hit != 'true'
|
||||
uses: mfem/github-actions/build-hypre@v2.5
|
||||
uses: mfem/github-actions/build-hypre@v2.7
|
||||
with:
|
||||
archive: ${{ env.HYPRE_ARCHIVE }}
|
||||
dir: ${{ env.HYPRE_TOP_DIR }}
|
||||
target: int32
|
||||
precision: fp64
|
||||
|
||||
- name: Cache Metis Install
|
||||
id: metis-cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ env.METIS_TOP_DIR }}
|
||||
key: ${{ runner.os }}-build-${{ env.METIS_TOP_DIR }}-v2.5
|
||||
key: ${{ runner.os }}-build-${{ env.METIS_TOP_DIR }}-${{ env.MFEM_ACTIONS_VERSION }}
|
||||
|
||||
- name: Install Metis
|
||||
if: steps.metis-cache.outputs.cache-hit != 'true'
|
||||
uses: mfem/github-actions/build-metis@v2.5
|
||||
uses: mfem/github-actions/build-metis@v2.7
|
||||
with:
|
||||
archive: ${{ env.METIS_ARCHIVE }}
|
||||
dir: ${{ env.METIS_TOP_DIR }}
|
||||
|
||||
# MFEM build and test
|
||||
- name: build-mfem
|
||||
uses: mfem/github-actions/build-mfem@v2.5
|
||||
uses: mfem/github-actions/build-mfem@v2.7
|
||||
with:
|
||||
os: ${{ runner.os }}
|
||||
target: opt
|
||||
|
||||
@@ -19,18 +19,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/sanitize/config
|
||||
with:
|
||||
NO_FLAGS: true
|
||||
- name: Cache
|
||||
id: cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{env.HYPRE_DIR}}
|
||||
key: ${{runner.os}}-ompi-build-${{env.HYPRE_DIR}}-int32-fp64-v2.5
|
||||
key: ${{runner.os}}-ompi-build-${{env.HYPRE_DIR}}-int32-fp64-${{ env.MFEM_ACTIONS_VERSION }}
|
||||
- name: Setup
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
uses: ./.github/actions/sanitize/mpi
|
||||
with:
|
||||
NO_FLAGS: true
|
||||
- name: Build
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
uses: mfem/github-actions/build-hypre@v2.5
|
||||
uses: mfem/github-actions/build-hypre@v2.7
|
||||
with:
|
||||
archive: ${{env.HYPRE_TGZ}}
|
||||
dir: ${{env.HYPRE_DIR}}
|
||||
|
||||
@@ -19,18 +19,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/sanitize/config
|
||||
with:
|
||||
NO_FLAGS: true
|
||||
- name: Cache
|
||||
id: cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{env.METIS_DIR}}
|
||||
key: ${{runner.os}}-build-${{env.METIS_DIR}}-v2.5
|
||||
key: ${{runner.os}}-build-${{env.METIS_DIR}}-${{env.MFEM_ACTIONS_VERSION}}
|
||||
- name: Setup
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
uses: ./.github/actions/sanitize/mpi
|
||||
with:
|
||||
NO_FLAGS: true
|
||||
- name: Build
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
uses: mfem/github-actions/build-metis@v2.5
|
||||
uses: mfem/github-actions/build-metis@v2.7
|
||||
with:
|
||||
archive: ${{env.METIS_TGZ}}
|
||||
dir: ${{env.METIS_DIR}}
|
||||
|
||||
@@ -146,7 +146,7 @@ jobs:
|
||||
if: ${{steps.restore.outputs.cache-hit != 'true'}}
|
||||
working-directory: mfem/build/tests/unit
|
||||
run: find . -type f -name '*.o' -delete
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: tests-${{inputs.par}}-${{inputs.sanitizer}}
|
||||
path: mfem/build/tests/unit/${{env.unit_tests}}
|
||||
@@ -172,7 +172,7 @@ jobs:
|
||||
par: ${{inputs.par}}
|
||||
sanitizer: ${{inputs.sanitizer}}
|
||||
cache-path: mfem/build/tests/unit/${{env.unit_tests}}
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v8
|
||||
if: ${{steps.restore.outputs.cache-hit != 'true'}}
|
||||
with:
|
||||
name: tests-${{inputs.par}}-${{inputs.sanitizer}}
|
||||
|
||||
@@ -85,3 +85,8 @@ opt_par_gcc_10_pumi:
|
||||
extends: .mfem_job_on_dane
|
||||
variables:
|
||||
SPEC: "%gcc@10.3.1 +pumi"
|
||||
|
||||
opt_par_gcc_10_gslib:
|
||||
extends: .mfem_job_on_dane
|
||||
variables:
|
||||
SPEC: "%gcc@10.3.1 +gslib"
|
||||
|
||||
@@ -63,3 +63,8 @@ opt_mpi_cuda_hypre_cuda_gcc:
|
||||
extends: .mfem_job_on_matrix
|
||||
variables:
|
||||
SPEC: "%gcc@10.3.1 +mpi +cuda cuda_arch=90 ^hypre+cuda"
|
||||
|
||||
opt_mpi_cuda_gcc_gslib:
|
||||
extends: .mfem_job_on_matrix
|
||||
variables:
|
||||
SPEC: "%gcc@10.3.1 +mpi +cuda +gslib cuda_arch=90 ^hypre+cuda"
|
||||
|
||||
@@ -32,9 +32,9 @@ mkdir _${BASELINE_TEST} && cd _${BASELINE_TEST}
|
||||
|
||||
# run
|
||||
if [[ "${MACHINE_NAME}" == "dane" ]]; then
|
||||
salloc --nodes=1 -t 60 --exclusive --reservation=ci ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
srun --nodes=1 -t 60 --exclusive --reservation=ci ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
elif [[ ${MACHINE_NAME} == "corona" ]]; then
|
||||
salloc --nodes=1 -t 60 -p pbatch ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
srun --nodes=1 -t 60 -p pbatch ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
else
|
||||
echo "Unknown machine: MACHINE_NAME=$MACHINE_NAME"
|
||||
exit 1
|
||||
|
||||
@@ -8,43 +8,83 @@
|
||||
https://mfem.org
|
||||
|
||||
|
||||
Version 4.10 (development)
|
||||
==========================
|
||||
|
||||
Discretization improvements
|
||||
---------------------------
|
||||
- Replaced legacy simplex quadrature rules with symmetric positive-weight
|
||||
rules for triangles (orders 0-25) and tetrahedra (orders 0-20). These
|
||||
rules guarantee all-positive weights and interior quadrature points,
|
||||
improving numerical stability. Higher orders fall back to Grundmann-Moller.
|
||||
Triangle rules: Witherden & Vincent, Comput. Math. Appl. 69(10):1232-1241,
|
||||
2015.
|
||||
Tet rules (d=1-13): Witherden & Vincent (ibid).
|
||||
Tet rules (d=14-20): Chuluunbaatar et al., Comput. Math. Appl. 124:89-97,
|
||||
2022.
|
||||
|
||||
|
||||
Version 4.9.1 (development)
|
||||
===========================
|
||||
|
||||
- Added policy for AI-assisted contribution to CONTRIBUTING.md.
|
||||
|
||||
Discretization improvements
|
||||
---------------------------
|
||||
- Improved the gridfunction projection routines. Projections work for Scalar,
|
||||
Vector and VectorFE, also NURBS versions. Optionally different types of
|
||||
projections can be selected, default behaviour has not changed.
|
||||
- Added GPU-enabled partial assembly for simplicial Bernstein H1 basis based on
|
||||
ragged tensor algorithms (see DOI: 10.1137/11082539X) for mass and diffusion
|
||||
integrators.
|
||||
|
||||
- Added methods to estimate function extremum using piecewise linear bounds +
|
||||
- Replaced legacy simplex quadrature rules with symmetric positive weight rules
|
||||
for triangles (orders 0-25) and tetrahedra (orders 0-20). These rules
|
||||
guarantee all-positive weights and interior quadrature points, improving
|
||||
numerical stability. Higher orders fall back to Grundmann-Moller.
|
||||
* Triangle rules: Witherden and Vincent, DOI: 10.1016/j.camwa.2015.03.017
|
||||
* Tet rules (d=1-13): Witherden and Vincent (same as above)
|
||||
* Tet rules (d=14-20): Chuluunbaatar et al., DOI: 10.1016/j.camwa.2022.08.016
|
||||
|
||||
- Added support for general 1D Gauss-Jacobi quadrature rules and Stroud conical
|
||||
quadrature rules on triangles and tetrahedra.
|
||||
|
||||
- Improved the GridFunction projection routines. Projections work for Scalar,
|
||||
Vector and VectorFE, also NURBS versions. Optionally different types of
|
||||
projections can be selected, default behavior has not changed.
|
||||
|
||||
- Added GridFunction projection methods for trace spaces, i.e., project
|
||||
coefficients on the mesh skeleton.
|
||||
|
||||
- Added methods to estimate function extremum using piecewise linear bounds plus
|
||||
recursive subdivision.
|
||||
|
||||
- Extend FindPointsGSLIB to support surface meshes.
|
||||
|
||||
Meshing improvements
|
||||
--------------------
|
||||
- Added option to guarantee mesh validity during TMOP-based r-adaptivity, using
|
||||
bounds on the determinant of the mesh transformation Jacobian.
|
||||
|
||||
- Added PA support for TMOP's adaptive limiting functionality. Multiple
|
||||
GridFunctions and Coefficients can be combined to form a composite term.
|
||||
|
||||
- Improved support for 1D NURBS meshes with variable order, including using
|
||||
the patches construct for 1D NURBS meshes.
|
||||
|
||||
- Added the option to include material interfaces (faces separating elements
|
||||
with different element attributes) as additional boundary elements, for
|
||||
parallel visualization, e.g. with GLVis. This is supported by both the Print
|
||||
and PrintAsOne methods of ParMesh. See ParMesh::SetPrintInterfaces().
|
||||
|
||||
Linear and nonlinear solvers
|
||||
----------------------------
|
||||
- Added support for trace spaces in PRefinementTransferOperator. This is used in
|
||||
PRefinement multigrid methods for problems posed on trace spaces (see e.g. the
|
||||
DPG miniapps).
|
||||
|
||||
GPU computing
|
||||
-------------
|
||||
- Added NVIDIA cuDSS library interface. Implementation examples have been
|
||||
added to ex1 and ex1p. See https://developer.nvidia.com/cudss for more
|
||||
details. Supported versions >= 0.6.0.
|
||||
|
||||
- Allow specifying GPU kernel launch bounds for native and RAJA GPU backends.
|
||||
|
||||
New and updated examples and miniapps
|
||||
-------------------------------------
|
||||
- Electromagnetics/lorentz miniapp has been updated to leverage the ParticleSet
|
||||
capability.
|
||||
- The Lorentz miniapp (in miniapps/electromagnetics) has been updated to
|
||||
leverage the ParticleSet capability.
|
||||
|
||||
- Added (Complex)PRefinementMultigrid solver option in the DPG miniapps.
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
- Fixed signed DOF handling in ParGridFunction reading (read constructor) and
|
||||
saving via SaveAsOne(). Simplified the process of applying the DOF signs by
|
||||
using the new method ApplyDofSigns() in class ParFiniteElementSpace: the
|
||||
method will return immediately if no sign flips are needed.
|
||||
|
||||
|
||||
Version 4.9, released on Dec 11, 2025
|
||||
|
||||
+10
-1
@@ -433,6 +433,15 @@ if (MFEM_USE_STRUMPACK)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# cuDSS can only be enabled in CUDA
|
||||
if (MFEM_USE_CUDSS)
|
||||
if (MFEM_USE_CUDA)
|
||||
find_package(CUDSS REQUIRED)
|
||||
else()
|
||||
message(FATAL_ERROR " *** cuDSS requires that CUDA be enabled.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# GnuTLS
|
||||
if (MFEM_USE_GNUTLS)
|
||||
find_package(_GnuTLS REQUIRED)
|
||||
@@ -631,7 +640,7 @@ find_package(Threads REQUIRED)
|
||||
set(MFEM_TPLS OPENMP HYPRE LAPACK BLAS SuperLUDist STRUMPACK METIS SuiteSparse
|
||||
SUNDIALS PETSC SLEPC MUMPS AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB HDF5
|
||||
NETCDF MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE
|
||||
ADIOS2 MKL_CPARDISO MKL_PARDISO AMGX MAGMA CUSPARSE CUBLAS CALIPER CODIPACK
|
||||
ADIOS2 MKL_CPARDISO MKL_PARDISO AMGX MAGMA CUSPARSE CUBLAS CUDSS CALIPER CODIPACK
|
||||
BENCHMARK PARELAG TRIBOL MPI_CXX HIP HIPBLAS HIPSPARSE MOONOLITH BLITZ
|
||||
ALGOIM ENZYME CUDA::cudart)
|
||||
|
||||
|
||||
+73
-65
@@ -3,12 +3,13 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/mfem/mfem/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-BSD-brightgreen.svg"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions?query=workflow%3Arepo-check+branch%3Amaster"><img alt="Repo check" src="https://github.com/mfem/mfem/actions/workflows/repo-check.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions?query=workflow%3Abuild-analysis+branch%3Amaster"><img alt="Build Analysis" src="https://github.com/mfem/mfem/actions/workflows/mfem-analysis.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions?query=workflow%3Abuilds-and-tests+branch%3Amaster"><img alt="Builds and Tests" src="https://github.com/mfem/mfem/actions/workflows/builds-and-tests.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://github.com/mfem/mfem/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-BSD-blue.svg"></a>
|
||||
<a href="https://github.com/mfem/mfem/releases/latest"><img alt="GitHub release" src="https://img.shields.io/github/v/release/mfem/mfem"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions/workflows/repo-check.yml?query=branch%3Amaster"><img alt="Repo check" src="https://github.com/mfem/mfem/actions/workflows/repo-check.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions/workflows/mfem-analysis.yml?query=branch%3Amaster"><img alt="Build Analysis" src="https://github.com/mfem/mfem/actions/workflows/mfem-analysis.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://github.com/mfem/mfem/actions/workflows/builds-and-tests.yml?query=branch%3Amaster"><img alt="Builds and Tests" src="https://github.com/mfem/mfem/actions/workflows/builds-and-tests.yml/badge.svg?branch=master"></a>
|
||||
<a href="https://ci.appveyor.com/project/mfem/mfem"><img alt="Build Status" src="https://ci.appveyor.com/api/projects/status/19non9sqm6msi2wy?svg=true"></a>
|
||||
<a href="https://docs.mfem.org/html/index.html"><img alt="Doxygen" src="https://img.shields.io/badge/code-documented-brightgreen.svg"></a>
|
||||
<a href="https://docs.mfem.org/html/index.html"><img alt="Documentation" src="https://img.shields.io/badge/code-documented-brightgreen.svg"></a>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -24,6 +25,14 @@ 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.
|
||||
|
||||
## AI Policy
|
||||
- Use of AI code generation in MFEM is allowed but must be disclosed, e.g. by
|
||||
selecting the `AI-assisted` label on the PR.
|
||||
- By submitting a PR, the author acknowledges that they have reviewed and
|
||||
understand the changes they are proposing.
|
||||
- PR authors are still responsible for correctness, licensing, and attribution
|
||||
of all changes.
|
||||
|
||||
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
|
||||
@@ -76,7 +85,7 @@ Origin](#developers-certificate-of-origin-11) at the end of this file.*
|
||||
follow the [MFEM PR Rules](#mfem-pr-rules).
|
||||
- When your contribution is fully working and ready to be reviewed, add
|
||||
the `ready-for-review` label.
|
||||
- PRs are treated similarly to journal submission with an "editor" assigning two
|
||||
- PRs are treated similarly to journal submission, with an "editor" assigning two
|
||||
reviewers to evaluate the changes.
|
||||
- The reviewers have 3 weeks to evaluate the PR and work with the author to
|
||||
fix issues and implement improvements.
|
||||
@@ -117,7 +126,7 @@ The MFEM source code has the following structure:
|
||||
│ ├── petsc
|
||||
│ ├── pumi
|
||||
│ ├── sundials
|
||||
| └── superlu
|
||||
│ └── superlu
|
||||
├── fem
|
||||
│ ├── ceed
|
||||
│ ├── dfem
|
||||
@@ -129,10 +138,6 @@ The MFEM source code has the following structure:
|
||||
│ ├── moonolith
|
||||
│ ├── qinterp
|
||||
│ └── tmop
|
||||
│ | ├── assemble
|
||||
│ | ├── metrics
|
||||
│ | ├── mult
|
||||
│ | └── tools
|
||||
├── general
|
||||
├── linalg
|
||||
│ ├── batched
|
||||
@@ -145,11 +150,10 @@ The MFEM source code has the following structure:
|
||||
│ ├── common
|
||||
│ ├── contact
|
||||
│ ├── dfem
|
||||
│ ├── diag-smoothers
|
||||
│ ├── dpg
|
||||
│ ├── electromagnetics
|
||||
│ ├── fluids
|
||||
│ │ ├── navier
|
||||
│ │ └── schrodinger-flow
|
||||
│ ├── gslib
|
||||
│ ├── hdiv-linear-solver
|
||||
│ ├── hooke
|
||||
@@ -159,6 +163,7 @@ The MFEM source code has the following structure:
|
||||
│ ├── nurbs
|
||||
│ ├── parelag
|
||||
│ ├── performance
|
||||
│ ├── plasma
|
||||
│ ├── shifted
|
||||
│ ├── solvers
|
||||
│ ├── spde
|
||||
@@ -189,15 +194,15 @@ respectively.
|
||||
|
||||
- The main finite element classes are:
|
||||
+ [`FiniteElement`](https://docs.mfem.org/html/classmfem_1_1FiniteElement.html)
|
||||
+ [`FiniteElementCollection`](https://docs.mfem.org/html/classmfem_1_1FiniteElement.html)
|
||||
+ [`FiniteElementCollection`](https://docs.mfem.org/html/classmfem_1_1FiniteElementCollection.html)
|
||||
+ [`FiniteElementSpace`](https://docs.mfem.org/html/classmfem_1_1FiniteElementSpace.html)
|
||||
+ [`GridFunction`](https://docs.mfem.org/html/classmfem_1_1GridFunction.html)
|
||||
+ [`BilinearFormIntegrator`](https://docs.mfem.org/html/classmfem_1_1BilinearFormIntegrator.html) and [`LinearFormIntegrator`](https://docs.mfem.org/html/classmfem_1_1LinearFormIntegrator.html)
|
||||
+ [`LinearForm`](https://docs.mfem.org/html/classmfem_1_1LinearFormIntegrator.html), [`BilinearForm`](https://docs.mfem.org/html/classmfem_1_1BilinearForm.html) and [`MixedBilinearForm`](https://docs.mfem.org/html/classmfem_1_1MixedBilinearForm.html)
|
||||
+ [`LinearForm`](https://docs.mfem.org/html/classmfem_1_1LinearForm.html), [`BilinearForm`](https://docs.mfem.org/html/classmfem_1_1BilinearForm.html) and [`MixedBilinearForm`](https://docs.mfem.org/html/classmfem_1_1MixedBilinearForm.html)
|
||||
|
||||
- The main linear algebra classes and sources are
|
||||
+ [`Operator`](https://docs.mfem.org/html/classmfem_1_1Operator.html) and [`BilinearForm`](https://docs.mfem.org/html/classmfem_1_1BilinearForm.html)
|
||||
+ [`Vector`](https://docs.mfem.org/html/classmfem_1_1BilinearForm.html) and [`LinearForm`](https://docs.mfem.org/html/classmfem_1_1LinearForm.html)
|
||||
+ [`Vector`](https://docs.mfem.org/html/classmfem_1_1Vector.html) and [`LinearForm`](https://docs.mfem.org/html/classmfem_1_1LinearForm.html)
|
||||
+ [`DenseMatrix`](https://docs.mfem.org/html/classmfem_1_1DenseMatrix.html) and [`SparseMatrix`](https://docs.mfem.org/html/classmfem_1_1SparseMatrix.html)
|
||||
+ Sparse [smoothers](https://docs.mfem.org/html/sparsesmoothers_8hpp.html) and linear [solvers](https://docs.mfem.org/html/solvers_8hpp.html)
|
||||
|
||||
@@ -209,8 +214,8 @@ shared geometric entities between different tasks. The parallel source files
|
||||
have a `p` prefix, e.g. `pmesh.cpp` vs. the serial `mesh.cpp`.
|
||||
|
||||
- The main parallel classes are
|
||||
+ [`ParMesh`](https://docs.mfem.org/html/solvers_8hpp.html)
|
||||
+ [`ParNCMesh`](https://docs.mfem.org/html/classmfem_1_1ParMesh.html)
|
||||
+ [`ParMesh`](https://docs.mfem.org/html/classmfem_1_1ParMesh.html)
|
||||
+ [`ParNCMesh`](https://docs.mfem.org/html/classmfem_1_1ParNCMesh.html)
|
||||
+ [`ParFiniteElementSpace`](https://docs.mfem.org/html/classmfem_1_1ParFiniteElementSpace.html)
|
||||
+ [`ParGridFunction`](https://docs.mfem.org/html/classmfem_1_1ParGridFunction.html)
|
||||
+ [`ParBilinearForm`](https://docs.mfem.org/html/classmfem_1_1ParBilinearForm.html) and [`ParLinearForm`](https://docs.mfem.org/html/classmfem_1_1ParLinearForm.html)
|
||||
@@ -220,14 +225,14 @@ have a `p` prefix, e.g. `pmesh.cpp` vs. the serial `mesh.cpp`.
|
||||
#### GPU and general device support
|
||||
|
||||
GPU and multi-core CPU support is based on device kernels supporting different
|
||||
backends (CUDA, OCCA, RAJA, OpenMP, etc.) and an internal lightweight
|
||||
backends (CUDA, HIP, OCCA, RAJA, OpenMP, etc.) and an internal lightweight
|
||||
device/host memory manager.
|
||||
|
||||
- The main device-relevant classes and sources are:
|
||||
+ [`Device`](https://docs.mfem.org/html/device_8hpp.html)
|
||||
+ [`MemoryManager`](https://docs.mfem.org/html/mem_manager_8hpp.html)
|
||||
+ the [`mfem::forall`](https://docs.mfem.org/html/forall_8hpp.html) function
|
||||
+ the [`cuda.hpp`](https://docs.mfem.org/html/cuda_8hpp.html) and [`occa.hpp`](https://docs.mfem.org/html/occa_8hpp.html) files
|
||||
+ the [`cuda.hpp`](https://docs.mfem.org/html/cuda_8hpp.html), [`hip.hpp`](https://docs.mfem.org/html/hip_8hpp.html) and [`occa.hpp`](https://docs.mfem.org/html/occa_8hpp.html) files
|
||||
|
||||
#### Utilities, building and documentation
|
||||
- The `general/` directory contains C++ classes that serve as utilities for
|
||||
@@ -241,8 +246,8 @@ device/host memory manager.
|
||||
- `examples` and `miniapps` respectively gather simple and more fully-featured
|
||||
demonstrations of the usage on MFEM. They both rely on `data/` for the
|
||||
collection of meshes.
|
||||
- The `tests/` directory contains a unit test suite and will later contain more
|
||||
tests that run example codes.
|
||||
- The `tests/` directory contains a unit test suite, additional tests, and
|
||||
benchmarks.
|
||||
|
||||
See also the [code overview](https://mfem.org/code-overview/) section on the MFEM
|
||||
website.
|
||||
@@ -276,8 +281,8 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
the top of https://github.com/mfem.
|
||||
- Consider making your membership public by going to https://github.com/orgs/mfem/people
|
||||
and clicking on the organization visibility drop box next to your name.
|
||||
- Project discussions and announcements will be posted at
|
||||
https://github.com/orgs/mfem/teams/everyone.
|
||||
- Project discussions and announcements will be posted at https://github.com/orgs/mfem/discussions,
|
||||
tagging the `@mfem/everyone` team when appropriate.
|
||||
|
||||
#### Structure
|
||||
- The MFEM source code is in the [mfem](https://github.com/mfem/mfem)
|
||||
@@ -337,11 +342,12 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
- Well-designed simple code is frequently more general and powerful.
|
||||
- Lean code base is easier to understand by new collaborators.
|
||||
- New features should be added only if they are necessary or generally useful.
|
||||
- Introduction of language constructions not currently used in MFEM should be
|
||||
- Introduction of language constructs not currently used in MFEM should be
|
||||
justified and generally avoided (to maintain portability to various systems
|
||||
and compilers, including early access hardware).
|
||||
- We prefer basic C++ and the C++03 standard, to keep the code readable by
|
||||
a large audience and to make sure it compiles anywhere.
|
||||
- We prefer basic C++. Use C++17 features judiciously, prioritizing readability,
|
||||
consistency with existing MFEM code, and portability to different systems,
|
||||
compilers and device backends.
|
||||
|
||||
- *Keep the code general and reasonably efficient*
|
||||
- The main goal is fast prototyping for research and application development.
|
||||
@@ -384,7 +390,7 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
- When your branch is ready for other developers to review / comment on
|
||||
the code, create a pull request towards `mfem:master`.
|
||||
|
||||
- Pull request typically have titles like:
|
||||
- Pull requests typically have titles like:
|
||||
|
||||
`Description [new-feature-dev]`
|
||||
|
||||
@@ -405,12 +411,12 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
- Add a description, appropriate labels and assign yourself to the PR. The MFEM
|
||||
team will add reviewers as appropriate.
|
||||
|
||||
- List outstanding TODO items in the description, see PR #222 for an example.
|
||||
- List outstanding TODO items in the description.
|
||||
|
||||
- When your contribution is fully working and ready to be reviewed, add
|
||||
the `ready-for-review` label.
|
||||
or request the `ready-for-review` label.
|
||||
|
||||
- PRs are treated similarly to journal submission with an "editor" assigning
|
||||
- PRs are treated similarly to journal submission, with an "editor" assigning
|
||||
two reviewers to evaluate the changes. The reviewers have 3 weeks to evaluate
|
||||
the PR and work with the author to implement improvements and fix issues.
|
||||
|
||||
@@ -436,7 +442,7 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
checks in GitHub Actions enforce MFEM-specific rules which are explained in
|
||||
the error messages and the `tests/scripts` directory.
|
||||
|
||||
- Also note that the tests `branch-history` and `repos-checks` found in GitHub
|
||||
- Also note that the tests `branch-history` and `repo-check` found in GitHub
|
||||
Actions can be triggered automatically before each push using git hooks. See
|
||||
the [git hooks README](config/githooks/README.md) for a detailed explanation.
|
||||
|
||||
@@ -493,15 +499,15 @@ Everyone on the MFEM team can be asked to serve as a reviewer on a PR in their a
|
||||
|
||||
3. To ensure the quality of the PR by making sure that the code adheres to the [Developer Guidelines](#developer-guidelines), e.g. all methods, data members, and functions have documentation, including data ownership and lifetime, new examples/miniapps have a corresponding PR in mfem/web, major features have `CHANGELOG` entries, etc.
|
||||
|
||||
3. To seek help from the editors in case of difficulties.
|
||||
4. To seek help from the editors in case of difficulties.
|
||||
|
||||
4. To complete the review in a timely manner: 3 weeks from assignment.
|
||||
5. To complete the review in a timely manner: 3 weeks from assignment.
|
||||
|
||||
5. To test the PR thoroughly before merging in *next*. The PR author is also encouraged to perform testing and inform the reviewers about the results.
|
||||
6. To test the PR thoroughly before merging in *next*. The PR author is also encouraged to perform testing and inform the reviewers about the results.
|
||||
|
||||
6. To monitor the PR impact on the testing in the *next* branch and alert the editors that the PR is ready for merging in *master*.
|
||||
7. To monitor the PR impact on the testing in the *next* branch and alert the editors that the PR is ready for merging in *master*.
|
||||
|
||||
7. The review of bugfixes should be expedited proportional to their importance. The review window can be much less than three weeks in such cases.
|
||||
8. The review of bugfixes should be expedited proportional to their importance. The review window can be much less than three weeks in such cases.
|
||||
|
||||
#### Responsibilities of Authors
|
||||
|
||||
@@ -527,30 +533,30 @@ Before a PR can be merged, it should satisfy the following:
|
||||
- [ ] Code builds.
|
||||
- [ ] Code passes `make style`.
|
||||
- [ ] Update `CHANGELOG`:
|
||||
- [ ] Is this a new feature users need to be aware of? New or updated example or miniapp?
|
||||
- [ ] Does it make sense to create a new section in the `CHANGELOG` to group with other related features?
|
||||
- [ ] Is this a new feature users need to be aware of? New or updated example or miniapp?
|
||||
- [ ] Does it make sense to create a new section in the `CHANGELOG` to group with other related features?
|
||||
- [ ] Update `INSTALL`:
|
||||
- [ ] Had a new optional library been added? If so, what range of versions of this library are required? (*Make sure the external library is compatible with our BSD license, e.g. it is not licensed under GPL!*)
|
||||
- [ ] Have the version ranges for any required or optional libraries changed?
|
||||
- [ ] Does `make` or `cmake` have a new target?
|
||||
- [ ] Did the requirements or the installation process change? *(rare)*
|
||||
- [ ] Has a new optional library been added? If so, what range of versions of this library are required? (*Make sure the external library is compatible with our BSD license, e.g. it is not licensed under GPL!*)
|
||||
- [ ] Have the version ranges for any required or optional libraries changed?
|
||||
- [ ] Does `make` or `cmake` have a new target?
|
||||
- [ ] Did the requirements or the installation process change? *(rare)*
|
||||
- [ ] Update continuous integration server configurations if necessary (e.g. with new version requirements for each of MFEM's dependencies)
|
||||
- [ ] `.github`
|
||||
- [ ] `.appveyor.yml`
|
||||
- [ ] `.github`
|
||||
- [ ] `.appveyor.yml`
|
||||
- [ ] Update `.gitignore`:
|
||||
- [ ] Check if `make distclean; git status` shows any files that were generated from the source by the project (not an IDE) but we don't want to track in the repository.
|
||||
- [ ] Add new patterns (just for the new files above) and re-run the above test.
|
||||
- [ ] Check if `make distclean; git status` shows any files that were generated from the source by the project (not an IDE) but we don't want to track in the repository.
|
||||
- [ ] Add new patterns (just for the new files above) and re-run the above test.
|
||||
- [ ] New examples:
|
||||
- [ ] All sample runs at the top of the example source file work.
|
||||
- [ ] Update `examples/makefile`:
|
||||
- [ ] All sample runs at the top of the example source file work.
|
||||
- [ ] Update `examples/makefile`:
|
||||
- [ ] Add the example code to the appropriate `SEQ_EXAMPLES` and `PAR_EXAMPLES` variables.
|
||||
- [ ] Add any files generated by it to the `clean` target.
|
||||
- [ ] Add the example binary and any files generated by it to the top-level `.gitignore` file.
|
||||
- [ ] Update `examples/CMakeLists.txt`:
|
||||
- [ ] Update `examples/CMakeLists.txt`:
|
||||
- [ ] Add the example code to the `ALL_EXE_SRCS` variable.
|
||||
- [ ] Make sure `THIS_TEST_OPTIONS` is set correctly for the new example.
|
||||
- [ ] List the new example in `doc/CodeDocumentation.dox`.
|
||||
- [ ] If new examples directory (e.g.`examples/pumi`), list it in `doc/CodeDocumentation.conf.in`
|
||||
- [ ] If new examples directory (e.g. `examples/pumi`), list it in `doc/CodeDocumentation.conf.in`
|
||||
- [ ] Companion pull request for documentation in [mfem/web](https://github.com/mfem/web) repo:
|
||||
- [ ] Update or add example-specific documentation, see e.g. the `src/examples.md`.
|
||||
- [ ] Add the description, labels and screenshots in `src/examples.md` and `src/img`.
|
||||
@@ -567,13 +573,13 @@ Before a PR can be merged, it should satisfy the following:
|
||||
- [ ] Add/update the `CMakeLists.txt` file in the new miniapp directory.
|
||||
- [ ] Consider adding a new test for the new miniapp.
|
||||
- [ ] List the new miniapp in `doc/CodeDocumentation.dox`
|
||||
- [ ] If new miniapps directory (e.g.`miniapps/nurbs`), add it to `MINIAPP_SUBDIRS` in the `makefile`.
|
||||
- [ ] If new miniapps directory (e.g.`miniapps/nurbs`), list it in `doc/CodeDocumentation.conf.in`
|
||||
- [ ] If new miniapps directory (e.g. `miniapps/nurbs`), add it to `MINIAPP_SUBDIRS` in the `makefile`.
|
||||
- [ ] If new miniapps directory (e.g. `miniapps/nurbs`), list it in `doc/CodeDocumentation.conf.in`
|
||||
- [ ] Companion pull request for documentation in [mfem/web](https://github.com/mfem/web) repo:
|
||||
- [ ] Update or add miniapp-specific documentation, see e.g. the `src/meshing.md` and `src/electromagnetics.md` files.
|
||||
- [ ] Add the description, labels and screenshots in `src/examples.md` and `src/img`.
|
||||
- [ ] The miniapps go at the end of the page, and are usually listed only under a specific "Application (PDE)" category.
|
||||
- [ ] Add a short description of the miniapp in the "Extensive Examples" section of `features.md`.
|
||||
- [ ] Update or add miniapp-specific documentation, see e.g. the `src/meshing.md` and `src/electromagnetics.md` files.
|
||||
- [ ] Add the description, labels and screenshots in `src/examples.md` and `src/img`.
|
||||
- [ ] The miniapps go at the end of the page, and are usually listed only under a specific "Application (PDE)" category.
|
||||
- [ ] Add a short description of the miniapp in the "Extensive Examples" section of `features.md`.
|
||||
- [ ] New capability:
|
||||
- [ ] All new public, protected, and private classes, methods, data members, and functions have full Doxygen-style documentation in source comments. Documentation should include descriptions of member data, function arguments and return values, template parameters, and prerequisites for calling new functions.
|
||||
- [ ] Pointer arguments and return values must specify whether ownership is being transferred or lent with the call.
|
||||
@@ -675,7 +681,7 @@ MFEM uses a `master`/`next`-branch workflow as described below:
|
||||
- [ ] Update URL shortlinks:
|
||||
- [ ] Create a shortlink at [http://bit.ly/](http://bit.ly/) for the release tarball, e.g. https://mfem.github.io/releases/mfem-3.1.tgz.
|
||||
- [ ] (LLNL only) Add and commit the new shortlink in the `links` and `links-mfem` files of the internal `mfem/downloads` repo.
|
||||
- [ ] Add the new shortlinks to the MFEM packages in `spack`, `homebrew/science`, `VisIt`, etc.
|
||||
- [ ] Add the new shortlinks to the MFEM package in `spack`.
|
||||
- [ ] Update website in `mfem/web` repo:
|
||||
- Update version and shortlinks in `src/index.md` and `src/download.md`.
|
||||
- Use [cloc-1.62.pl](http://cloc.sourceforge.net/) and `ls -lh` to estimate the SLOC and the tarball size in `src/download.md`.
|
||||
@@ -727,22 +733,24 @@ commit or push, see the [README](config/githooks/README.md) in the `config/githo
|
||||
directory.
|
||||
|
||||
|
||||
### Linux and Mac smoke tests
|
||||
### GitHub Actions smoke tests
|
||||
|
||||
We use GitHub Actions to drive the default tests on the `master` and `next`
|
||||
branches. See the `.github/workflows` files and the logs at
|
||||
[https://github.com/mfem/mfem/actions](https://github.com/mfem/mfem/actions).
|
||||
|
||||
Testing using GitHub Actions should be kept lightweight, as there is a time
|
||||
constraint on jobs. Two virtual machines are configured - Mac (OS X) and Linux.
|
||||
GitHub Actions testing should be kept lightweight, as there is a time
|
||||
constraint on jobs. The current workflows cover Linux, macOS, and Windows
|
||||
configurations.
|
||||
|
||||
- Tests on the `master` branch are triggered whenever a PR is issued on this branch.
|
||||
- Tests on the `next` branch are currently scheduled to run each night.
|
||||
|
||||
### Additional Windows smoke test
|
||||
|
||||
### Windows smoke test
|
||||
We use Appveyor to test building with the MS Visual C++ compiler in a Windows
|
||||
environment, as well as to test the CMake build. See the `.appveyor` file and the
|
||||
build logs at
|
||||
We also use Appveyor to test building with the MS Visual C++ compiler in a Windows
|
||||
environment, as well as to test the CMake build. See the `.appveyor.yml` file
|
||||
and the build logs at
|
||||
[https://ci.appveyor.com/project/mfem/mfem](https://ci.appveyor.com/project/mfem/mfem).
|
||||
|
||||
CMake is used to generate the MSVC Project files and drive the build. A release
|
||||
|
||||
@@ -38,14 +38,13 @@ the option MFEM_USE_METIS.
|
||||
MFEM also includes support for devices such as GPUs, and programming models such
|
||||
as CUDA, HIP, OCCA, OpenMP and RAJA.
|
||||
|
||||
- Starting with version 4.0, MFEM requires a C++11 compiler. We recommend using
|
||||
a newer compiler, e.g. GCC version 4.9 or higher.
|
||||
- Starting with version 4.9, MFEM requires a C++17 compiler.
|
||||
|
||||
- CUDA support requires an NVIDIA GPU and an installation of the CUDA Toolkit
|
||||
https://developer.nvidia.com/cuda-toolkit
|
||||
|
||||
- HIP support requires an AMD GPU and an installation of the ROCm software stack
|
||||
https://rocmdocs.amd.com
|
||||
https://rocm.docs.amd.com
|
||||
|
||||
- OCCA support requires the OCCA library
|
||||
https://libocca.org
|
||||
@@ -83,9 +82,9 @@ Serial build:
|
||||
Parallel build:
|
||||
(download hypre and METIS 4 from above URLs)
|
||||
(build METIS 4 in ../metis-4.0 relative to mfem/)
|
||||
(for METIS 5, see https://mfem.org/building/#parallel-build-using-metis-5)
|
||||
(build hypre in ../hypre relative to mfem/)
|
||||
make parallel -j 4
|
||||
(For METIS 5, see https://mfem.org/building/#parallel-build-using-metis-5)
|
||||
|
||||
CUDA build:
|
||||
make cuda -j 4
|
||||
@@ -115,14 +114,14 @@ Serial build:
|
||||
Parallel build:
|
||||
(download hypre and METIS 4 from above URLs)
|
||||
(build METIS 4 in ../metis-4.0 relative to mfem/)
|
||||
(for METIS 5, see https://mfem.org/building/#parallel-build-using-metis-5)
|
||||
(build hypre in ../hypre relative to mfem/)
|
||||
mkdir <mfem-build-dir> ; cd <mfem-build-dir>
|
||||
cmake <mfem-source-dir> -DMFEM_USE_MPI=YES
|
||||
make -j 4
|
||||
(For METIS 5, see https://mfem.org/building/#parallel-build-using-metis-5)
|
||||
|
||||
Parallel build with fetching of hypre and METIS:
|
||||
mkdir <mfem-buil-dir> ; cd <mfem-build-dir>
|
||||
mkdir <mfem-build-dir> ; cd <mfem-build-dir>
|
||||
cmake <mfem-source-dir> -DMFEM_USE_MPI=YES -DMFEM_FETCH_TPLS=YES
|
||||
make -j 4
|
||||
|
||||
@@ -134,7 +133,8 @@ CUDA build:
|
||||
|
||||
HIP build:
|
||||
mkdir <mfem-build-dir> ; cd <mfem-build-dir>
|
||||
cmake <mfem-source-dir> -DMFEM_USE_HIP=YES -DHIP_ARCH=gfx942 -DCMAKE_CXX_COMPILER=amdclang++ -DCMAKE_HIP_COMPILER=amdclang++
|
||||
cmake <mfem-source-dir> -DMFEM_USE_HIP=YES -DHIP_ARCH=gfx942 \
|
||||
-DCMAKE_CXX_COMPILER=amdclang++ -DCMAKE_HIP_COMPILER=amdclang++
|
||||
make -j 4
|
||||
|
||||
Example codes (serial/parallel, depending on the build):
|
||||
@@ -269,6 +269,7 @@ Compilers:
|
||||
CXX - C++ compiler, serial build
|
||||
MPICXX - MPI C++ compiler, parallel build
|
||||
CUDA_CXX - The CUDA compiler, 'nvcc' or 'clang++'
|
||||
HIP_CXX - The HIP compiler, e.g. 'hipcc'
|
||||
|
||||
Compiler options:
|
||||
OPTIM_FLAGS - Options for optimized build
|
||||
@@ -395,6 +396,11 @@ MFEM_USE_STRUMPACK = YES/NO
|
||||
classes. When enabled, this option uses the STRUMPACK_* library options, see
|
||||
below.
|
||||
|
||||
MFEM_USE_CUDSS = YES/NO
|
||||
Enable MFEM functionality based on the cuDSS library. When using cuDSS, CUDA
|
||||
support must be also enabled in MFEM, i.e. MFEM_USE_CUDA=YES must be set.
|
||||
When enabled, this option uses the CUDSS_* library options, see below.
|
||||
|
||||
MFEM_USE_GINKGO = YES/NO
|
||||
Enable MFEM functionality based on the Ginkgo library, which provides
|
||||
iterative linear solvers and preconditioners with OpenMP, CUDA backends, see
|
||||
@@ -554,13 +560,13 @@ MFEM_USE_RAJA = YES/NO
|
||||
MFEM_USE_OCCA = YES/NO
|
||||
Enables support for the OCCA library in MFEM. OCCA is an open-source library
|
||||
which aims to make it easy to program different types of devices (e.g. CPU,
|
||||
GPU, FPGA) by providing an unified API for interacting with JIT-compiled
|
||||
GPU, FPGA) by providing a unified API for interacting with JIT-compiled
|
||||
backends. In order to use the OCCA CUDA backend, CUDA support must be enabled
|
||||
in MFEM as well, i.e. MFEM_USE_CUDA=YES must be set.
|
||||
|
||||
MFEM_USE_GSLIB = YES/NO
|
||||
Enables MFEM functionality based on the GSLIB library, and specifically its
|
||||
FindPoints component, which provides a robust algorithms to evaluate finite
|
||||
FindPoints component, which provides robust algorithms to evaluate finite
|
||||
element functions in a collection of points in physical space. When enabled,
|
||||
the user can use the GSLIB-FindPoints methods as shown in miniapps/gslib.
|
||||
|
||||
@@ -719,9 +725,18 @@ The specific libraries and their options are:
|
||||
Options: STRUMPACK_OPT, STRUMPACK_LIB.
|
||||
Versions: STRUMPACK >= 3.0.0.
|
||||
|
||||
- Ginkgo (optional), used when MFEM_USE_GINKGO = YES. Note that Ginkgo needs a
|
||||
C++ compiler that supports the C++-17 standard. For additional requirements
|
||||
and dependencies of specific modules, see the Ginkgo webpage below.
|
||||
- CUDSS (optional), used when MFEM_USE_CUDSS = YES. Note that CUDSS requires
|
||||
CUDA 12.x toolkit and the cuDSS libraries. The supported communication backend
|
||||
is OpenMPI 4.x (default), and OpenMPI 4.x or a later version must be pre-built.
|
||||
The source files in the cuDSS tarball provide guidance for developing custom
|
||||
MPI implementations.
|
||||
URL: https://developer.nvidia.com/cudss
|
||||
https://docs.nvidia.com/cuda/cudss/advanced_features.html#communication-layer-library-in-cudss
|
||||
Options: CUDSS_OPT, CUDSS_LIB.
|
||||
Versions: cuDSS >= 0.6.0.
|
||||
|
||||
- Ginkgo (optional), used when MFEM_USE_GINKGO = YES. Ginkgo may have additional
|
||||
requirements and module-specific dependencies; see the webpage below.
|
||||
URL: https://ginkgo-project.github.io
|
||||
Options: GINKGO_OPT, GINKGO_LIB, GINKGO_DIR, GINKGO_BUILD_TYPE (Release or
|
||||
Debug).
|
||||
@@ -793,7 +808,7 @@ The specific libraries and their options are:
|
||||
Options: CONDUIT_OPT, CONDUIT_LIB.
|
||||
Versions: Conduit >= 0.3.1.
|
||||
|
||||
- ADIOS2 (optional) used when MFEM_USE_ADIOS2 = YES.
|
||||
- ADIOS2 (optional), used when MFEM_USE_ADIOS2 = YES.
|
||||
URL: https://adios2.readthedocs.io/
|
||||
Versions: ADIOS >= 2.5.0.
|
||||
|
||||
@@ -869,7 +884,7 @@ The specific libraries and their options are:
|
||||
Options: RAJA_DIR, RAJA_OPT, RAJA_LIB.
|
||||
Versions: RAJA >= 2022.10.3.
|
||||
|
||||
- Moonolith (optional), use when MFEM_USE_MOONOLITH = YES.
|
||||
- Moonolith (optional), used when MFEM_USE_MOONOLITH = YES.
|
||||
URL: https://bitbucket.org/zulianp/par_moonolith
|
||||
Options: MOONOLITH_DIR
|
||||
Versions: MOONOLITH >= 1.1.0.
|
||||
@@ -957,7 +972,7 @@ CMAKE_BUILD_TYPE which can be set to standard values like "Debug", and "Release"
|
||||
To use a specific generator use the "-G <generator>" option of cmake:
|
||||
|
||||
cmake <mfem-source-dir> -G "Xcode"
|
||||
cmake <mfem-source-dir> -G "Visual Studio 12 2013"
|
||||
cmake <mfem-source-dir> -G "Visual Studio 17 2022"
|
||||
cmake <mfem-source-dir> -G "MinGW Makefiles"
|
||||
|
||||
With CMake it is possible to build MFEM as a shared library using the standard
|
||||
@@ -1202,7 +1217,7 @@ larger problems, there are two options:
|
||||
Specific options for HIP
|
||||
========================
|
||||
MFEM expects the `ROCM_PATH` environment variable to be set to the path of the
|
||||
ROCM install, as well as having `$ROCM_PATH/bin` in `PATH`.
|
||||
ROCm install, as well as having `$ROCM_PATH/bin` in `PATH`.
|
||||
|
||||
Specific options for RAJA+HIP+MPI
|
||||
=================================
|
||||
|
||||
@@ -28,6 +28,7 @@ license files. These software products and their licenses are as follows:
|
||||
* AmgXWrapper (linalg/amgxsolver.{hpp,cpp}) -- MIT license
|
||||
* Catch++ (tests/unit/catch.hpp) -- Boost 1.0 license
|
||||
* Gecko (general/gecko.{cpp,hpp}) -- BSD 3-clause license
|
||||
* gslib (fem/gslib.{cpp,hpp}, mesh/bb_grid_map.{cpp,hpp}) -- BSD 3-clause license
|
||||
* Picojson (fem/picojson.h) -- Custom 2-clause license
|
||||
* TinyXML2 (general/tinyxml2.{cpp,h}) -- zlib license
|
||||
* Zstr (general/zstr.hpp) -- MIT license
|
||||
|
||||
@@ -35,6 +35,7 @@ set(MFEM_USE_SUITESPARSE @MFEM_USE_SUITESPARSE@)
|
||||
set(MFEM_USE_SUPERLU @MFEM_USE_SUPERLU@)
|
||||
set(MFEM_USE_MUMPS @MFEM_USE_MUMPS@)
|
||||
set(MFEM_USE_STRUMPACK @MFEM_USE_STRUMPACK@)
|
||||
set(MFEM_USE_CUDSS @MFEM_USE_CUDSS@)
|
||||
set(MFEM_USE_GINKGO @MFEM_USE_GINKGO@)
|
||||
set(MFEM_USE_AMGX @MFEM_USE_AMGX@)
|
||||
set(MFEM_USE_MAGMA @MFEM_USE_MAGMA@)
|
||||
@@ -109,6 +110,10 @@ if (MFEM_USE_RAJA)
|
||||
find_dependency(RAJA)
|
||||
endif()
|
||||
|
||||
if (MFEM_USE_CUDSS)
|
||||
find_dependency(cudss)
|
||||
endif (MFEM_USE_CUDSS)
|
||||
|
||||
if (MFEM_USE_UMPIRE)
|
||||
find_dependency(umpire)
|
||||
endif()
|
||||
|
||||
@@ -108,6 +108,15 @@
|
||||
// Enable MFEM functionality based on the STRUMPACK library.
|
||||
#cmakedefine MFEM_USE_STRUMPACK
|
||||
|
||||
// Enable MFEM functionality based on the cuDSS library.
|
||||
#cmakedefine MFEM_USE_CUDSS
|
||||
|
||||
// CUDSS communication layer library path
|
||||
#cmakedefine MFEM_CUDSS_COMM_LIB "@MFEM_CUDSS_COMM_LIB@"
|
||||
|
||||
// CUDSS threading layer library path
|
||||
#cmakedefine MFEM_CUDSS_THREADING_LIB "@MFEM_CUDSS_THREADING_LIB@"
|
||||
|
||||
// Enable functionality based on the Ginkgo library.
|
||||
#cmakedefine MFEM_USE_GINKGO
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
if (NOT cudss_DIR AND CUDSS_DIR)
|
||||
set(cudss_DIR ${CUDSS_DIR}/lib/cmake/cudss)
|
||||
endif()
|
||||
message(STATUS "Looking for CUDSS ...")
|
||||
message(STATUS " in CUDSS_DIR = ${CUDSS_DIR}")
|
||||
message(STATUS " cudss_DIR = ${cudss_DIR}")
|
||||
find_package(cudss)
|
||||
set(CUDSS_FOUND ${cudss_FOUND})
|
||||
set(CUDSS_LIBRARIES "cudss")
|
||||
if (CUDSS_FOUND)
|
||||
message(STATUS
|
||||
"Found CUDSS target: ${CUDSS_LIBRARIES} (version: ${cudss_VERSION})")
|
||||
else()
|
||||
set(msg STATUS)
|
||||
if (CUDSS_FIND_REQUIRED)
|
||||
set(msg FATAL_ERROR)
|
||||
endif()
|
||||
message(${msg}
|
||||
"CUDSS not found. Please set CUDSS_DIR to the install prefix.")
|
||||
endif()
|
||||
|
||||
if(CUDSS_FOUND AND TARGET cudss)
|
||||
get_target_property(CUDSS_LIBRARY_LOCATION cudss IMPORTED_LOCATION)
|
||||
if(NOT CUDSS_LIBRARY_LOCATION)
|
||||
get_target_property(CUDSS_LIBRARY_LOCATION cudss IMPORTED_LOCATION_RELEASE)
|
||||
endif()
|
||||
if(CUDSS_LIBRARY_LOCATION)
|
||||
get_filename_component(CUDSS_LIBRARY_DIR "${CUDSS_LIBRARY_LOCATION}" DIRECTORY)
|
||||
else()
|
||||
message(WARNING "Could not determine the location of the cuDSS library.")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "cuDSS target not available; cannot determine library directory.")
|
||||
endif()
|
||||
|
||||
# Set the full name of the cuDSS threading library if OpenMP is enabled.
|
||||
# The threading layer library (libcudss_mtlayer_gomp.so) is located under the
|
||||
# cuDSS library directory by default.
|
||||
if (MFEM_USE_OPENMP)
|
||||
find_file(
|
||||
CUDSS_THREADING_LIB
|
||||
NAMES libcudss_mtlayer_gomp.so
|
||||
PATHS ${CUDSS_LIBRARY_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT DEFINED MFEM_CUDSS_THREADING_LIB AND CUDSS_THREADING_LIB)
|
||||
set(MFEM_CUDSS_THREADING_LIB "${CUDSS_THREADING_LIB}")
|
||||
endif()
|
||||
message(STATUS "CUDSS threading layer library: ${MFEM_CUDSS_THREADING_LIB}")
|
||||
endif()
|
||||
|
||||
# Set the full name of the cuDSS communication library if MFEM use OpenMPI.
|
||||
# The communication layer library (libcudss_commlayer_mpi.so) is located under the
|
||||
# cuDSS library directory by default.
|
||||
# The communication layer library is used pre-built communication layers for OpenMPI
|
||||
# by default.
|
||||
if (MFEM_USE_MPI)
|
||||
find_file(
|
||||
CUDSS_COMM_LIB
|
||||
NAMES libcudss_commlayer_openmpi.so
|
||||
PATHS ${CUDSS_LIBRARY_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT DEFINED MFEM_CUDSS_COMM_LIB AND CUDSS_COMM_LIB)
|
||||
set(MFEM_CUDSS_COMM_LIB "${CUDSS_COMM_LIB}")
|
||||
endif()
|
||||
message(STATUS "CUDSS communication layer library: ${MFEM_CUDSS_COMM_LIB}")
|
||||
endif()
|
||||
@@ -157,4 +157,10 @@ constexpr real_t operator""_r(unsigned long long v)
|
||||
#endif
|
||||
#endif // MFEM_USE_MPI not defined
|
||||
|
||||
#ifndef MFEM_USE_CUDA
|
||||
#ifdef MFEM_USE_CUDSS
|
||||
#error Building with cuDSS (MFEM_USE_CUDSS=YES) requires CUDA (MFEM_USE_CUDA=YES)
|
||||
#endif
|
||||
#endif // MFEM_USE_CUDSS not defined
|
||||
|
||||
#endif // MFEM_CONFIG_HPP
|
||||
|
||||
@@ -108,6 +108,15 @@
|
||||
// Enable MFEM functionality based on the STRUMPACK library.
|
||||
// #define MFEM_USE_STRUMPACK
|
||||
|
||||
// Enable MFEM functionality based on the cuDSS library.
|
||||
// #define MFEM_USE_CUDSS
|
||||
|
||||
// CUDSS communication layer library path
|
||||
// #define MFEM_CUDSS_COMM_LIB "@MFEM_CUDSS_COMM_LIB@"
|
||||
|
||||
// CUDSS threading layer library path
|
||||
// #define MFEM_CUDSS_THREADING_LIB "@MFEM_CUDSS_THREADING_LIB@"
|
||||
|
||||
// Enable MFEM features based on the Ginkgo library.
|
||||
// #define MFEM_USE_GINKGO
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ MFEM_USE_SUPERLU = @MFEM_USE_SUPERLU@
|
||||
MFEM_USE_SUPERLU5 = @MFEM_USE_SUPERLU5@
|
||||
MFEM_USE_MUMPS = @MFEM_USE_MUMPS@
|
||||
MFEM_USE_STRUMPACK = @MFEM_USE_STRUMPACK@
|
||||
MFEM_USE_CUDSS = @MFEM_USE_CUDSS@
|
||||
MFEM_CUDSS_COMM_LIB = @MFEM_CUDSS_COMM_LIB@
|
||||
MFEM_CUDSS_THREADING_LIB = @MFEM_CUDSS_THREADING_LIB@
|
||||
MFEM_USE_GINKGO = @MFEM_USE_GINKGO@
|
||||
MFEM_USE_AMGX = @MFEM_USE_AMGX@
|
||||
MFEM_USE_MAGMA = @MFEM_USE_MAGMA@
|
||||
|
||||
@@ -38,6 +38,7 @@ option(MFEM_USE_SUPERLU "Enable SuperLU_DIST usage" OFF)
|
||||
option(MFEM_USE_SUPERLU5 "Use the old SuperLU_DIST 5.1 version" OFF)
|
||||
option(MFEM_USE_MUMPS "Enable MUMPS usage" OFF)
|
||||
option(MFEM_USE_STRUMPACK "Enable STRUMPACK usage" OFF)
|
||||
option(MFEM_USE_CUDSS "Enable cuDSS usage" OFF)
|
||||
option(MFEM_USE_GINKGO "Enable Ginkgo usage" OFF)
|
||||
option(MFEM_USE_AMGX "Enable AmgX usage" OFF)
|
||||
option(MFEM_USE_MAGMA "Enable MAGMA usage" OFF)
|
||||
|
||||
+15
-1
@@ -153,6 +153,7 @@ MFEM_USE_SUPERLU = NO
|
||||
MFEM_USE_SUPERLU5 = NO
|
||||
MFEM_USE_MUMPS = NO
|
||||
MFEM_USE_STRUMPACK = NO
|
||||
MFEM_USE_CUDSS = NO
|
||||
MFEM_USE_GINKGO = NO
|
||||
MFEM_USE_AMGX = NO
|
||||
MFEM_USE_MAGMA = NO
|
||||
@@ -368,6 +369,19 @@ STRUMPACK_OPT = -I$(STRUMPACK_DIR)/include $(SCOTCH_OPT)
|
||||
STRUMPACK_LIB = -L$(STRUMPACK_DIR)/lib -lstrumpack $(MPI_FORTRAN_LIB)\
|
||||
$(SCOTCH_LIB) $(SCALAPACK_LIB)
|
||||
|
||||
# CUDSS library configuration
|
||||
CUDSS_DIR = @MFEM_DIR@/../cudss
|
||||
CUDSS_INCLUDE_DIR = $(CUDSS_DIR)/include
|
||||
CUDSS_LIBRARY_DIR = $(CUDSS_DIR)/lib
|
||||
CUDSS_OPT = -I$(CUDSS_INCLUDE_DIR)
|
||||
CUDSS_LIB = \
|
||||
$(XLINKER)-rpath,$(CUDSS_LIBRARY_DIR) -L$(CUDSS_LIBRARY_DIR) -lcudss
|
||||
# The cuDSS communication and threading libraries.
|
||||
MFEM_CUDSS_COMM_LIB = $(abspath $(wildcard $(or $(CUDSS_COMM_LIB),\
|
||||
$(subst @MFEM_DIR@,$(MFEM_DIR), $(CUDSS_LIBRARY_DIR)/libcudss_commlayer_openmpi.so))))
|
||||
MFEM_CUDSS_THREADING_LIB = $(abspath $(wildcard $(or $(CUDSS_THREADING_LIB),\
|
||||
$(subst @MFEM_DIR@,$(MFEM_DIR),$(CUDSS_LIBRARY_DIR)/libcudss_mtlayer_gomp.so))))
|
||||
|
||||
# Ginkgo library configuration
|
||||
GINKGO_DIR = @MFEM_DIR@/../ginkgo/install
|
||||
GINKGO_SEARCH_DIR = $(subst @MFEM_DIR@,$(MFEM_DIR),$(GINKGO_DIR))
|
||||
@@ -621,7 +635,7 @@ PARELAG_LIB = -L$(PARELAG_DIR)/build/src -lParELAG
|
||||
AXOM_DIR = @MFEM_DIR@/../axom
|
||||
TRIBOL_DIR = @MFEM_DIR@/../tribol
|
||||
TRIBOL_OPT = -I$(TRIBOL_DIR)/include -I$(AXOM_DIR)/include
|
||||
TRIBOL_LIB = -L$(TRIBOL_DIR)/lib -ltribol -lredecomp -L$(AXOM_DIR)/lib -laxom_mint\
|
||||
TRIBOL_LIB = -L$(TRIBOL_DIR)/lib -ltribol -ltribol_shared -lredecomp -L$(AXOM_DIR)/lib -laxom_mint\
|
||||
-laxom_slam -laxom_slic -laxom_core
|
||||
|
||||
# Enzyme configuration
|
||||
|
||||
@@ -215,7 +215,7 @@ if (MFEM_ENABLE_TESTING)
|
||||
add_test(NAME ex1p_ceed_np=${MFEM_MPI_NP}
|
||||
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP}
|
||||
${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:ex1p> "-no-vis" "-d ceed-cpu" "-pa" "-a"
|
||||
$<TARGET_FILE:ex1p> "-no-vis" "-d" "ceed-cpu" "-pa" "-a"
|
||||
${MPIEXEC_POSTFLAGS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -64,7 +64,7 @@ PARALLEL_NAME := Parallel AMGX example
|
||||
$(MFEM_LIB_FILE):
|
||||
$(error The MFEM library is not build)
|
||||
|
||||
clean: clean-build
|
||||
clean: clean-build clean-exec
|
||||
|
||||
clean-build:
|
||||
rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES)
|
||||
|
||||
@@ -64,12 +64,12 @@ ex1p-test-par: ex1p
|
||||
$(MFEM_LIB_FILE):
|
||||
$(error The MFEM library is not built)
|
||||
|
||||
clean: clean-build clean-exec $(SUBDIRS_CLEAN)
|
||||
clean: clean-build clean-exec
|
||||
|
||||
clean-build:
|
||||
rm -f *.o *~ $(SEQ_EXAMPLES) $(PAR_EXAMPLES)
|
||||
rm -rf *.dSYM *.TVD.*breakpoints
|
||||
|
||||
clean-exec:
|
||||
@rm -f refined.mesh displaced.mesh mesh.* ex5.mesh
|
||||
@rm -f sphere_refined.* sol.* sol_u.* sol_p.* sol_r.* sol_i.*
|
||||
@rm -f refined.mesh mesh.*
|
||||
@rm -f sol.*
|
||||
|
||||
+36
-23
@@ -50,6 +50,10 @@
|
||||
// ex1 -m ../data/beam-tet.mesh -pa -d ceed-cpu
|
||||
// ex1 -m ../data/beam-tet.mesh -pa -d ceed-cuda:/gpu/cuda/ref
|
||||
//
|
||||
// Device simplices sample runs:
|
||||
// ex1 -pa -d gpu -m ../data/inline-tet.mesh
|
||||
// ex1 -pa -d gpu -m ../data/inline-tri.mesh
|
||||
//
|
||||
// Description: This example code demonstrates the use of MFEM to define a
|
||||
// simple finite element discretization of the Poisson problem
|
||||
// -Delta u = 1 with homogeneous Dirichlet boundary conditions.
|
||||
@@ -138,25 +142,25 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// 5. Define a finite element space on the mesh. Here we use continuous
|
||||
// Lagrange finite elements of the specified order. If order < 1, we
|
||||
// instead use an isoparametric/isogeometric space.
|
||||
// Lagrange finite elements of the specified order.
|
||||
// - If order < 1, we instead use an isoparametric/isogeometric space.
|
||||
// - If the mesh is simplicial and partial assembly is requested,
|
||||
// we use the positive basis, which supports device execution.
|
||||
FiniteElementCollection *fec;
|
||||
bool delete_fec;
|
||||
auto basis_type = (pa && mesh.IsSimplexMesh()) ?
|
||||
BasisType::Positive : BasisType::GaussLobatto;
|
||||
if (order > 0)
|
||||
{
|
||||
fec = new H1_FECollection(order, dim);
|
||||
delete_fec = true;
|
||||
fec = new H1_FECollection(order, dim, basis_type);
|
||||
}
|
||||
else if (mesh.GetNodes())
|
||||
{
|
||||
fec = mesh.GetNodes()->OwnFEC();
|
||||
delete_fec = false;
|
||||
cout << "Using isoparametric FEs: " << fec->Name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
fec = new H1_FECollection(order = 1, dim);
|
||||
delete_fec = true;
|
||||
fec = new H1_FECollection(order = 1, dim, basis_type);
|
||||
}
|
||||
FiniteElementSpace fespace(&mesh, fec);
|
||||
cout << "Number of finite element unknowns: "
|
||||
@@ -224,17 +228,29 @@ int main(int argc, char *argv[])
|
||||
// 11. Solve the linear system A X = B.
|
||||
if (!pa)
|
||||
{
|
||||
#ifndef MFEM_USE_SUITESPARSE
|
||||
// Use a simple symmetric Gauss-Seidel preconditioner with PCG.
|
||||
GSSmoother M((SparseMatrix&)(*A));
|
||||
PCG(*A, M, B, X, 1, 200, 1e-12, 0.0);
|
||||
#else
|
||||
// If MFEM was compiled with SuiteSparse, use UMFPACK to solve the system.
|
||||
UMFPackSolver umf_solver;
|
||||
umf_solver.Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
|
||||
umf_solver.SetOperator(*A);
|
||||
umf_solver.Mult(B, X);
|
||||
#ifdef MFEM_USE_CUDSS
|
||||
if (Device::Allows(Backend::CUDA_MASK))
|
||||
{
|
||||
// Use cuDSS to solve the system.
|
||||
CuDSSSolver cudss_solver;
|
||||
cudss_solver.SetOperator(*A);
|
||||
cudss_solver.Mult(B, X);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifndef MFEM_USE_SUITESPARSE
|
||||
// Use a simple symmetric Gauss-Seidel preconditioner with PCG.
|
||||
GSSmoother M((SparseMatrix&)(*A));
|
||||
PCG(*A, M, B, X, 1, 200, 1e-12, 0.0);
|
||||
#else
|
||||
// If MFEM was compiled with SuiteSparse, use UMFPACK to solve the system.
|
||||
UMFPackSolver umf_solver;
|
||||
umf_solver.Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
|
||||
umf_solver.SetOperator(*A);
|
||||
umf_solver.Mult(B, X);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -273,17 +289,14 @@ int main(int argc, char *argv[])
|
||||
if (visualization)
|
||||
{
|
||||
char vishost[] = "localhost";
|
||||
int visport = 19916;
|
||||
int visport = 19916;
|
||||
socketstream sol_sock(vishost, visport);
|
||||
sol_sock.precision(8);
|
||||
sol_sock << "solution\n" << mesh << x << flush;
|
||||
}
|
||||
|
||||
// 15. Free the used memory.
|
||||
if (delete_fec)
|
||||
{
|
||||
delete fec;
|
||||
}
|
||||
if (order > 0) { delete fec; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+61
-35
@@ -42,7 +42,11 @@
|
||||
// mpirun -np 4 ex1p -pa -d ceed-cuda:/gpu/cuda/shared
|
||||
// mpirun -np 4 ex1p -pa -d ceed-cuda:/gpu/cuda/shared -m ../data/square-mixed.mesh
|
||||
// mpirun -np 4 ex1p -pa -d ceed-cuda:/gpu/cuda/shared -m ../data/fichera-mixed.mesh
|
||||
// mpirun -np 4 ex1p -m ../data/beam-tet.mesh -pa -d ceed-cpu
|
||||
// mpirun -np 4 ex1p -pa -d ceed-cpu -m ../data/beam-tet.mesh
|
||||
//
|
||||
// Device simplices sample runs:
|
||||
// mpirun -np 4 ex1p -pa -d gpu -m ../data/inline-tet.mesh
|
||||
// mpirun -np 4 ex1p -pa -d gpu -m ../data/inline-tri.mesh
|
||||
//
|
||||
// Description: This example code demonstrates the use of MFEM to define a
|
||||
// simple finite element discretization of the Poisson problem
|
||||
@@ -83,6 +87,9 @@ int main(int argc, char *argv[])
|
||||
const char *device_config = "cpu";
|
||||
bool visualization = true;
|
||||
bool algebraic_ceed = false;
|
||||
#ifdef MFEM_USE_CUDSS
|
||||
bool cudss_solver = false;
|
||||
#endif
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -102,6 +109,10 @@ int main(int argc, char *argv[])
|
||||
args.AddOption(&algebraic_ceed, "-a", "--algebraic",
|
||||
"-no-a", "--no-algebraic",
|
||||
"Use algebraic Ceed solver");
|
||||
#endif
|
||||
#ifdef MFEM_USE_CUDSS
|
||||
args.AddOption(&cudss_solver, "-cudss", "--cudss-solver", "-no-cudss",
|
||||
"--no-cudss-solver", "Use the cuDSS Solver.");
|
||||
#endif
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
"--no-visualization",
|
||||
@@ -158,19 +169,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// 7. Define a parallel finite element space on the parallel mesh. Here we
|
||||
// use continuous Lagrange finite elements of the specified order. If
|
||||
// order < 1, we instead use an isoparametric/isogeometric space.
|
||||
// use continuous Lagrange finite elements of the specified order.
|
||||
// - If order < 1, we instead use an isoparametric/isogeometric space.
|
||||
// - If the mesh is simplicial and partial assembly is requested,
|
||||
// we use the positive basis, which supports device execution.
|
||||
FiniteElementCollection *fec;
|
||||
bool delete_fec;
|
||||
auto basis_type = (pa && pmesh.IsSimplexMesh()) ?
|
||||
BasisType::Positive : BasisType::GaussLobatto;
|
||||
if (order > 0)
|
||||
{
|
||||
fec = new H1_FECollection(order, dim);
|
||||
delete_fec = true;
|
||||
fec = new H1_FECollection(order, dim, basis_type);
|
||||
}
|
||||
else if (pmesh.GetNodes())
|
||||
{
|
||||
fec = pmesh.GetNodes()->OwnFEC();
|
||||
delete_fec = false;
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "Using isoparametric FEs: " << fec->Name() << endl;
|
||||
@@ -178,8 +190,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
fec = new H1_FECollection(order = 1, dim);
|
||||
delete_fec = true;
|
||||
fec = new H1_FECollection(order = 1, dim, basis_type);
|
||||
}
|
||||
ParFiniteElementSpace fespace(&pmesh, fec);
|
||||
HYPRE_BigInt size = fespace.GlobalTrueVSize();
|
||||
@@ -248,33 +259,51 @@ int main(int argc, char *argv[])
|
||||
// 13. Solve the linear system A X = B.
|
||||
// * With full assembly, use the BoomerAMG preconditioner from hypre.
|
||||
// * With partial assembly, use Jacobi smoothing, for now.
|
||||
Solver *prec = NULL;
|
||||
if (pa)
|
||||
#ifdef MFEM_USE_CUDSS
|
||||
if (!pa && (Device::Allows(Backend::CUDA_MASK) && cudss_solver))
|
||||
{
|
||||
if (UsesTensorBasis(fespace))
|
||||
{
|
||||
if (algebraic_ceed)
|
||||
{
|
||||
prec = new ceed::AlgebraicSolver(a, ess_tdof_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
prec = new OperatorJacobiSmoother(a, ess_tdof_list);
|
||||
}
|
||||
}
|
||||
// Solve using a direct solver with cuDSS
|
||||
CuDSSSolver cudss_solver(MPI_COMM_WORLD);
|
||||
cudss_solver.SetMatrixSymType(
|
||||
CuDSSSolver::SYMMETRIC_POSITIVE_DEFINITE);
|
||||
cudss_solver.SetMatrixViewType(CuDSSSolver::UPPER);
|
||||
cudss_solver.SetOperator(*A);
|
||||
cudss_solver.Mult(B, X);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
prec = new HypreBoomerAMG;
|
||||
Solver *prec = NULL;
|
||||
if (pa)
|
||||
{
|
||||
if (UsesTensorBasis(fespace))
|
||||
{
|
||||
if (algebraic_ceed)
|
||||
{
|
||||
prec = new ceed::AlgebraicSolver(a, ess_tdof_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
prec = new OperatorJacobiSmoother(a, ess_tdof_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prec = new HypreBoomerAMG;
|
||||
}
|
||||
CGSolver cg(MPI_COMM_WORLD);
|
||||
cg.SetRelTol(1e-12);
|
||||
cg.SetMaxIter(2000);
|
||||
cg.SetPrintLevel(1);
|
||||
if (prec)
|
||||
{
|
||||
cg.SetPreconditioner(*prec);
|
||||
}
|
||||
cg.SetOperator(*A);
|
||||
cg.Mult(B, X);
|
||||
delete prec;
|
||||
}
|
||||
CGSolver cg(MPI_COMM_WORLD);
|
||||
cg.SetRelTol(1e-12);
|
||||
cg.SetMaxIter(2000);
|
||||
cg.SetPrintLevel(1);
|
||||
if (prec) { cg.SetPreconditioner(*prec); }
|
||||
cg.SetOperator(*A);
|
||||
cg.Mult(B, X);
|
||||
delete prec;
|
||||
|
||||
// 14. Recover the parallel grid function corresponding to X. This is the
|
||||
// local finite element solution on each processor.
|
||||
@@ -308,10 +337,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// 17. Free the used memory.
|
||||
if (delete_fec)
|
||||
{
|
||||
delete fec;
|
||||
}
|
||||
if (order > 0) { delete fec; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,15 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
if (amg_elast && !static_cond && reorder_space)
|
||||
{
|
||||
if (myid == 0)
|
||||
cerr << "\nThe AMG elasticity solver requires ordering byVDIM! "
|
||||
<< "Ignoring the specified option -nodes/--by-nodes.\n"
|
||||
<< endl;
|
||||
reorder_space = false;
|
||||
}
|
||||
|
||||
// 3. Enable hardware devices such as GPUs, and programming models such as
|
||||
// CUDA, OCCA, RAJA and OpenMP based on command line options.
|
||||
Device device(device_config);
|
||||
|
||||
@@ -76,4 +76,4 @@ clean-build:
|
||||
rm -rf *.dSYM *.TVD.*breakpoints
|
||||
|
||||
clean-exec:
|
||||
@rm -f refined.mesh sol.gf
|
||||
@rm -f refined.mesh sol.gf mesh.* sol.*
|
||||
|
||||
+5
-2
@@ -71,6 +71,7 @@ endif
|
||||
|
||||
SUBDIRS_ALL = $(addsuffix /all,$(SUBDIRS))
|
||||
SUBDIRS_TEST = $(addsuffix /test,$(SUBDIRS))
|
||||
SUBDIRS_TEST_NOCLEAN = $(addsuffix /test-noclean,$(SUBDIRS))
|
||||
SUBDIRS_CLEAN = $(addsuffix /clean,$(SUBDIRS))
|
||||
SUBDIRS_TPRINT = $(addsuffix /test-print,$(SUBDIRS))
|
||||
|
||||
@@ -87,8 +88,9 @@ SUBDIRS_TPRINT = $(addsuffix /test-print,$(SUBDIRS))
|
||||
|
||||
all: $(EXAMPLES) $(SUBDIRS_ALL)
|
||||
|
||||
.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT)
|
||||
$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_CLEAN):
|
||||
.PHONY: $(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) \
|
||||
$(SUBDIRS_CLEAN) $(SUBDIRS_TPRINT)
|
||||
$(SUBDIRS_ALL) $(SUBDIRS_TEST) $(SUBDIRS_TEST_NOCLEAN) $(SUBDIRS_CLEAN):
|
||||
$(MAKE) -C $(@D) $(@F)
|
||||
$(SUBDIRS_TPRINT):
|
||||
@$(MAKE) -C $(@D) $(@F)
|
||||
@@ -107,6 +109,7 @@ endif
|
||||
MFEM_TESTS = EXAMPLES
|
||||
include $(MFEM_TEST_MK)
|
||||
test: $(SUBDIRS_TEST)
|
||||
test-noclean: $(SUBDIRS_TEST_NOCLEAN)
|
||||
test-print: $(SUBDIRS_TPRINT)
|
||||
|
||||
# Testing: Parallel vs. serial runs
|
||||
|
||||
@@ -171,8 +171,12 @@ set(SRCS
|
||||
tmop_tools.cpp
|
||||
tmop_amr.cpp
|
||||
gslib.cpp
|
||||
gslib/findptsedge_local_2.cpp
|
||||
gslib/findptsedge_local_3.cpp
|
||||
gslib/findptssurf_local_3.cpp
|
||||
gslib/findpts_local_2.cpp
|
||||
gslib/findpts_local_3.cpp
|
||||
gslib/interpolate_local_1.cpp
|
||||
gslib/interpolate_local_2.cpp
|
||||
gslib/interpolate_local_3.cpp
|
||||
transfer.cpp
|
||||
@@ -191,12 +195,14 @@ set(HDRS
|
||||
integ/bilininteg_dgtrace_kernels.hpp
|
||||
integ/bilininteg_vecdiffusion_kernels.hpp
|
||||
integ/bilininteg_convection_kernels.hpp
|
||||
integ/bilininteg_diffusion_pa_simplices.hpp
|
||||
integ/bilininteg_diffusion_kernels.hpp
|
||||
integ/bilininteg_elasticity_kernels.hpp
|
||||
integ/bilininteg_hcurl_kernels.hpp
|
||||
integ/bilininteg_hdiv_kernels.hpp
|
||||
integ/bilininteg_hcurlhdiv_kernels.hpp
|
||||
integ/bilininteg_mass_kernels.hpp
|
||||
integ/bilininteg_mass_pa_simplices.hpp
|
||||
integ/bilininteg_vecdiffusion_pa.hpp
|
||||
integ/bilininteg_vecmass_pa.hpp
|
||||
coefficient.hpp
|
||||
|
||||
+22
-4
@@ -1345,7 +1345,8 @@ real_t DiffusionIntegrator::ComputeFluxEnergy
|
||||
}
|
||||
|
||||
const IntegrationRule &DiffusionIntegrator::GetRule(
|
||||
const FiniteElement &trial_fe, const FiniteElement &test_fe)
|
||||
const FiniteElement &trial_fe, const FiniteElement &test_fe,
|
||||
const bool stroud)
|
||||
{
|
||||
int order;
|
||||
if (trial_fe.Space() == FunctionSpace::Pk)
|
||||
@@ -1362,7 +1363,15 @@ const IntegrationRule &DiffusionIntegrator::GetRule(
|
||||
{
|
||||
return RefinedIntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
return IntRules.Get(trial_fe.GetGeomType(), order);
|
||||
|
||||
if (stroud)
|
||||
{
|
||||
return StroudIntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
else
|
||||
{
|
||||
return IntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
}
|
||||
|
||||
MassIntegrator::MassIntegrator(const IntegrationRule *ir)
|
||||
@@ -1449,7 +1458,8 @@ void MassIntegrator::AssembleElementMatrix2(
|
||||
|
||||
const IntegrationRule &MassIntegrator::GetRule(const FiniteElement &trial_fe,
|
||||
const FiniteElement &test_fe,
|
||||
const ElementTransformation &Trans)
|
||||
const ElementTransformation &Trans,
|
||||
const bool stroud)
|
||||
{
|
||||
// int order = trial_fe.GetOrder() + test_fe.GetOrder();
|
||||
const int order = trial_fe.GetOrder() + test_fe.GetOrder() + Trans.OrderW();
|
||||
@@ -1458,7 +1468,15 @@ const IntegrationRule &MassIntegrator::GetRule(const FiniteElement &trial_fe,
|
||||
{
|
||||
return RefinedIntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
return IntRules.Get(trial_fe.GetGeomType(), order);
|
||||
|
||||
if (stroud)
|
||||
{
|
||||
return StroudIntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
else
|
||||
{
|
||||
return IntRules.Get(trial_fe.GetGeomType(), order);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+40
-2
@@ -2184,11 +2184,22 @@ public:
|
||||
const Vector&, const Vector&,
|
||||
Vector&, const int, const int);
|
||||
|
||||
using ApplySimplexKernelType = void(*)(const int, const bool, const Array<int>&,
|
||||
const Array<int>&,
|
||||
const Array<int>&, const Array<int>&, const Array<int>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Vector&, const Vector&,
|
||||
Vector&, const int, const int);
|
||||
|
||||
using DiagonalKernelType = void(*)(const int, const bool, const Array<real_t>&,
|
||||
const Array<real_t>&, const Vector&, Vector&,
|
||||
const int, const int);
|
||||
|
||||
MFEM_REGISTER_KERNELS(ApplyPAKernels, ApplyKernelType, (int, int, int));
|
||||
MFEM_REGISTER_KERNELS(ApplySimplexPAKernels, ApplySimplexKernelType, (int, int,
|
||||
int));
|
||||
MFEM_REGISTER_KERNELS(DiagonalPAKernels, DiagonalKernelType, (int, int, int));
|
||||
struct Kernels { Kernels(); };
|
||||
|
||||
@@ -2341,7 +2352,8 @@ public:
|
||||
void AddMultPatchPA(const int patch, const Vector &x, Vector &y) const;
|
||||
|
||||
static const IntegrationRule &GetRule(const FiniteElement &trial_fe,
|
||||
const FiniteElement &test_fe);
|
||||
const FiniteElement &test_fe,
|
||||
const bool stroud = false);
|
||||
|
||||
bool SupportsCeed() const override { return DeviceCanUseCeed(); }
|
||||
|
||||
@@ -2352,6 +2364,13 @@ public:
|
||||
{
|
||||
ApplyPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
DiagonalPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
AddSimplexSpecialization<DIM,D1D,Q1D>();
|
||||
}
|
||||
|
||||
template <int DIM, int D1D, int Q1D>
|
||||
static void AddSimplexSpecialization()
|
||||
{
|
||||
ApplySimplexPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
}
|
||||
protected:
|
||||
const IntegrationRule* GetDefaultIntegrationRule(
|
||||
@@ -2388,11 +2407,22 @@ public:
|
||||
const Array<real_t>&, const Vector&,
|
||||
const Vector&, Vector&, const int, const int);
|
||||
|
||||
using ApplySimplexKernelType = void(*)(const int, const Array<int>&,
|
||||
const Array<int>&,
|
||||
const Array<int>&, const Array<int>&, const Array<int>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Array<real_t>&, const Array<real_t>&,
|
||||
const Vector&, const Vector&, Vector&,
|
||||
const int, const int);
|
||||
|
||||
using DiagonalKernelType = void(*)(const int, const Array<real_t>&,
|
||||
const Vector&, Vector&, const int,
|
||||
const int);
|
||||
|
||||
MFEM_REGISTER_KERNELS(ApplyPAKernels, ApplyKernelType, (int, int, int));
|
||||
MFEM_REGISTER_KERNELS(ApplySimplexPAKernels, ApplySimplexKernelType, (int, int,
|
||||
int));
|
||||
MFEM_REGISTER_KERNELS(DiagonalPAKernels, DiagonalKernelType, (int, int, int));
|
||||
struct Kernels { Kernels(); };
|
||||
|
||||
@@ -2441,7 +2471,8 @@ public:
|
||||
|
||||
static const IntegrationRule &GetRule(const FiniteElement &trial_fe,
|
||||
const FiniteElement &test_fe,
|
||||
const ElementTransformation &Trans);
|
||||
const ElementTransformation &Trans,
|
||||
const bool stroud = false);
|
||||
|
||||
bool SupportsCeed() const override { return DeviceCanUseCeed(); }
|
||||
|
||||
@@ -2452,6 +2483,13 @@ public:
|
||||
{
|
||||
ApplyPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
DiagonalPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
AddSimplexSpecialization<DIM,D1D,Q1D>();
|
||||
}
|
||||
|
||||
template <int DIM, int D1D, int Q1D>
|
||||
static void AddSimplexSpecialization()
|
||||
{
|
||||
ApplySimplexPAKernels::Specialization<DIM,D1D,Q1D>::Add();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
+13
-26
@@ -830,15 +830,9 @@ ParComplexGridFunction::ParComplexGridFunction(ParMesh *m, std::istream &input)
|
||||
int vsize = pfes->GetVSize();
|
||||
Vector::Load(input, 2*vsize);
|
||||
|
||||
real_t *data_ = const_cast<real_t*>(HostRead());
|
||||
for (int i = 0; i < vsize; i++)
|
||||
{
|
||||
if (pfes->GetDofSign(i) < 0)
|
||||
{
|
||||
data_[i] = -data_[i];
|
||||
data_[i+vsize] = -data_[i+vsize];
|
||||
}
|
||||
}
|
||||
real_t *h_data = HostReadWrite();
|
||||
pfes->ApplyDofSigns(h_data);
|
||||
pfes->ApplyDofSigns(h_data + vsize);
|
||||
|
||||
|
||||
// if the mesh is a legacy (v1.1) NC mesh, it has old vertex ordering
|
||||
@@ -1051,15 +1045,14 @@ void ParComplexGridFunction::Save(std::ostream &os) const
|
||||
os << '\n';
|
||||
|
||||
int vsize = pfes->GetVSize();
|
||||
real_t *data_ = const_cast<real_t*>(HostRead());
|
||||
for (int i = 0; i < vsize; i++)
|
||||
{
|
||||
if (pfes->GetDofSign(i) < 0)
|
||||
{
|
||||
data_[i] = -data_[i];
|
||||
data_[i+vsize] = -data_[i+vsize];
|
||||
}
|
||||
}
|
||||
// We use const_cast + HostRead (instead of HostReadWrite) because we only
|
||||
// need to change the host data temporarily and this way we do not invalidate
|
||||
// the data if it is on device. If we use HostReadWrite here, later calls to
|
||||
// Read or ReadWrite will need to copy the data from host to device. With the
|
||||
// approach used here, the host-to-device copy is avoided.
|
||||
real_t *h_data = const_cast<real_t*>(HostRead());
|
||||
pfes->ApplyDofSigns(h_data);
|
||||
pfes->ApplyDofSigns(h_data + vsize);
|
||||
|
||||
if (pfes->GetOrdering() == Ordering::byNODES)
|
||||
{
|
||||
@@ -1070,14 +1063,8 @@ void ParComplexGridFunction::Save(std::ostream &os) const
|
||||
Vector::Print(os, pfes->GetVDim());
|
||||
}
|
||||
|
||||
for (int i = 0; i < vsize; i++)
|
||||
{
|
||||
if (pfes->GetDofSign(i) < 0)
|
||||
{
|
||||
data_[i] = -data_[i];
|
||||
data_[i+vsize] = -data_[i+vsize];
|
||||
}
|
||||
}
|
||||
pfes->ApplyDofSigns(h_data);
|
||||
pfes->ApplyDofSigns(h_data + vsize);
|
||||
|
||||
os.flush();
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ void ConduitDataCollection::Save()
|
||||
n_mesh["fields"][name]);
|
||||
}
|
||||
|
||||
// TODO: in parallel, we need to call ParFiniteElementSpace::ApplyDofSigns
|
||||
// for all ParGridFunction objects before and after saving, see
|
||||
// ParGridFunction::Save.
|
||||
|
||||
// save mesh data
|
||||
SaveMeshAndFields(myid,
|
||||
n_mesh,
|
||||
|
||||
@@ -57,7 +57,7 @@ void DGMassApply(const int e,
|
||||
}
|
||||
else if (DIM == 3)
|
||||
{
|
||||
SmemPAMassApply3D_Element<TD1D,TQ1D,ACCUM>(e, NE, B, pa_data, x, y);
|
||||
SmemPAMassApply3D_Element<TD1D,TQ1D,NBZ,ACCUM>(e, NE, B, pa_data, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+42
-1
@@ -167,7 +167,15 @@ public:
|
||||
/** @brief Full multidimensional representation which does not use tensor
|
||||
product structure. The ordering of the degrees of freedom is the
|
||||
same as TENSOR, but the sizes of B and G are the same as FULL.*/
|
||||
LEXICOGRAPHIC_FULL
|
||||
LEXICOGRAPHIC_FULL,
|
||||
|
||||
/** @brief Ragged tensor product representation using 1D matrices/tensors
|
||||
with dimensions using 1D number of quadrature points and ragged tensor degrees of
|
||||
freedom. */
|
||||
/** Used only for partial assembly of the H1 positive basis. The
|
||||
size of B is d1d x qnpt x dim. Since different Gauss-Jacobi quadrature rules
|
||||
are employed in each dimension, we need to store dim arrays. */
|
||||
RAGGED_TENSOR
|
||||
};
|
||||
|
||||
/// Describes the contents of the #B, #Bt, #G, and #Gt arrays, see #Mode.
|
||||
@@ -228,6 +236,39 @@ public:
|
||||
const Array<DofToQuad*> &dof2quad_array,
|
||||
const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode);
|
||||
|
||||
virtual ~DofToQuad() = default;
|
||||
};
|
||||
|
||||
/** @brief Structure representing the matrices/tensors needed to evaluate (in
|
||||
reference space) the values, gradients, divergences, or curls of a positive
|
||||
FiniteElement on simplices at the quadrature points of Stroud conical quadrature. */
|
||||
class RaggedDofToQuad : public DofToQuad
|
||||
{
|
||||
public:
|
||||
/** @brief Special basis function structures for positive (Bernstein) basis with
|
||||
partial assembly. The storage layout of Ba1 is ndof x nqpt for scalar elements.
|
||||
The storage layout of Ba2 is ndof x ndof x nqpt. In particular, we have
|
||||
Ba2(iqpt, a1, a2) = B^{p-a1}_{a2}(x_{iqpt}). */
|
||||
Array<real_t> Ba1, Ba2, Ba3;
|
||||
Array<real_t> Ba1t, Ba2t, Ba3t;
|
||||
|
||||
/** @brief Special structures for gradients of positive basis with partial assembly.
|
||||
The gradient arrays exploit properties of the Bernstein basis which allow grad(B^p_alpha)
|
||||
to be expressed as the sum of products of B^{p-1}_alpha and the barycentric coordinates.
|
||||
Thus, Ga1 and Ga2 simply contain the ragged tensor product components of B^{p-1}_alpha */
|
||||
Array<real_t> Ga1, Ga2, Ga3;
|
||||
Array<real_t> Ga1t, Ga2t, Ga3t;
|
||||
|
||||
/** @brief Mapping from the Bernstein multi-index (a_1, ..., a_d) to the lexicographic
|
||||
dof index. */
|
||||
Array<int> lex_map;
|
||||
|
||||
Array<int> forward_map2d_diff, forward_map3d_diff;
|
||||
Array<int> inverse_map2d_diff, inverse_map3d_diff;
|
||||
|
||||
Array<int> forward_map2d_mass, forward_map3d_mass;
|
||||
Array<int> inverse_map2d_mass, inverse_map3d_mass;
|
||||
};
|
||||
|
||||
/// Describes the function space on each element
|
||||
|
||||
@@ -557,6 +557,101 @@ H1Pos_TriangleElement::H1Pos_TriangleElement(const int p)
|
||||
}
|
||||
}
|
||||
|
||||
const DofToQuad &H1Pos_TriangleElement::GetRaggedTensorDofToQuad(
|
||||
const FiniteElement &fe, const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode,
|
||||
Array<DofToQuad*> &dof2quad_array)
|
||||
{
|
||||
DofToQuad *d2q = nullptr;
|
||||
MFEM_VERIFY(mode == DofToQuad::RAGGED_TENSOR, "invalid mode requested");
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
#pragma omp critical (DofToQuad)
|
||||
#endif
|
||||
{
|
||||
for (int i = 0; i < dof2quad_array.Size(); i++)
|
||||
{
|
||||
d2q = dof2quad_array[i];
|
||||
if (d2q->IntRule != &ir || d2q->mode != mode) { d2q = nullptr; }
|
||||
}
|
||||
if (!d2q)
|
||||
{
|
||||
d2q = new RaggedDofToQuad;
|
||||
const int ndof = fe.GetOrder() + 1; // verify
|
||||
const int nqpt = (int)floor(pow(ir.GetNPoints(), 1.0/fe.GetDim()) + 0.5);
|
||||
d2q->FE = &fe;
|
||||
d2q->IntRule = &ir;
|
||||
d2q->mode = mode;
|
||||
d2q->ndof = ndof;
|
||||
d2q->nqpt = nqpt;
|
||||
|
||||
RaggedDofToQuad *rd2q = static_cast<RaggedDofToQuad*>(d2q);
|
||||
rd2q->Ba1.SetSize(nqpt*ndof);
|
||||
// second component of ragged tensor basis, technically dof*(dof-1)/2 entries
|
||||
rd2q->Ba2.SetSize((int)nqpt*ndof*ndof);
|
||||
rd2q->Ba1t.SetSize(nqpt*ndof);
|
||||
rd2q->Ba2t.SetSize((int)nqpt*ndof*ndof);
|
||||
// stores first component of ragged tensor basis with order p-1, for gradients only
|
||||
rd2q->Ga1.SetSize(nqpt*(ndof -1));
|
||||
// stores second component of ragged tensor basis with order p-1
|
||||
rd2q->Ga2.SetSize(nqpt*(ndof-1)*(ndof -1));
|
||||
rd2q->Ga1t.SetSize(nqpt*(ndof -1));
|
||||
rd2q->Ga2t.SetSize(nqpt*(ndof-1)*(ndof -1));
|
||||
rd2q->lex_map.SetSize(ndof * ndof);
|
||||
Vector shape_a1(ndof), shape_a2(ndof * ndof);
|
||||
Vector shape_Ga1(ndof-1), shape_Ga2((ndof-1) * (ndof-1));
|
||||
for (int i = 0; i < nqpt; i++)
|
||||
{
|
||||
// The first 'nqpt' points in the first dimension 'ir' have the same x-coordinates as those
|
||||
// of the 1D rule (ie. (2,0) Gauss-Jacobi rule). The first 'nqpt' points in the second dimension
|
||||
// 'ir' have the same y-coordinates as those of the 1D rule for second dimension (i.e. (1,0)
|
||||
// Gauss-Jacobi rule). Additionally, the Bernstein PA algorithms expect evaluation of the
|
||||
// component 1D bases at the Stroud nodes pulled back to the unit square, so perform the pullback
|
||||
// on the fly.
|
||||
const real_t x = ir.IntPoint(i).x;
|
||||
const real_t y = ir.IntPoint(nqpt*i).y / (1.0 - ir.IntPoint(nqpt*i).x);
|
||||
|
||||
Poly_1D::CalcBernstein(ndof-1, x, shape_a1);
|
||||
Poly_1D::CalcBernstein(ndof-2, x, shape_Ga1);
|
||||
for (int j = 0; j < ndof; j++)
|
||||
{
|
||||
rd2q->Ba1t[i+nqpt*j] = rd2q->Ba1[j+ndof*i] = shape_a1(j);
|
||||
if (j < ndof-1)
|
||||
{
|
||||
rd2q->Ga1t[i+nqpt*j] = rd2q->Ga1[j+(ndof-1)*i] = shape_Ga1(j);
|
||||
Poly_1D::CalcBernstein(ndof-2-j, y, shape_Ga2);
|
||||
}
|
||||
|
||||
Poly_1D::CalcBernstein(ndof-1-j, y, shape_a2);
|
||||
for (int k = 0; k < ndof-j; k++)
|
||||
{
|
||||
rd2q->Ba2t[i + nqpt*(j + ndof*k)] = rd2q->Ba2[k + ndof*(j + ndof*i)] = shape_a2(
|
||||
k);
|
||||
if (j < ndof-1 && k < ndof-j-1)
|
||||
{
|
||||
rd2q->Ga2t[i + nqpt*(j + (ndof-1)*k)] = rd2q->Ga2[k + (ndof-1)*(j +
|
||||
(ndof-1)*i)] = shape_Ga2(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stores the mapping from 2D Bernstein multi-index (i,j,p-i-j) to the
|
||||
// lexicographic DOF ordering
|
||||
for (int i = 0; i < ndof; i++)
|
||||
{
|
||||
for (int j = 0; j < ndof-i; j++)
|
||||
{
|
||||
int idx = ((2 * (ndof-1) + 3) - j) * j / 2 + i;
|
||||
rd2q->lex_map[j + ndof*i] = idx;
|
||||
}
|
||||
}
|
||||
dof2quad_array.Append(d2q);
|
||||
}
|
||||
}
|
||||
return *d2q;
|
||||
}
|
||||
|
||||
// static method
|
||||
void H1Pos_TriangleElement::CalcShape(
|
||||
const int p, const real_t l1, const real_t l2, real_t *shape)
|
||||
@@ -749,6 +844,213 @@ H1Pos_TetrahedronElement::H1Pos_TetrahedronElement(const int p)
|
||||
}
|
||||
}
|
||||
|
||||
const DofToQuad &H1Pos_TetrahedronElement::GetRaggedTensorDofToQuad(
|
||||
const FiniteElement &fe, const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode,
|
||||
Array<DofToQuad*> &dof2quad_array)
|
||||
{
|
||||
DofToQuad *d2q = nullptr;
|
||||
MFEM_VERIFY(mode == DofToQuad::RAGGED_TENSOR, "invalid mode requested");
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
#pragma omp critical (DofToQuad)
|
||||
#endif
|
||||
{
|
||||
for (int i = 0; i < dof2quad_array.Size(); i++)
|
||||
{
|
||||
d2q = dof2quad_array[i];
|
||||
if (d2q->IntRule != &ir || d2q->mode != mode) { d2q = nullptr; }
|
||||
}
|
||||
if (!d2q)
|
||||
{
|
||||
d2q = new RaggedDofToQuad;
|
||||
const int ndof = fe.GetOrder() + 1; // verify
|
||||
const int nqpt = (int)floor(pow(ir.GetNPoints(), 1.0/fe.GetDim()) + 0.5);
|
||||
const int basis_dim2d = ndof*(ndof+1) / 2;
|
||||
const int basis_dim3d = ndof*(ndof+1)*(ndof+2) / 6;
|
||||
const int basis_dim2d_diff = (ndof-1)*(ndof) / 2;
|
||||
const int basis_dim3d_diff = (ndof-1)*(ndof)*(ndof+1) / 6;
|
||||
d2q->FE = &fe;
|
||||
d2q->IntRule = &ir;
|
||||
d2q->mode = mode;
|
||||
d2q->ndof = ndof;
|
||||
d2q->nqpt = nqpt;
|
||||
|
||||
RaggedDofToQuad *rd2q = static_cast<RaggedDofToQuad*>(d2q);
|
||||
rd2q->Ba1.SetSize(nqpt * ndof);
|
||||
// second component of ragged tensor basis, technically dof*(dof-1)/2 entries
|
||||
rd2q->Ba2.SetSize(nqpt * basis_dim2d);
|
||||
// third component of ragged tensor basis, technically dof*(dof-1)/2 entries
|
||||
rd2q->Ba3.SetSize(nqpt * basis_dim3d);
|
||||
rd2q->Ba1t.SetSize(nqpt * ndof);
|
||||
rd2q->Ba2t.SetSize(nqpt * basis_dim2d);
|
||||
rd2q->Ba3t.SetSize(nqpt * basis_dim3d);
|
||||
// stores first component of ragged tensor basis with order p-1, for gradients only
|
||||
rd2q->Ga1.SetSize(nqpt * (ndof-1));
|
||||
// stores second component of ragged tensor basis with order p-1
|
||||
rd2q->Ga2.SetSize(nqpt * basis_dim2d_diff);
|
||||
// stores third component of ragged tensor basis with order p-1
|
||||
rd2q->Ga3.SetSize(nqpt * basis_dim3d_diff);
|
||||
rd2q->Ga1t.SetSize(nqpt * (ndof-1));
|
||||
rd2q->Ga2t.SetSize(nqpt * basis_dim2d_diff);
|
||||
rd2q->Ga3t.SetSize(nqpt * basis_dim3d_diff);
|
||||
rd2q->lex_map.SetSize(ndof * ndof * ndof);
|
||||
|
||||
rd2q->forward_map2d_diff.SetSize((ndof-1) * (ndof-1));
|
||||
rd2q->forward_map3d_diff.SetSize((ndof-1) * (ndof-1) * (ndof-1));
|
||||
rd2q->inverse_map2d_diff.SetSize(2 * basis_dim2d_diff);
|
||||
rd2q->inverse_map3d_diff.SetSize(3 * basis_dim3d_diff);
|
||||
|
||||
rd2q->forward_map2d_mass.SetSize(ndof * ndof);
|
||||
rd2q->forward_map3d_mass.SetSize(ndof * ndof * ndof);
|
||||
rd2q->inverse_map2d_mass.SetSize(2 * basis_dim2d);
|
||||
rd2q->inverse_map3d_mass.SetSize(2 * basis_dim3d);
|
||||
|
||||
// forward and inverse maps for multi-index to collpased 1d index for diffusion, can combine
|
||||
// these four loops, but need four idx's and clause for shorter diff loops
|
||||
int idx = 0;
|
||||
for (int i = 0; i < ndof-1; i++)
|
||||
{
|
||||
for (int j = 0; j < ndof-i-1; j++)
|
||||
{
|
||||
rd2q->forward_map2d_diff[j + (ndof-1)*i] = idx;
|
||||
rd2q->inverse_map2d_diff[2*idx] = i;
|
||||
rd2q->inverse_map2d_diff[1 + 2*idx] = j;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for (int k = 0; k < ndof-1; k++)
|
||||
{
|
||||
for (int j = 0; j < ndof-k-1; j++)
|
||||
{
|
||||
for (int i = 0; i < ndof-k-j-1; i++)
|
||||
{
|
||||
rd2q->forward_map3d_diff[k + (ndof-1)*(j + (ndof-1)*i)] = idx;
|
||||
rd2q->inverse_map3d_diff[3*idx] = i;
|
||||
rd2q->inverse_map3d_diff[1 + 3*idx] = j;
|
||||
rd2q->inverse_map3d_diff[2 + 3*idx] = k;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// forward and inverse maps for multi-index to collpased 1d index for mass
|
||||
idx = 0;
|
||||
for (int j = 0; j < ndof; j++)
|
||||
{
|
||||
for (int i = 0; i < ndof-j; i++)
|
||||
{
|
||||
rd2q->forward_map2d_mass[j + ndof*i] = idx;
|
||||
rd2q->inverse_map2d_mass[2*idx] = i;
|
||||
rd2q->inverse_map2d_mass[1 + 2*idx] = j;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for (int k = 0; k < ndof; k++)
|
||||
{
|
||||
for (int j = 0; j < ndof-k; j++)
|
||||
{
|
||||
for (int i = 0; i < ndof-k-j; i++)
|
||||
{
|
||||
rd2q->forward_map3d_mass[k + ndof*(j + ndof*i)] = idx;
|
||||
rd2q->inverse_map3d_mass[2*idx] = i;
|
||||
rd2q->inverse_map3d_mass[1 + 2*idx] = j;
|
||||
// d2q->inverse_map3d_mass[2 + 3*idx] = k;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector shape_a1(ndof), shape_a2(ndof * ndof), shape_a3(ndof * ndof * ndof);
|
||||
Vector shape_Ga1(ndof-1), shape_Ga2(ndof-1), shape_Ga3(ndof-1);
|
||||
for (int i = 0; i < nqpt; i++)
|
||||
{
|
||||
// The first 'nqpt' points in the first dimension 'ir' have the same x-coordinates as those
|
||||
// of the 1D rule (ie. (2,0) Gauss-Jacobi rule). The first 'nqpt' points in the second dimension
|
||||
// 'ir' have the same y-coordinates as those of the 1D rule for second dimension (i.e. (1,0)
|
||||
// Gauss-Jacobi rule). The first 'nqpt' points in the third dimension have the same z-coordinates
|
||||
// as those of the 1D rule for the third dimension (i.e. Gauss-Legendre rule). Additionally,
|
||||
// the Bernstein PA algorithms expect evaluation of the component 1D bases at the Stroud nodes
|
||||
// pulled back to the unit cube, so perform the pullback on the fly.
|
||||
const real_t x = ir.IntPoint(i).x;
|
||||
const real_t y = ir.IntPoint(nqpt*i).y / (1.0 - ir.IntPoint(nqpt*i).x);
|
||||
const real_t z = ir.IntPoint(nqpt*nqpt*i).z / (1.0 - ir.IntPoint(
|
||||
nqpt*nqpt*i).x - ir.IntPoint(nqpt*nqpt*i).y);
|
||||
Poly_1D::CalcBernstein(ndof-1, x, shape_a1);
|
||||
Poly_1D::CalcBernstein(ndof-2, x, shape_Ga1);
|
||||
for (int j = 0; j < ndof; j++)
|
||||
{
|
||||
rd2q->Ba1t[i+nqpt*j] = rd2q->Ba1[j+ndof*i] = shape_a1(j);
|
||||
if (j < ndof-1)
|
||||
{
|
||||
rd2q->Ga1t[i+nqpt*j] = rd2q->Ga1[j+(ndof-1)*i] = shape_Ga1(j);
|
||||
Poly_1D::CalcBernstein(ndof-2-j, y, shape_Ga2);
|
||||
}
|
||||
|
||||
Poly_1D::CalcBernstein(ndof-1-j, y, shape_a2);
|
||||
for (int k = 0; k < ndof-j; k++)
|
||||
{
|
||||
const int a_2d_mass = rd2q->forward_map2d_mass[k + ndof*j];
|
||||
rd2q->Ba2t[i + nqpt*a_2d_mass] = rd2q->Ba2[a_2d_mass + basis_dim2d*i] =
|
||||
shape_a2(
|
||||
k);
|
||||
if (j < ndof-1 && k < ndof-j-1)
|
||||
{
|
||||
const int a_2d_diff = rd2q->forward_map2d_diff[k + (ndof-1)*j];
|
||||
rd2q->Ga2t[i + nqpt*a_2d_diff] = rd2q->Ga2[a_2d_diff + basis_dim2d_diff*i] =
|
||||
shape_Ga2(k);
|
||||
Poly_1D::CalcBernstein(ndof-2-j-k, z, shape_Ga3);
|
||||
}
|
||||
|
||||
Poly_1D::CalcBernstein(ndof-1-j-k, z, shape_a3);
|
||||
for (int m = 0; m < ndof-j-k; m++)
|
||||
{
|
||||
const int a_3d_mass = rd2q->forward_map3d_mass[m + ndof*(k + ndof*j)];
|
||||
rd2q->Ba3t[i + nqpt*a_3d_mass] = rd2q->Ba3[a_3d_mass + basis_dim3d*i] =
|
||||
shape_a3(
|
||||
m);
|
||||
if (j < ndof-1 && k < ndof-j-1 && m < ndof-j-k-1)
|
||||
{
|
||||
// // collapsed 1D access
|
||||
// d2q->Ga3[i + nqpt*(m + d2q->offset3d[k + (ndof-1)*j])] = shape_Ga3(m);
|
||||
// collapsed 1D access with forward mapping
|
||||
const int a_3d_diff = rd2q->forward_map3d_diff[m + (ndof-1)*(k + (ndof-1)*j)];
|
||||
rd2q->Ga3t[i + nqpt*a_3d_diff] = rd2q->Ga3[a_3d_diff + basis_dim3d_diff*i] =
|
||||
shape_Ga3(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stores the mapping from 3D Bernstein multi-index (i,j,k,p-i-j-k) to the
|
||||
// lexicographic DOF ordering
|
||||
int p = ndof - 1;
|
||||
for (int i = 0; i < ndof; i++)
|
||||
{
|
||||
for (int j = 0; j < ndof-i; j++)
|
||||
{
|
||||
for (int k = 0; k < ndof-i-j; k++)
|
||||
{
|
||||
int dof = (p+1)*(p+2)*(p+3) / 6;
|
||||
int tet = (p-k)*(p-k+1)*(p-k+2) / 6;
|
||||
int tri = (p+1-k-j)*(p+2-k-j)/2;
|
||||
int multi_idx = dof - tet - tri + i;
|
||||
rd2q->lex_map[k + ndof*(j + ndof*i)] = multi_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dof2quad_array.Append(d2q);
|
||||
}
|
||||
}
|
||||
return *d2q;
|
||||
}
|
||||
|
||||
// static method
|
||||
void H1Pos_TetrahedronElement::CalcShape(
|
||||
const int p, const real_t l1, const real_t l2, const real_t l3,
|
||||
|
||||
@@ -191,6 +191,21 @@ public:
|
||||
/// Construct the H1Pos_TriangleElement of order @a p
|
||||
H1Pos_TriangleElement(const int p);
|
||||
|
||||
const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode) const override
|
||||
{
|
||||
return (mode == DofToQuad::RAGGED_TENSOR) ?
|
||||
GetRaggedTensorDofToQuad(*this, ir, mode, dof2quad_array) :
|
||||
FiniteElement::GetDofToQuad(ir, mode);
|
||||
}
|
||||
|
||||
static const DofToQuad &GetRaggedTensorDofToQuad(
|
||||
const FiniteElement &fe, const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode,
|
||||
Array<DofToQuad*> &dof2quad_array);
|
||||
|
||||
const Array<int> &GetDofMap() const { return dof_map; }
|
||||
|
||||
// The size of shape is (p+1)(p+2)/2 (dof).
|
||||
static void CalcShape(const int p, const real_t x, const real_t y,
|
||||
real_t *shape);
|
||||
@@ -220,6 +235,21 @@ public:
|
||||
/// Construct the H1Pos_TetrahedronElement of order @a p
|
||||
H1Pos_TetrahedronElement(const int p);
|
||||
|
||||
const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode) const override
|
||||
{
|
||||
return (mode == DofToQuad::RAGGED_TENSOR) ?
|
||||
GetRaggedTensorDofToQuad(*this, ir, mode, dof2quad_array) :
|
||||
FiniteElement::GetDofToQuad(ir, mode);
|
||||
}
|
||||
|
||||
static const DofToQuad &GetRaggedTensorDofToQuad(
|
||||
const FiniteElement &fe, const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode,
|
||||
Array<DofToQuad*> &dof2quad_array);
|
||||
|
||||
const Array<int> &GetDofMap() const { return dof_map; }
|
||||
|
||||
// The size of shape is (p+1)(p+2)(p+3)/6 (dof).
|
||||
static void CalcShape(const int p, const real_t x, const real_t y,
|
||||
const real_t z, real_t *shape);
|
||||
|
||||
@@ -250,6 +250,14 @@ public:
|
||||
its GetOrder() method. */
|
||||
virtual FiniteElementCollection *Clone(int p) const;
|
||||
|
||||
/** @brief Return the order parameter used to construct this collection.
|
||||
* This differs from GetOrder() depending on the collection type. */
|
||||
virtual int GetConstructorOrder() const
|
||||
{
|
||||
MFEM_ABORT("Collection " << Name() << " does not support GetConstructorOrder");
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected:
|
||||
const int base_p; ///< Order as returned by GetOrder().
|
||||
|
||||
@@ -314,6 +322,9 @@ public:
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new H1_FECollection(p, dim, b_type); }
|
||||
|
||||
int GetConstructorOrder() const override
|
||||
{ return base_p; }
|
||||
|
||||
virtual ~H1_FECollection();
|
||||
};
|
||||
|
||||
@@ -343,6 +354,10 @@ class H1_Trace_FECollection : public H1_FECollection
|
||||
public:
|
||||
H1_Trace_FECollection(const int p, const int dim,
|
||||
const int btype = BasisType::GaussLobatto);
|
||||
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new H1_Trace_FECollection(p, dim+1, b_type); }
|
||||
|
||||
};
|
||||
|
||||
/// Arbitrary order "L2-conforming" discontinuous finite elements.
|
||||
@@ -396,6 +411,9 @@ public:
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new L2_FECollection(p, dim, b_type, m_type); }
|
||||
|
||||
int GetConstructorOrder() const override
|
||||
{ return base_p; }
|
||||
|
||||
virtual ~L2_FECollection();
|
||||
};
|
||||
|
||||
@@ -456,6 +474,9 @@ public:
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new RT_FECollection(p, dim, cb_type, ob_type); }
|
||||
|
||||
int GetConstructorOrder() const override
|
||||
{ return base_p-1; }
|
||||
|
||||
virtual ~RT_FECollection();
|
||||
};
|
||||
|
||||
@@ -536,6 +557,9 @@ public:
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new ND_FECollection(p, dim, cb_type, ob_type); }
|
||||
|
||||
int GetConstructorOrder() const override
|
||||
{ return dim>1 ? base_p : base_p+1; }
|
||||
|
||||
virtual ~ND_FECollection();
|
||||
};
|
||||
|
||||
@@ -548,6 +572,9 @@ public:
|
||||
ND_Trace_FECollection(const int p, const int dim,
|
||||
const int cb_type = BasisType::GaussLobatto,
|
||||
const int ob_type = BasisType::GaussLegendre);
|
||||
|
||||
FiniteElementCollection *Clone(int p) const override
|
||||
{ return new ND_Trace_FECollection(p, dim+1, cb_type, ob_type); }
|
||||
};
|
||||
|
||||
/// Arbitrary order 3D H(curl)-conforming Nedelec finite elements in 1D.
|
||||
|
||||
+1
-2
@@ -4631,9 +4631,8 @@ FiniteElementCollection *FiniteElementSpace::Load(Mesh *m, std::istream &input)
|
||||
|
||||
ElementDofOrdering GetEVectorOrdering(const FiniteElementSpace& fes)
|
||||
{
|
||||
return UsesTensorBasis(fes)?
|
||||
return (UsesTensorBasis(fes) || fes.UsesRaggedTensorBasis()) ?
|
||||
ElementDofOrdering::LEXICOGRAPHIC:
|
||||
ElementDofOrdering::NATIVE;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -1514,6 +1514,18 @@ public:
|
||||
return dynamic_cast<const L2_FECollection*>(fec) != NULL;
|
||||
}
|
||||
|
||||
/// @brief Return true if the mesh contains only one topology, the elements are
|
||||
/// all triangles or tetrahedrons, and the elements are ragged tensor elements
|
||||
/// i.e. Bernstein/positive basis.
|
||||
bool UsesRaggedTensorBasis() const
|
||||
{
|
||||
bool simplex = this->GetMesh()->IsSimplexMesh();
|
||||
bool positive =
|
||||
dynamic_cast<const mfem::H1Pos_TriangleElement *>(this->GetTypicalFE()) ||
|
||||
dynamic_cast<const mfem::H1Pos_TetrahedronElement *>(this->GetTypicalFE());
|
||||
return simplex && positive;
|
||||
}
|
||||
|
||||
/** In variable-order spaces on nonconforming (NC) meshes, this function
|
||||
controls whether strict conformity is enforced in cases where coarse
|
||||
edges/faces have higher polynomial order than their fine NC neighbors.
|
||||
|
||||
@@ -2256,6 +2256,104 @@ void GridFunction::AccumulateAndCountBdrTangentValues(
|
||||
}
|
||||
}
|
||||
|
||||
void GridFunction::AccumulateAndCountTraceValues(
|
||||
Coefficient *coeff[], VectorCoefficient *vcoeff,
|
||||
Array<int> &values_counter)
|
||||
{
|
||||
if (vcoeff)
|
||||
{
|
||||
MFEM_VERIFY(fes->GetVDim() == vcoeff->GetVDim(),
|
||||
"vcoeff vdim != fes VDim");
|
||||
MFEM_VERIFY(fes->GetTypicalTraceElement()->GetMapType() ==
|
||||
FiniteElement::VALUE &&
|
||||
fes->GetTypicalTraceElement()->GetRangeType() ==
|
||||
FiniteElement::SCALAR,
|
||||
"Can only call ProjectTraceCoefficient on scalar value-type "
|
||||
"trace elements. "
|
||||
"Use ProjectTraceCoefficientNormal for RT and "
|
||||
"ProjectTraceCoefficientTangent for ND finite elements.");
|
||||
}
|
||||
|
||||
Array<int> vdofs;
|
||||
Vector vc;
|
||||
|
||||
values_counter.SetSize(Size());
|
||||
values_counter = 0;
|
||||
|
||||
const int vdim = fes->GetVDim();
|
||||
HostReadWrite();
|
||||
|
||||
for (int i = 0; i < fes->GetMesh()->GetNumFaces(); i++)
|
||||
{
|
||||
|
||||
const FiniteElement *fe = fes->GetFaceElement(i);
|
||||
const int fdof = fe->GetDof();
|
||||
ElementTransformation *transf = fes->GetMesh()->GetFaceTransformation(i);
|
||||
const IntegrationRule &ir = fe->GetNodes();
|
||||
fes->GetFaceVDofs(i, vdofs);
|
||||
|
||||
for (int j = 0; j < fdof; j++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(j);
|
||||
transf->SetIntPoint(&ip);
|
||||
if (vcoeff) { vcoeff->Eval(vc, *transf, ip); }
|
||||
for (int d = 0; d < vdim; d++)
|
||||
{
|
||||
if (!vcoeff && !coeff[d]) { continue; }
|
||||
|
||||
real_t val = vcoeff ? vc(d) : coeff[d]->Eval(*transf, ip);
|
||||
int ind = vdofs[fdof*d+j];
|
||||
if ( ind < 0 )
|
||||
{
|
||||
val = -val, ind = -1-ind;
|
||||
}
|
||||
if (++values_counter[ind] == 1)
|
||||
{
|
||||
(*this)(ind) = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this)(ind) += val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GridFunction::AccumulateAndCountTraceTangentValues(
|
||||
VectorCoefficient &vcoeff, Array<int> &values_counter)
|
||||
{
|
||||
MFEM_VERIFY(fes->GetVDim() == 1, "fespace VDim != 1");
|
||||
MFEM_VERIFY(fes->GetTypicalTraceElement()
|
||||
->GetRangeType() == FiniteElement::VECTOR &&
|
||||
fes->GetTypicalTraceElement()
|
||||
->GetMapType() == FiniteElement::H_CURL,
|
||||
"Not an ND FE space!");
|
||||
MFEM_VERIFY(fes->GetTypicalTraceElement()->GetPhysRangeDim(
|
||||
fes->GetMesh()->SpaceDimension()) == vcoeff.GetVDim(),
|
||||
"vcoeff vdim != PhysRangeDim");
|
||||
|
||||
const FiniteElement *fe;
|
||||
ElementTransformation *T;
|
||||
Array<int> dofs;
|
||||
Vector lvec;
|
||||
|
||||
values_counter.SetSize(Size());
|
||||
values_counter = 0;
|
||||
|
||||
HostReadWrite();
|
||||
|
||||
for (int i = 0; i < fes->GetMesh()->GetNumFaces(); i++)
|
||||
{
|
||||
fe = fes->GetFaceElement(i);
|
||||
T = fes->GetMesh()->GetFaceTransformation(i);
|
||||
fes->GetFaceVDofs(i, dofs);
|
||||
lvec.SetSize(fe->GetDof());
|
||||
fe->Project(vcoeff, *T, lvec);
|
||||
accumulate_dofs(dofs, lvec, *this, values_counter);
|
||||
}
|
||||
}
|
||||
|
||||
void GridFunction::ComputeMeans(AvgType type, Array<int> &zones_per_vdof)
|
||||
{
|
||||
switch (type)
|
||||
@@ -2698,6 +2796,74 @@ void GridFunction::ProjectCoefficient(VectorCoefficient &vcoeff,
|
||||
}
|
||||
}
|
||||
|
||||
void GridFunction::ProjectTraceCoefficient(Coefficient *coeff[])
|
||||
{
|
||||
Array<int> values_counter;
|
||||
AccumulateAndCountTraceValues(coeff, NULL, values_counter);
|
||||
ComputeMeans(ARITHMETIC, values_counter);
|
||||
}
|
||||
|
||||
void GridFunction::ProjectTraceCoefficient(Coefficient &coeff)
|
||||
{
|
||||
MFEM_VERIFY(FESpace()->GetVDim() == 1, "ProjectTraceCoefficient(Coefficient&)"
|
||||
"is only valid for scalar GridFunction");
|
||||
Coefficient *coeff_p = &coeff;
|
||||
ProjectTraceCoefficient(&coeff_p);
|
||||
}
|
||||
|
||||
void GridFunction::ProjectTraceCoefficient(VectorCoefficient &vcoeff)
|
||||
{
|
||||
MFEM_VERIFY(FESpace()->GetVDim() == vcoeff.GetVDim(),
|
||||
"Incompatible vcoeff vdim and fes vdim");
|
||||
Array<int> values_counter;
|
||||
AccumulateAndCountTraceValues(NULL, &vcoeff, values_counter);
|
||||
ComputeMeans(ARITHMETIC, values_counter);
|
||||
}
|
||||
|
||||
void GridFunction::ProjectTraceCoefficientNormal(VectorCoefficient &vcoeff)
|
||||
{
|
||||
MFEM_VERIFY(fes->GetVDim() == 1, "fespace VDim != 1");
|
||||
MFEM_VERIFY(fes->GetTypicalTraceElement()->GetRangeType() ==
|
||||
FiniteElement::SCALAR &&
|
||||
fes->GetTypicalTraceElement()->GetMapType() ==
|
||||
FiniteElement::INTEGRAL, "Not an RT FE space!");
|
||||
MFEM_VERIFY(vcoeff.GetVDim() == fes->GetMesh()->SpaceDimension(),
|
||||
"vcoeff vdim (" << vcoeff.GetVDim()
|
||||
<< ") != SpaceDimension ("
|
||||
<< fes->GetMesh()->SpaceDimension() << ")");
|
||||
|
||||
const FiniteElement *fe;
|
||||
ElementTransformation *T;
|
||||
Array<int> dofs;
|
||||
int dim = vcoeff.GetVDim();
|
||||
Vector vc(dim), nor(dim), lvec;
|
||||
|
||||
for (int i = 0; i < fes->GetMesh()->GetNumFaces(); i++)
|
||||
{
|
||||
fe = fes->GetFaceElement(i);
|
||||
T = fes->GetMesh()->GetFaceTransformation(i);
|
||||
const IntegrationRule &ir = fe->GetNodes();
|
||||
lvec.SetSize(fe->GetDof());
|
||||
for (int j = 0; j < ir.GetNPoints(); j++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(j);
|
||||
T->SetIntPoint(&ip);
|
||||
vcoeff.Eval(vc, *T, ip);
|
||||
CalcOrtho(T->Jacobian(), nor);
|
||||
lvec(j) = (vc * nor);
|
||||
}
|
||||
fes->GetFaceVDofs(i, dofs);
|
||||
SetSubVector(dofs, lvec);
|
||||
}
|
||||
}
|
||||
|
||||
void GridFunction::ProjectTraceCoefficientTangent(VectorCoefficient &vcoeff)
|
||||
{
|
||||
Array<int> values_counter;
|
||||
AccumulateAndCountTraceTangentValues(vcoeff, values_counter);
|
||||
ComputeMeans(ARITHMETIC, values_counter);
|
||||
}
|
||||
|
||||
void GridFunction::ProjectCoefficientGlobalL2(VectorCoefficient &vcoeff,
|
||||
real_t rtol, int iter)
|
||||
{
|
||||
@@ -5286,6 +5452,7 @@ PLBound GridFunction::GetBounds(Vector &lower, Vector &upper,
|
||||
{
|
||||
int max_order = fes->GetMaxElementOrder();
|
||||
PLBound plb(fes, ref_factor*(max_order+1));
|
||||
|
||||
Vector lel, uel;
|
||||
GetElementBounds(plb, lel, uel, vdim);
|
||||
|
||||
|
||||
+27
-3
@@ -578,6 +578,13 @@ protected:
|
||||
const Array<int> &bdr_attr,
|
||||
Array<int> &values_counter);
|
||||
|
||||
void AccumulateAndCountTraceValues(Coefficient *coeff[],
|
||||
VectorCoefficient *vcoeff,
|
||||
Array<int> &values_counter);
|
||||
|
||||
void AccumulateAndCountTraceTangentValues(VectorCoefficient &vcoeff,
|
||||
Array<int> &values_counter);
|
||||
|
||||
// Complete the computation of averages; called e.g. after
|
||||
// AccumulateAndCountZones().
|
||||
void ComputeMeans(AvgType type, Array<int> &zones_per_vdof);
|
||||
@@ -663,6 +670,23 @@ public:
|
||||
ProjectBdrCoefficient(&coeff_p, attr);
|
||||
}
|
||||
|
||||
/// Project a Coefficient on a GridFunction defined on H1 trace space
|
||||
void ProjectTraceCoefficient(Coefficient *coeff[]);
|
||||
void ProjectTraceCoefficient(Coefficient &coeff);
|
||||
|
||||
/** @brief Project a VectorCoefficient @a vcoeff on a GridFunction
|
||||
defined on a Vector H1 trace space. Note that this also works
|
||||
for a scalar H1 trace space, where only the first component of
|
||||
@a vcoeff is used. */
|
||||
void ProjectTraceCoefficient(VectorCoefficient &vcoeff);
|
||||
/** @brief Project a VectorCoefficient on a GridFunction
|
||||
defined on an RT trace space */
|
||||
void ProjectTraceCoefficientNormal(VectorCoefficient &vcoeff);
|
||||
/** @brief Project a VectorCoefficient on a GridFunction
|
||||
defined on an ND trace space */
|
||||
void ProjectTraceCoefficientTangent(VectorCoefficient &vcoeff);
|
||||
|
||||
|
||||
/** @brief Project a VectorCoefficient on the GridFunction, modifying only
|
||||
DOFs on the boundary associated with the boundary attributes marked in
|
||||
the @a attr array. */
|
||||
@@ -1767,8 +1791,8 @@ public:
|
||||
const int ref_factor=1, const int vdim=-1) const;
|
||||
|
||||
/// Computes the \ref PLBound for the gridfunction with number of control
|
||||
/// points based on \p ref_factor, and returns the bounds for each element
|
||||
/// ordered byNodes:
|
||||
/// points based on @a ref_factor, and returns the bounds for each element
|
||||
/// ordered byNODES:
|
||||
/// lower_{0,0}, lower_{1,0}, ..., lower_{ne-1,0},
|
||||
/// lower_{0,1}, ..., lower_{ne-1,vdim-1}. We also return the
|
||||
/// PLBound object used to compute the bounds.
|
||||
@@ -1802,7 +1826,7 @@ public:
|
||||
const int vdim = -1) const;
|
||||
|
||||
/// Compute bounds on the grid function for all the elements. The bounds
|
||||
/// are returned in @b lower and @b upper, ordered byNodes:
|
||||
/// are returned in @b lower and @b upper, ordered byNODES:
|
||||
/// lower_{0,0}, lower_{1,0}, ..., lower_{ne-1,0},
|
||||
/// lower_{0,1}, ..., lower_{ne-1,vdim-1}
|
||||
void GetElementBounds(const PLBound &plb, Vector &lower, Vector &upper,
|
||||
|
||||
+2390
-158
File diff suppressed because it is too large
Load Diff
+343
-67
@@ -21,6 +21,45 @@
|
||||
|
||||
#ifdef MFEM_USE_GSLIB
|
||||
|
||||
/* gslib license and copyright statement for code adapted from gslib:
|
||||
|
||||
Copyright (c) 2008-2024, UCHICAGO ARGONNE, LLC.
|
||||
|
||||
The UChicago Argonne, LLC as Operator of Argonne National
|
||||
Laboratory holds copyright in the Software. The copyright holder
|
||||
reserves all rights except those expressly granted to licensees,
|
||||
and U.S. Government license rights.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the disclaimer below.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the disclaimer (as noted below)
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. Neither the name of ANL nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
|
||||
ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace gslib
|
||||
{
|
||||
struct comm;
|
||||
@@ -86,7 +125,7 @@ protected:
|
||||
void *fdataD;
|
||||
struct gslib::crystal *cr; // gslib's internal data
|
||||
struct gslib::comm *gsl_comm; // gslib's internal data
|
||||
int dim, points_cnt; // mesh dimension and number of points
|
||||
int dim, spacedim, points_cnt; // mesh dimension and number of points
|
||||
Array<unsigned int> gsl_code, gsl_proc, gsl_elem, gsl_mfem_elem;
|
||||
Vector gsl_mesh, gsl_ref, gsl_dist, gsl_mfem_ref;
|
||||
Array<unsigned int> recv_proc, recv_index; // data for custom interpolation
|
||||
@@ -104,18 +143,23 @@ protected:
|
||||
bool gpu_to_cpu_fallback = false;
|
||||
|
||||
// Device specific data used for FindPoints
|
||||
struct
|
||||
struct DEV_STRUCT
|
||||
{
|
||||
bool setup_device = false;
|
||||
bool find_device = false;
|
||||
int local_hash_size, dof1d, dof1d_sol, h_o_size, h_nx;
|
||||
int local_hash_size, dof1d, dof1d_sol, lh_nx, gh_nx;
|
||||
double newt_tol; // Tolerance specified during setup for Newton solve
|
||||
struct gslib::crystal *cr;
|
||||
struct gslib::hash_data_3 *hash3;
|
||||
struct gslib::hash_data_2 *hash2;
|
||||
mutable Vector bb, wtend, gll1d, lagcoeff, gll1d_sol, lagcoeff_sol;
|
||||
mutable Array<unsigned int> loc_hash_offset;
|
||||
mutable Vector loc_hash_min, loc_hash_fac;
|
||||
mutable Array<unsigned int> lh_offset, gh_offset;
|
||||
mutable Vector lh_min, lh_fac, gh_min, gh_fac;
|
||||
// Tolerance to mark points found on the surface as CODE_INTERNAL
|
||||
// or CODE_BORDER. This is needed because we cannot only use reference
|
||||
// space coordinates to determine if a point is located inside the
|
||||
// element or not.
|
||||
mutable double surf_dist_tol;
|
||||
} DEV;
|
||||
|
||||
/// Use GSLIB for communication and interpolation
|
||||
@@ -127,80 +171,143 @@ protected:
|
||||
Vector &field_out,
|
||||
const int field_out_ordering);
|
||||
|
||||
/// Since GSLIB is designed to work with quads/hexes, we split every
|
||||
/// triangle/tet/prism/pyramid element into quads/hexes.
|
||||
/** @brief Since GSLIB is designed to work with quads/hexes, we split every
|
||||
* triangle/tet/prism/pyramid element into quads/hexes. */
|
||||
virtual void SetupSplitMeshes();
|
||||
|
||||
/// Setup integration points that will be used to interpolate the nodal
|
||||
/// location at points expected by GSLIB.
|
||||
/** @brief Setup integration points that will be used to interpolate the
|
||||
* nodal location at points expected by GSLIB. */
|
||||
virtual void SetupIntegrationRuleForSplitMesh(Mesh *mesh,
|
||||
IntegrationRule *irule,
|
||||
int order);
|
||||
|
||||
/// Helper function that calls \ref SetupSplitMeshes and
|
||||
/// \ref SetupIntegrationRuleForSplitMesh.
|
||||
/** @brief Helper function that calls \ref SetupSplitMeshes and
|
||||
* \ref SetupIntegrationRuleForSplitMesh. */
|
||||
virtual void SetupSplitMeshesAndIntegrationRules(const int order);
|
||||
|
||||
/// Get GridFunction value at the points expected by GSLIB.
|
||||
virtual void GetNodalValues(const GridFunction *gf_in, Vector &node_vals) const;
|
||||
|
||||
/// Map {r,s,t} coordinates from [-1,1] to [0,1] for MFEM. For simplices,
|
||||
/// find the original element number (that was split into micro quads/hexes)
|
||||
/// during the setup phase.
|
||||
/** @brief Map {r,s,t} coordinates from [-1,1] to [0,1] for MFEM. For
|
||||
* simplices, find the original element number (that was split into
|
||||
* micro quads/hexes) during the setup phase. */
|
||||
virtual void MapRefPosAndElemIndices();
|
||||
|
||||
// Device functions
|
||||
// FindPoints locally on device for 3D.
|
||||
/// FindPoints locally on device for 3D.
|
||||
void FindPointsLocal3(const Vector &point_pos, int point_pos_ordering,
|
||||
Array<unsigned int> &gsl_code_dev_l,
|
||||
Array<unsigned int> &gsl_elem_dev_l, Vector &gsl_ref_l,
|
||||
Vector &gsl_dist_l, int npt);
|
||||
|
||||
// FindPoints locally on device for 2D.
|
||||
/// FindPoints locally on device for 2D.
|
||||
void FindPointsLocal2(const Vector &point_pos, int point_pos_ordering,
|
||||
Array<unsigned int> &gsl_code_dev_l,
|
||||
Array<unsigned int> &gsl_elem_dev_l, Vector &gsl_ref_l,
|
||||
Vector &gsl_dist_l, int npt);
|
||||
|
||||
// Interpolate on device for 3D.
|
||||
/// FindPoints locally on device for 3D surface elements.
|
||||
void FindPointsSurfLocal3(const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &gsl_code_dev_l,
|
||||
Array<unsigned int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &gsl_dist_l,
|
||||
int npt);
|
||||
|
||||
/// FindPoints locally on device for 3D edge elements.
|
||||
void FindPointsEdgeLocal3(const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &gsl_code_dev_l,
|
||||
Array<unsigned int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &gsl_dist_l,
|
||||
int npt);
|
||||
|
||||
/// FindPoints locally on device for 2D edge elements.
|
||||
void FindPointsEdgeLocal2(const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &gsl_code_dev_l,
|
||||
Array<unsigned int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &gsl_dist_l,
|
||||
int npt);
|
||||
|
||||
/// Interpolate on device for 3D.
|
||||
void InterpolateLocal3(const Vector &field_in,
|
||||
Array<int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1dsol);
|
||||
// Interpolate on device for 2D.
|
||||
int dof1dsol);
|
||||
|
||||
/// Interpolate on device for 2D.
|
||||
void InterpolateLocal2(const Vector &field_in,
|
||||
Array<int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1dsol);
|
||||
int dof1dsol);
|
||||
|
||||
// Prepare data for device functions.
|
||||
/// Interpolate on device for 1D.
|
||||
void InterpolateLocal1(const Vector &field_in,
|
||||
Array<int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp, int dof1dsol);
|
||||
|
||||
/// Prepare data for device execution for volume meshes.
|
||||
void SetupDevice();
|
||||
|
||||
/** Searches positions given in physical space by @a point_pos.
|
||||
/** @brief Searches positions given in physical space by @a point_pos.
|
||||
These positions can be ordered byNodes: (XXX...,YYY...,ZZZ) or
|
||||
byVDim: (XYZ,XYZ,....XYZ) specified by @a point_pos_ordering. */
|
||||
void FindPointsOnDevice(const Vector &point_pos,
|
||||
const int point_pos_ordering = Ordering::byNODES);
|
||||
|
||||
/** Interpolation of field values at prescribed reference space positions.
|
||||
@param[in] field_in_evec E-vector of grid function to be interpolated.
|
||||
Assumed ordering is NDOFSxVDIMxNEL
|
||||
@param[in] nel Number of elements in the mesh.
|
||||
@param[in] ncomp Number of components in the field.
|
||||
@param[in] dof1dsol Number of degrees of freedom in each reference
|
||||
space direction.
|
||||
@param[in] ordering Ordering of the out field values: byNodes/byVDIM
|
||||
|
||||
@param[out] field_out Interpolated values. For points that are not found
|
||||
the value is set to #default_interp_value. */
|
||||
/** @brief Interpolation of field values at prescribed reference space
|
||||
* positions.
|
||||
* @param[in] field_in_evec E-vector of grid function to be interpolated.
|
||||
* Assumed ordering is NDOFSxVDIMxNEL
|
||||
* @param[in] nel Number of elements in the mesh.
|
||||
* @param[in] ncomp Number of components in the field.
|
||||
* @param[in] dof1dsol Number of degrees of freedom in each reference
|
||||
* space direction.
|
||||
* @param[in] ordering Ordering of the out field values: byNodes/byVDIM
|
||||
*
|
||||
* @param[out] field_out Interpolated values. For points that are not
|
||||
* found the value is set to
|
||||
* #default_interp_value. */
|
||||
void InterpolateOnDevice(const Vector &field_in_evec, Vector &field_out,
|
||||
const int nel, const int ncomp,
|
||||
const int dof1dsol, const int ordering);
|
||||
|
||||
/** @brief Interpolation of field values at prescribed reference space
|
||||
* positions for surface meshes. */
|
||||
void InterpolateSurfBase(const Vector &field_in, Vector &field_out,
|
||||
const int nel, const int ncomp,
|
||||
const int dof1dsol, const int field_out_ordering);
|
||||
|
||||
/// Preprocess 2D surface mesh needed for FindPoints.
|
||||
void findptsedge_setup_2(DEV_STRUCT &devs,
|
||||
const double *const elx[2],
|
||||
const unsigned n,
|
||||
const uint nel,
|
||||
const unsigned m,
|
||||
const double bbox_tol,
|
||||
const uint local_hash_size,
|
||||
const uint global_hash_size);
|
||||
|
||||
/// Preprocess 3D surface mesh needed for FindPoints.
|
||||
void findptssurf_setup_3(DEV_STRUCT &devs,
|
||||
const double *const elx[3],
|
||||
const unsigned n,
|
||||
const uint nel,
|
||||
const unsigned m,
|
||||
const double bbox_tol,
|
||||
const uint local_hash_size,
|
||||
const uint global_hash_size,
|
||||
const int rD);
|
||||
|
||||
public:
|
||||
/// Serial constructor
|
||||
FindPointsGSLIB();
|
||||
@@ -224,8 +331,10 @@ public:
|
||||
FindPointsGSLIB(const FindPointsGSLIB&) = delete;
|
||||
FindPointsGSLIB& operator=(const FindPointsGSLIB&) = delete;
|
||||
|
||||
/** Initializes the internal mesh in gslib, by sending the positions of the
|
||||
Gauss-Lobatto nodes of the input Mesh object \p m.
|
||||
/** @brief Preprocess the internal mesh in gslib.
|
||||
|
||||
@details Initializes the internal mesh in gslib, by sending the
|
||||
positions of the Gauss-Lobatto nodes of the input Mesh object \p m.
|
||||
Note: not tested with periodic (L2).
|
||||
Note: the input mesh \p m must have Nodes set.
|
||||
|
||||
@@ -236,13 +345,22 @@ public:
|
||||
search methods.
|
||||
@param[in] npt_max (Optional) Number of points for simultaneous
|
||||
iteration. This alters performance and
|
||||
memory footprint.*/
|
||||
|
||||
memory footprint.
|
||||
*/
|
||||
void Setup(Mesh &m, const double bb_t = 0.1, const double newt_tol = 1.0e-12,
|
||||
const int npt_max = 256);
|
||||
/** Searches positions given in physical space by \p point_pos.
|
||||
These positions can be ordered byNodes: (XXX...,YYY...,ZZZ) or
|
||||
|
||||
/// Preprocess the surface mesh to compute data for FindPoints.
|
||||
void SetupSurf(Mesh &m,
|
||||
const double bb_t = 0.1,
|
||||
const double newt_tol = 1.0e-12,
|
||||
const int npt_max = 256);
|
||||
|
||||
/** @brief Searches positions given in physical space by \p point_pos.
|
||||
|
||||
@details These positions can be ordered byNodes: (XXX...,YYY...,ZZZ) or
|
||||
byVDim: (XYZ,XYZ,....XYZ) specified by \p point_pos_ordering.
|
||||
|
||||
This function populates the following member variables:
|
||||
#gsl_code Return codes for each point: inside element (0),
|
||||
element boundary (1), not found (2).
|
||||
@@ -261,19 +379,34 @@ public:
|
||||
#gsl_dist Distance between the sought and the found point
|
||||
in physical space. */
|
||||
void FindPoints(const Vector &point_pos,
|
||||
const int point_pos_ordering = Ordering::byNODES);
|
||||
int point_pos_ordering = Ordering::byNODES);
|
||||
|
||||
/// Convenience function when point positions are in a ParticleVector
|
||||
void FindPoints(const ParticleVector &point_pos)
|
||||
{
|
||||
FindPoints(point_pos, point_pos.GetOrdering());
|
||||
}
|
||||
|
||||
/** @brief Searches positions given in physical space by \p point_pos on
|
||||
* surface mesh. */
|
||||
void FindPointsSurf(const Vector &point_pos,
|
||||
int point_pos_ordering = Ordering::byNODES);
|
||||
|
||||
/// Convenience function when point positions are in a ParticleVector
|
||||
void FindPointsSurf(const ParticleVector &point_pos)
|
||||
{
|
||||
FindPointsSurf(point_pos, point_pos.GetOrdering());
|
||||
}
|
||||
|
||||
/// Setup FindPoints and search positions
|
||||
void FindPoints(Mesh &m, const Vector &point_pos,
|
||||
const int point_pos_ordering = Ordering::byNODES,
|
||||
const double bb_t = 0.1, const double newt_tol = 1.0e-12,
|
||||
const int npt_max = 256);
|
||||
|
||||
/** Interpolation of field values at prescribed reference space positions.
|
||||
/** @brief Interpolation of field values at prescribed reference space
|
||||
* positions.
|
||||
|
||||
@param[in] field_in Function values that will be interpolated on the
|
||||
reference positions. Note: it is assumed that
|
||||
\p field_in is in H1 and in the same space as the
|
||||
@@ -282,19 +415,36 @@ public:
|
||||
the value is set to #default_interp_value.
|
||||
The output ordering is determined from field_in.*/
|
||||
virtual void Interpolate(const GridFunction &field_in, Vector &field_out);
|
||||
|
||||
/// Interpolation of field values, with output ordering specification.
|
||||
virtual void Interpolate(const GridFunction &field_in, Vector &field_out,
|
||||
const int field_out_ordering);
|
||||
/** Search positions and interpolate. The ordering (byNODES or byVDIM) of
|
||||
the output values in \p field_out corresponds to the ordering used
|
||||
in the input GridFunction \p field_in. */
|
||||
|
||||
/** @brief Same as Interpolate but for surface meshes */
|
||||
virtual void InterpolateSurf(const GridFunction &field_in,
|
||||
Vector &field_out);
|
||||
|
||||
/** @brief Same as Interpolate but for surface meshes with specified output
|
||||
ordering */
|
||||
virtual void InterpolateSurf(const GridFunction &field_in,
|
||||
Vector &field_out,
|
||||
const int field_out_ordering);
|
||||
|
||||
/** @brief Search positions and interpolate.
|
||||
*
|
||||
* @details The ordering (byNODES or byVDIM) of the output values in
|
||||
* \p field_out corresponds to the ordering used in the input
|
||||
* GridFunction \p field_in.
|
||||
*/
|
||||
void Interpolate(const Vector &point_pos, const GridFunction &field_in,
|
||||
Vector &field_out,
|
||||
const int point_pos_ordering = Ordering::byNODES);
|
||||
int point_pos_ordering = Ordering::byNODES);
|
||||
|
||||
/// Search positions and interpolate with given point and output ordering.
|
||||
void Interpolate(const Vector &point_pos, const GridFunction &field_in,
|
||||
Vector &field_out, const int point_pos_ordering,
|
||||
const int field_out_ordering);
|
||||
|
||||
/** Setup FindPoints, search positions and interpolate. The ordering (byNODES
|
||||
or byVDIM) of the output values in \p field_out corresponds to the
|
||||
ordering used in the input GridFunction \p field_in. */
|
||||
@@ -302,32 +452,36 @@ public:
|
||||
const GridFunction &field_in, Vector &field_out,
|
||||
const int point_pos_ordering = Ordering::byNODES);
|
||||
|
||||
/// Average type to be used for L2 functions in-case a point is located at
|
||||
/// an element boundary where the function might be multi-valued.
|
||||
/** @brief Average type to be used for L2 functions in-case a point is
|
||||
* located at an element boundary where the function might be multi-valued.
|
||||
*/
|
||||
virtual void SetL2AvgType(AvgType avgtype_) { avgtype = avgtype_; }
|
||||
|
||||
/// Set the default interpolation value for points that are not found in the
|
||||
/// mesh.
|
||||
/** @brief Set the default interpolation value for points that are not found in the mesh. */
|
||||
virtual void SetDefaultInterpolationValue(double interp_value_)
|
||||
{
|
||||
default_interp_value = interp_value_;
|
||||
}
|
||||
|
||||
/// Set the tolerance for detecting points outside the 'curvilinear' boundary
|
||||
/// that gslib may return as found on the boundary. Points found on boundary
|
||||
/// with distance greater than @ bdr_tol are marked as not found.
|
||||
/** @brief Tolerance for detecting points outside the 'curvilinear' boundary.
|
||||
*
|
||||
* @details When using FindPoints, gslib may return points as found on the
|
||||
* boundary even when they are slightly outside the domain. This tolerance
|
||||
* is used to filter such points based on the distance^2 value and mark them
|
||||
* as not found.*/
|
||||
virtual void SetDistanceToleranceForPointsFoundOnBoundary(double bdr_tol_)
|
||||
{
|
||||
bdr_tol = bdr_tol_;
|
||||
}
|
||||
|
||||
/// Enable/Disable use of CPU functions for GPU data if the gslib version
|
||||
/// is older.
|
||||
/** @brief Enable/Disable use of CPU functions for GPU data if the gslib
|
||||
* version is older. */
|
||||
virtual void SetGPUtoCPUFallback(bool mode) { gpu_to_cpu_fallback = mode; }
|
||||
|
||||
/** Cleans up memory allocated internally by gslib.
|
||||
Note that in parallel, this must be called before MPI_Finalize(), as it
|
||||
calls MPI_Comm_free() for internal gslib communicators. FreeData is
|
||||
/** @brief Cleans up memory allocated internally by gslib.
|
||||
|
||||
@details Note that in parallel, this must be called before MPI_Finalize,
|
||||
as it calls MPI_Comm_free() for internal gslib communicators. FreeData is
|
||||
also called by the class destructor and there are no memory leaks if the
|
||||
destructor is called before MPI_Finalize(). If the destructor is called
|
||||
after MPI_Finalize(), there will be an error because gslib will try to
|
||||
@@ -335,8 +489,8 @@ public:
|
||||
*/
|
||||
virtual void FreeData();
|
||||
|
||||
/// Return code for each point searched by FindPoints: inside element (0), on
|
||||
/// element boundary (1), or not found (2).
|
||||
/** @brief Return code for each point searched by FindPoints:
|
||||
* inside element (0), element boundary (1), or not found (2). */
|
||||
virtual const Array<unsigned int> &GetCode() const { return gsl_code; }
|
||||
/// Return element number for each point found by FindPoints.
|
||||
virtual const Array<unsigned int> &GetElem() const { return gsl_mfem_elem; }
|
||||
@@ -344,15 +498,15 @@ public:
|
||||
virtual const Array<unsigned int> &GetProc() const { return gsl_proc; }
|
||||
/// Return reference coordinates for each point found by FindPoints.
|
||||
virtual const Vector &GetReferencePosition() const { return gsl_mfem_ref; }
|
||||
/// Return distance between the sought and the found point in physical space,
|
||||
/// for each point found by FindPoints.
|
||||
/// Return distance between the sought and the found point in physical space.
|
||||
virtual const Vector &GetDist() const { return gsl_dist; }
|
||||
|
||||
/// Return element number for each point found by FindPoints corresponding to
|
||||
/// GSLIB mesh. gsl_mfem_elem != gsl_elem for mesh with simplices.
|
||||
/** @brief Return element number for each point found by FindPoints
|
||||
* corresponding to GSLIB mesh. gsl_mfem_elem != gsl_elem for mesh with
|
||||
* simplices. */
|
||||
virtual const Array<unsigned int> &GetGSLIBElem() const { return gsl_elem; }
|
||||
/// Return reference coordinates in [-1,1] (internal range in GSLIB) for each
|
||||
/// point found by FindPoints.
|
||||
/** @brief Return reference coordinates in [-1,1] (internal range in GSLIB)
|
||||
* for each point found by FindPoints. */
|
||||
virtual const Vector &GetGSLIBReferencePosition() const { return gsl_ref; }
|
||||
|
||||
/// Get array of indices of not-found points.
|
||||
@@ -395,7 +549,7 @@ public:
|
||||
|
||||
/// Return the axis-aligned bounding boxes (AABB) computed during \ref Setup.
|
||||
/// The size of the returned vector is (nel x nverts x dim), where nel is the
|
||||
/// number of elements (after splitting for simplcies), nverts is number of
|
||||
/// number of elements (after splitting for simplicies), nverts is number of
|
||||
/// vertices (4 in 2D, 8 in 3D), and dim is the spatial dimension.
|
||||
void GetAxisAlignedBoundingBoxes(Vector &aabb) const;
|
||||
|
||||
@@ -409,6 +563,18 @@ public:
|
||||
/// \p obbV, a vector of size (nel x nverts x dim) .
|
||||
void GetOrientedBoundingBoxes(DenseTensor &obbA, Vector &obbC,
|
||||
Vector &obbV) const;
|
||||
|
||||
/** @brief Return the bounding boxes as a mesh on rank 0.
|
||||
*
|
||||
* @param[in] type Bounding-box type: 0 - AABB, 1 - OBB.
|
||||
*
|
||||
* @return On rank 0, returns a newly allocated mesh containing the
|
||||
* bounding boxes. The caller owns the returned pointer and is responsible
|
||||
* for deleting it. On other ranks, returns nullptr.
|
||||
*/
|
||||
Mesh *GetBoundingBoxMesh(int type);
|
||||
|
||||
virtual const Vector &GetGLLMesh() const { return gsl_mesh; }
|
||||
};
|
||||
|
||||
/** \brief OversetFindPointsGSLIB enables use of findpts for arbitrary number of
|
||||
@@ -536,6 +702,116 @@ public:
|
||||
void GS(Vector &senddata, GSOp op);
|
||||
};
|
||||
|
||||
#if defined(MFEM_USE_MPI)
|
||||
/** \brief Class to map a point in physical space to candidate ranks.
|
||||
*
|
||||
* This class builds a Cartesian-aligned tensor grid that covers the entire
|
||||
* domain and precomputes which ranks have elements intersecting each
|
||||
* grid cell. Given a point in physical space, the grid cell containing
|
||||
* the point is determined, and the list of candidate ranks whose
|
||||
* elements intersect that cell is returned. This yields a fast, conservative
|
||||
* point-to-rank candidate query. This is used internally by FindPointsGSLIB
|
||||
* to speed up point searches in parallel.
|
||||
*
|
||||
* See Mittal et al., "General Field Evaluation in High-Order Meshes on GPUs".
|
||||
* (2025). Computers & Fluids. for technical details.
|
||||
*
|
||||
*/
|
||||
class GlobalBBoxTensorGridMap
|
||||
{
|
||||
private:
|
||||
struct gslib::crystal *cr = nullptr; // gslib's internal data
|
||||
struct gslib::comm *gsl_comm = nullptr; // gslib's internal data
|
||||
int sdim, n_local_cells, num_procs;
|
||||
Array<int> gmap_n;
|
||||
Vector gmap_bnd_min, gmap_bnd_max;
|
||||
Vector gmap_fac;
|
||||
Array<int> ggrid_map;
|
||||
|
||||
void SetupCrystal(const MPI_Comm &comm);
|
||||
public:
|
||||
/// Constructor for a given mesh and number of tensor grid divisions
|
||||
GlobalBBoxTensorGridMap(ParMesh &pmesh, int nx);
|
||||
|
||||
/** @brief Constructor for given element bounds and spatial dimension.
|
||||
*
|
||||
* @details This constructor must be called collectively on \a comm.
|
||||
* Supports spatial dimensions 1, 2, and 3, and accepts nel == 0 on a rank.
|
||||
*
|
||||
* Assumes elmin, elmax Ordering::byNodes:
|
||||
* elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}]
|
||||
* elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}]
|
||||
* Note elmin, elmax can be obtained using GridFunction::GetElementBounds()
|
||||
*
|
||||
* When by_max_size=false, n gives the number of tensor-grid divisions in
|
||||
* each direction. When by_max_size=true, n is a per-rank size hint used to
|
||||
* derive a uniform global resolution. The communicator-wide sum of n is
|
||||
* converted to nx = ceil(pow(sum(n), 1./sdim)) in each direction, so n is
|
||||
* not a hard cap on ggrid_map.Size().
|
||||
*/
|
||||
GlobalBBoxTensorGridMap(const MPI_Comm &comm, Vector &elmin,
|
||||
Vector &elmax, int nel, int sdim, int n,
|
||||
bool by_max_size);
|
||||
|
||||
/** @brief Constructor for given element bounds, spatial dimension, and
|
||||
* tensor-grid divisions in each direction.
|
||||
*
|
||||
* @details This constructor must be called collectively on \a comm.
|
||||
* Supports spatial dimensions 1, 2, and 3, and accepts nel == 0 on a rank.
|
||||
* Requires nx.Size() == sdim and positive entries in nx.
|
||||
*
|
||||
* Assumes elmin, elmax Ordering::byNodes:
|
||||
* elmin -> [x_{0,min},x_{1,min},... ,y_{0,min},y_{1,min},..,z_{nel-1,min}]
|
||||
* elmax -> [x_{0,max},x_{1,max},... ,y_{0,max},y_{1,max},..,z_{nel-1,max}]
|
||||
* Note elmin, elmax can be obtained using GridFunction::GetElementBounds()
|
||||
*/
|
||||
GlobalBBoxTensorGridMap(const MPI_Comm &comm, Vector &elmin,
|
||||
Vector &elmax, int nel, int sdim, Array<int> &nx);
|
||||
|
||||
~GlobalBBoxTensorGridMap();
|
||||
|
||||
/** @brief Get list of procs corresponding to the list of points.
|
||||
*
|
||||
* @details This method must be called collectively on the communicator
|
||||
* used to construct the map. The input points can be ordered byNodes:
|
||||
* (XXX...,YYY...,ZZZ) or byVDIM: (XYZ,XYZ,...), as specified by
|
||||
* \a ordering.
|
||||
*
|
||||
* The output map contains one entry for each input point, keyed by the
|
||||
* point's local index in \a xyz. Points with no candidate ranks, including
|
||||
* points outside the global bounding box, have an empty list of candidate
|
||||
* ranks.
|
||||
*/
|
||||
void MapPointsToProcs(Vector &xyz, int ordering,
|
||||
std::map<int, std::vector<int>> &pt_to_procs) const;
|
||||
|
||||
// Some getters
|
||||
const Array<int> &GetGridMap() const { return ggrid_map; }
|
||||
const Vector &GetGridFac() const { return gmap_fac; }
|
||||
const Vector &GetGridMin() const { return gmap_bnd_min; }
|
||||
const Vector &GetGridMax() const { return gmap_bnd_max; }
|
||||
const Array<int> &GetGridN() const { return gmap_n; }
|
||||
|
||||
private:
|
||||
/// Setup the map given element bounds and number of tensor grid divisions.
|
||||
void Setup(const MPI_Comm &comm, Vector &elmin, Vector &elmax,
|
||||
int nel, Array<int> &nx);
|
||||
|
||||
/// Get global hash cell index for a given point.
|
||||
int GetGlobalGridCellFromPoint(Vector &xyz) const;
|
||||
|
||||
/** @brief Get owning proc and local index on that proc for given global
|
||||
* grid cell index. */
|
||||
void GlobalGridCellToProcAndLocalIndex(int i, int &proc, int &idx) const;
|
||||
|
||||
/// Map a point to proc and local index of the corresponding grid cell
|
||||
void GetProcAndLocalIndexFromPoint(Vector &xyz, int &proc, int &idx) const;
|
||||
|
||||
/// Given local cell index, return list of procs saved in the map
|
||||
Array<int> MapCellToProcs(int l_idx) const;
|
||||
};
|
||||
#endif // MFEM_USE_MPI
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif // MFEM_USE_GSLIB
|
||||
|
||||
@@ -562,7 +562,7 @@ newton_area_fin:
|
||||
int f = flags >> (2 * dd) & 3u;
|
||||
res->r[dd] = f == 0 ? r0[dd] + dr[dd] : (f == 1 ? -1 : 1);
|
||||
}
|
||||
res->flags = flags | (p->flags << 5);
|
||||
res->flags = flags | ((p->flags & FLAG_MASK) << 5);
|
||||
}
|
||||
|
||||
// Full Newton solve on the face. One of r/s/t is constrained.
|
||||
@@ -635,7 +635,8 @@ newton_edge_fin:
|
||||
res->r[de] = nr;
|
||||
res->r[dn]=p->r[dn];
|
||||
res->dist2p = -v;
|
||||
res->flags = flags | new_flags | (p->flags << 5);
|
||||
res->flags = flags | new_flags | ((p->flags & FLAG_MASK) << 5);
|
||||
#undef EVAL
|
||||
}
|
||||
|
||||
// Find closest mesh node to the sought point.
|
||||
@@ -714,7 +715,6 @@ static void FindPointsLocal2D_Kernel(const int npt,
|
||||
const double *lagcoeff,
|
||||
const int pN = 0)
|
||||
{
|
||||
#define MAX_CONST(a, b) (((a) > (b)) ? (a) : (b))
|
||||
const int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
const int D1D = T_D1D ? T_D1D : pN;
|
||||
const int p_NE = D1D*D1D;
|
||||
@@ -729,7 +729,7 @@ static void FindPointsLocal2D_Kernel(const int npt,
|
||||
// 3D1D for seed, 10D1D+6 for area, 3D1D+9 for edge
|
||||
constexpr int size1 = 10*MD1 + 6;
|
||||
constexpr int size2 = MD1*4; // edge constraints
|
||||
constexpr int size3 = MD1*MD1*MD1*DIM; // local element coordinates
|
||||
constexpr int size3 = MD1*MD1*DIM; // local element coordinates
|
||||
|
||||
MFEM_SHARED double r_workspace[size1];
|
||||
MFEM_SHARED findptsElementPoint_t el_pts[2];
|
||||
@@ -1162,9 +1162,9 @@ void FindPointsGSLIB::FindPointsLocal2(const Vector &point_pos,
|
||||
auto pgslm = gsl_mesh.Read();
|
||||
auto pwt = DEV.wtend.Read();
|
||||
auto pbb = DEV.bb.Read();
|
||||
auto plhm = DEV.loc_hash_min.Read();
|
||||
auto plhf = DEV.loc_hash_fac.Read();
|
||||
auto plho = DEV.loc_hash_offset.ReadWrite();
|
||||
auto plhm = DEV.lh_min.Read();
|
||||
auto plhf = DEV.lh_fac.Read();
|
||||
auto plho = DEV.lh_offset.ReadWrite();
|
||||
auto pcode = code.Write();
|
||||
auto pelem = elem.Write();
|
||||
auto pref = ref.Write();
|
||||
@@ -1177,30 +1177,32 @@ void FindPointsGSLIB::FindPointsLocal2(const Vector &point_pos,
|
||||
case 2:
|
||||
return FindPointsLocal2D_Kernel<2>(
|
||||
npt, DEV.newt_tol, pp, point_pos_ordering, pgslm, NE_split_total, pwt,
|
||||
pbb, DEV.h_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pbb, DEV.lh_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pgll1d, plc);
|
||||
case 3:
|
||||
return FindPointsLocal2D_Kernel<3>(
|
||||
npt, DEV.newt_tol, pp, point_pos_ordering, pgslm, NE_split_total, pwt,
|
||||
pbb, DEV.h_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pbb, DEV.lh_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pgll1d, plc);
|
||||
case 4:
|
||||
return FindPointsLocal2D_Kernel<4>(
|
||||
npt, DEV.newt_tol, pp, point_pos_ordering, pgslm, NE_split_total, pwt,
|
||||
pbb, DEV.h_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pbb, DEV.lh_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pgll1d, plc);
|
||||
case 5:
|
||||
return FindPointsLocal2D_Kernel<5>(
|
||||
npt, DEV.newt_tol, pp, point_pos_ordering, pgslm, NE_split_total, pwt,
|
||||
pbb, DEV.h_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pbb, DEV.lh_nx, plhm, plhf, plho, pcode, pelem, pref, pdist,
|
||||
pgll1d, plc);
|
||||
default:
|
||||
return FindPointsLocal2D_Kernel(npt, DEV.newt_tol, pp, point_pos_ordering,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.h_nx,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.lh_nx,
|
||||
plhm, plhf, plho, pcode, pelem,
|
||||
pref, pdist, pgll1d, plc, DEV.dof1d);
|
||||
}
|
||||
}
|
||||
#undef DIM2
|
||||
#undef DIM
|
||||
#undef CODE_INTERNAL
|
||||
#undef CODE_BORDER
|
||||
#undef CODE_NOT_FOUND
|
||||
|
||||
@@ -706,7 +706,7 @@ newton_vol_fin:
|
||||
int f = flags >> (2*dd) & 3u;
|
||||
res->r[dd] = f == 0 ? r0[dd]+dr[dd] : (f == 1 ? -1 : 1);
|
||||
}
|
||||
res->flags = flags | (p->flags << 7);
|
||||
res->flags = flags | ((p->flags & FLAG_MASK) << 7);
|
||||
}
|
||||
|
||||
// Full Newton solve on the face. One of r/s/t is constrained.
|
||||
@@ -889,7 +889,7 @@ newton_face_fin:
|
||||
res->r[dn] = p->r[dn];
|
||||
res->r[d1] = r[0];
|
||||
res->r[d2] = r[1];
|
||||
res->flags = new_flags | (p->flags << 7);
|
||||
res->flags = new_flags | ((p->flags & FLAG_MASK) << 7);
|
||||
}
|
||||
|
||||
// Full Newton solve on the edge. Two of r/s/t are constrained.
|
||||
@@ -973,7 +973,8 @@ newton_edge_fin:
|
||||
res->r[dn1] = p->r[dn1];
|
||||
res->r[dn2] = p->r[dn2];
|
||||
res->dist2p = -v;
|
||||
res->flags = flags | new_flags | (p->flags << 7);
|
||||
res->flags = flags | new_flags | ((p->flags & FLAG_MASK) << 7);
|
||||
#undef EVAL
|
||||
}
|
||||
|
||||
// Find closest mesh node to the sought point.
|
||||
@@ -1252,7 +1253,6 @@ static void FindPointsLocal3DKernel(const int npt,
|
||||
case 0: // findpt_vol
|
||||
{
|
||||
double *wtr = r_workspace_ptr;
|
||||
|
||||
double *resid = wtr+6*D1D;
|
||||
double *jac = resid+3;
|
||||
double *resid_temp = jac+9;
|
||||
@@ -1503,7 +1503,7 @@ static void FindPointsLocal3DKernel(const int npt,
|
||||
// Hes_T is transposed version (i.e. in col major)
|
||||
// n1*[2, 1, 1, 0, 0]
|
||||
// j==1 => wt_j = wt+n1
|
||||
double *wt_j = wt+D1D*(2-(row+1) / 2);
|
||||
double *wt_j = wt+D1D*(2 - (row+1)/2);
|
||||
const double *x = e_x[row+1][d];
|
||||
hes_T[j] = 0.0;
|
||||
for (int k = 0; k < D1D; ++k)
|
||||
@@ -1522,7 +1522,6 @@ static void FindPointsLocal3DKernel(const int npt,
|
||||
hes[j] += resid[d]*hes_T[j*3+d];
|
||||
}
|
||||
}
|
||||
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(l,x,1)
|
||||
@@ -1780,6 +1779,7 @@ static void FindPointsLocal3DKernel(const int npt,
|
||||
} //findpts_local
|
||||
} //elp
|
||||
});
|
||||
#undef MAXC
|
||||
}
|
||||
|
||||
void FindPointsGSLIB::FindPointsLocal3(const Vector &point_pos,
|
||||
@@ -1796,9 +1796,9 @@ void FindPointsGSLIB::FindPointsLocal3(const Vector &point_pos,
|
||||
auto pgslm = gsl_mesh.Read();
|
||||
auto pwt = DEV.wtend.Read();
|
||||
auto pbb = DEV.bb.Read();
|
||||
auto plhm = DEV.loc_hash_min.Read();
|
||||
auto plhf = DEV.loc_hash_fac.Read();
|
||||
auto plho = DEV.loc_hash_offset.ReadWrite();
|
||||
auto plhm = DEV.lh_min.Read();
|
||||
auto plhf = DEV.lh_fac.Read();
|
||||
auto plho = DEV.lh_offset.ReadWrite();
|
||||
auto pcode = code.Write();
|
||||
auto pelem = elem.Write();
|
||||
auto pref = ref.Write();
|
||||
@@ -1809,31 +1809,31 @@ void FindPointsGSLIB::FindPointsLocal3(const Vector &point_pos,
|
||||
{
|
||||
case 2:
|
||||
FindPointsLocal3DKernel<2>(npt, DEV.newt_tol, pp, point_pos_ordering,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.h_nx, plhm,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.lh_nx, plhm,
|
||||
plhf, plho, pcode, pelem, pref, pdist, pgll1d,
|
||||
plc);
|
||||
break;
|
||||
case 3:
|
||||
FindPointsLocal3DKernel<3>(npt, DEV.newt_tol, pp, point_pos_ordering,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.h_nx, plhm,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.lh_nx, plhm,
|
||||
plhf, plho, pcode, pelem, pref, pdist, pgll1d,
|
||||
plc);
|
||||
break;
|
||||
case 4:
|
||||
FindPointsLocal3DKernel<4>(npt, DEV.newt_tol, pp, point_pos_ordering,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.h_nx, plhm,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.lh_nx, plhm,
|
||||
plhf, plho, pcode, pelem, pref, pdist, pgll1d,
|
||||
plc);
|
||||
break;
|
||||
case 5:
|
||||
FindPointsLocal3DKernel<5>(npt, DEV.newt_tol, pp, point_pos_ordering,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.h_nx, plhm,
|
||||
pgslm, NE_split_total, pwt, pbb, DEV.lh_nx, plhm,
|
||||
plhf, plho, pcode, pelem, pref, pdist, pgll1d,
|
||||
plc);
|
||||
break;
|
||||
default:
|
||||
FindPointsLocal3DKernel(npt, DEV.newt_tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.h_nx, plhm, plhf,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc,
|
||||
DEV.dof1d);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,725 @@
|
||||
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
|
||||
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
|
||||
// LICENSE and NOTICE for details. LLNL-CODE-806117.
|
||||
//
|
||||
// This file is part of the MFEM library. For more information and source code
|
||||
// availability visit https://mfem.org.
|
||||
//
|
||||
// MFEM is free software; you can redistribute it and/or modify it under the
|
||||
// terms of the BSD-3 license. We welcome feedback and contributions, see file
|
||||
// CONTRIBUTING.md for details.
|
||||
|
||||
#include "../gslib.hpp"
|
||||
#include "../../general/forall.hpp"
|
||||
|
||||
#ifdef MFEM_USE_GSLIB
|
||||
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
#include "gslib.h"
|
||||
#ifndef GSLIB_RELEASE_VERSION //gslib v1.0.7
|
||||
#define GSLIB_RELEASE_VERSION 10007
|
||||
#endif
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
#if GSLIB_RELEASE_VERSION >= 10009
|
||||
#define CODE_INTERNAL 0
|
||||
#define CODE_BORDER 1
|
||||
#define CODE_NOT_FOUND 2
|
||||
#define sDIM 2
|
||||
#define sDIM2 4
|
||||
#define rDIM 1
|
||||
|
||||
struct findptsElementPoint_t
|
||||
{
|
||||
double x[sDIM], r, oldr, dist2, dist2p, tr;
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct findptsElementGEdge_t
|
||||
{
|
||||
double *x[sDIM];
|
||||
};
|
||||
|
||||
struct findptsElementGPT_t
|
||||
{
|
||||
double x[sDIM], jac[sDIM*rDIM], hes[sDIM*rDIM];
|
||||
};
|
||||
|
||||
struct dbl_range_t
|
||||
{
|
||||
double min, max;
|
||||
};
|
||||
|
||||
struct obbox_t
|
||||
{
|
||||
double c0[sDIM], A[sDIM*sDIM];
|
||||
dbl_range_t x[sDIM];
|
||||
};
|
||||
|
||||
struct findptsLocalHashData_t
|
||||
{
|
||||
int hash_n;
|
||||
dbl_range_t bnd[sDIM];
|
||||
double fac[sDIM];
|
||||
unsigned int *offset;
|
||||
};
|
||||
|
||||
static MFEM_HOST_DEVICE inline void lag_eval_second_der(double *p0, double x,
|
||||
int i, const double *z,
|
||||
const double *lCoeff,
|
||||
int pN)
|
||||
{
|
||||
double u0 = 1, u1 = 0, u2 = 0;
|
||||
for (int j = 0; j < pN; ++j)
|
||||
{
|
||||
if (i != j)
|
||||
{
|
||||
double d_j = 2 * (x-z[j]);
|
||||
u2 = d_j * u2 + u1;
|
||||
u1 = d_j * u1 + u0;
|
||||
u0 = d_j * u0;
|
||||
}
|
||||
}
|
||||
double *p1 = p0 + pN, *p2 = p0 + 2 * pN;
|
||||
p0[i] = lCoeff[i] * u0;
|
||||
p1[i] = 2.0 * lCoeff[i] * u1;
|
||||
p2[i] = 8.0 * lCoeff[i] * u2;
|
||||
}
|
||||
|
||||
/* positive when possibly inside */
|
||||
static MFEM_HOST_DEVICE inline double obbox_axis_test(const obbox_t *const b,
|
||||
const double x[sDIM])
|
||||
{
|
||||
double b_d;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
b_d = (x[d] - b->x[d].min) * (b->x[d].max - x[d]);
|
||||
if (b_d < 0) // if outside in any dimension
|
||||
{
|
||||
return b_d;
|
||||
}
|
||||
}
|
||||
return b_d; // only positive if inside
|
||||
}
|
||||
|
||||
/* positive when given point is possibly inside given obbox b */
|
||||
static MFEM_HOST_DEVICE inline double obbox_test(const obbox_t *const b,
|
||||
const double x[sDIM])
|
||||
{
|
||||
const double bxyz = obbox_axis_test(b,x);
|
||||
if (bxyz<0) // test if point is in AABB
|
||||
{
|
||||
return bxyz;
|
||||
}
|
||||
else // test OBB only if inside AABB
|
||||
{
|
||||
double dxyz[sDIM];
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
dxyz[d] = x[d] - b->c0[d];
|
||||
}
|
||||
double test = 1;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
double rst = 0;
|
||||
for (int e=0; e<sDIM; ++e)
|
||||
{
|
||||
rst += b->A[d*2 + e] * dxyz[e];
|
||||
}
|
||||
double brst = (rst+1)*(1-rst);
|
||||
test = test<0 ? test : brst;
|
||||
}
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hash index in the hash table to the elements that possibly contain the point x */
|
||||
static MFEM_HOST_DEVICE inline int hash_index(const findptsLocalHashData_t *p,
|
||||
const double x[2])
|
||||
{
|
||||
const int n = p->hash_n;
|
||||
int sum = 0;
|
||||
for (int d=sDIM-1; d>=0; --d)
|
||||
{
|
||||
sum *= n;
|
||||
int i = (int)floor((x[d] - p->bnd[d].min) * p->fac[d]);
|
||||
sum += i<0 ? 0 : (n-1 < i ? n-1 : i);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE inline double l2norm2(const double x[2])
|
||||
{
|
||||
return x[0] * x[0] + x[1] * x[1];
|
||||
}
|
||||
|
||||
/* the bit structure of flags is CRR
|
||||
the C bit --- 1<<2 --- is set when the point is converged
|
||||
RR is 0 = 00b if r is unconstrained,
|
||||
1 = 01b if r is constrained at -1, i.e., rmin
|
||||
2 = 10b if r is constrained at +1, i.e., rmax
|
||||
*/
|
||||
|
||||
#define CONVERGED_FLAG (1u<<2)
|
||||
#define FLAG_MASK 0x07u // = 111b
|
||||
|
||||
/* returns 1 if r direction (the only free direction in 2D) is constrained.
|
||||
returns 1 if either 1st or 2nd bit of flags is set.
|
||||
*/
|
||||
static MFEM_HOST_DEVICE inline int num_constrained(const int flags)
|
||||
{
|
||||
return ((flags | flags>>1) & 1u);
|
||||
}
|
||||
|
||||
/* pi=0, r=-1; pi=1, r=+1 */
|
||||
static MFEM_HOST_DEVICE inline int point_index(const int x)
|
||||
{
|
||||
return ((x>>1) & 1u);
|
||||
}
|
||||
|
||||
/* check reduction in objective against prediction, and adjust
|
||||
trust region radius (p->tr) accordingly;
|
||||
may reject the prior step, returning 1; otherwise returns 0
|
||||
sets out->dist2, out->index, out->x, out->oldr in any event,
|
||||
leaving out->r, out->dr, out->flags to be set when returning 0 */
|
||||
static MFEM_HOST_DEVICE bool reject_prior_step_q(findptsElementPoint_t *out,
|
||||
const double resid[2],
|
||||
const findptsElementPoint_t *p,
|
||||
const double tol)
|
||||
{
|
||||
const double dist2 = l2norm2(resid);
|
||||
const double decr = p->dist2 - dist2;
|
||||
const double pred = p->dist2p;
|
||||
out->x[0] = p->x[0];
|
||||
out->x[1] = p->x[1];
|
||||
out->oldr = p->r;
|
||||
out->dist2 = dist2;
|
||||
if (decr >= 0.01*pred)
|
||||
{
|
||||
if (decr >= 0.9*pred) // very good iteration
|
||||
{
|
||||
out->tr = p->tr*2;
|
||||
}
|
||||
else // somewhat good iteration
|
||||
{
|
||||
out->tr = p->tr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* reject step; note: the point will pass through this routine
|
||||
again, and we set things up here so it gets classed as a
|
||||
"very good iteration" --- this doubles the trust radius,
|
||||
which is why we divide by 4 below */
|
||||
double v0 = fabs(p->r - p->oldr);
|
||||
out->tr = v0/4.0;
|
||||
out->dist2 = p->dist2;
|
||||
out->r = p->oldr;
|
||||
out->flags = p->flags>>3;
|
||||
out->dist2p = -HUGE_VAL;
|
||||
if (pred < dist2*tol)
|
||||
{
|
||||
out->flags |= CONVERGED_FLAG;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE inline void newton_edge( findptsElementPoint_t *const
|
||||
out,
|
||||
const double jac[2],
|
||||
const double rhess,
|
||||
const double resid[2],
|
||||
int flags,
|
||||
const findptsElementPoint_t *const p,
|
||||
const double tol )
|
||||
{
|
||||
const double tr = p->tr;
|
||||
const double A = jac[0] * jac[0] + jac[1] * jac[1] -
|
||||
rhess; // A = J^T J - resid_d H_d
|
||||
const double y = jac[0]*resid[0] + jac[1]*resid[1]; // y = J^T resid
|
||||
|
||||
const double oldr = p->r;
|
||||
double dr, newr, tdr, tnewr, v, tv;
|
||||
int new_flags=0, tnew_flags=0;
|
||||
|
||||
#define EVAL(dr) ( (dr*A - 2*y) * dr )
|
||||
if (A>0)
|
||||
{
|
||||
dr = y/A;
|
||||
if (fabs(dr)<tol)
|
||||
{
|
||||
dr=0.0;
|
||||
newr = oldr;
|
||||
}
|
||||
else
|
||||
{
|
||||
newr = oldr+dr;
|
||||
}
|
||||
|
||||
if (fabs(dr)<tr && fabs(newr)<1)
|
||||
{
|
||||
v = EVAL(dr);
|
||||
goto newton_edge_fin;
|
||||
}
|
||||
}
|
||||
|
||||
if ((newr=oldr-tr) > -1)
|
||||
{
|
||||
dr = -tr;
|
||||
}
|
||||
else
|
||||
{
|
||||
newr = -1, dr = -1-oldr, new_flags = flags|1u;
|
||||
}
|
||||
v = EVAL(dr);
|
||||
|
||||
if ((tnewr=oldr+tr) < 1)
|
||||
{
|
||||
tdr = tr;
|
||||
}
|
||||
else
|
||||
{
|
||||
tnewr = 1, tdr = 1-oldr, tnew_flags = flags|2u;
|
||||
}
|
||||
tv = EVAL(tdr);
|
||||
|
||||
if (tv<v)
|
||||
{
|
||||
newr = tnewr, dr = tdr, v = tv, new_flags = tnew_flags;
|
||||
}
|
||||
#undef EVAL
|
||||
|
||||
newton_edge_fin:
|
||||
// check convergence by testing if change in r is less than tol
|
||||
if (fabs(dr)<tol)
|
||||
{
|
||||
new_flags |= CONVERGED_FLAG;
|
||||
}
|
||||
out->r = newr;
|
||||
out->dist2p = -v;
|
||||
out->flags = flags | new_flags | ((p->flags & FLAG_MASK)<<3);
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE void seed_j( const double *elx[sDIM],
|
||||
const double x[sDIM],
|
||||
const double *z,
|
||||
double *dist2,
|
||||
double *r,
|
||||
const int ir,
|
||||
const int pN )
|
||||
{
|
||||
double dx[sDIM];
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
dx[d] = x[d] - elx[d][ir];
|
||||
}
|
||||
dist2[ir] = HUGE_VAL;
|
||||
const double dist2_rs = l2norm2(dx);
|
||||
if (dist2[ir]>dist2_rs)
|
||||
{
|
||||
dist2[ir] = dist2_rs;
|
||||
r[ir] = z[ir];
|
||||
}
|
||||
}
|
||||
|
||||
template<int T_D1D = 0>
|
||||
static void FindPointsEdgeLocal2D_Kernel( const int npt,
|
||||
const double tol,
|
||||
const double dist2tol,
|
||||
const double *x,
|
||||
const int point_pos_ordering,
|
||||
const double *xElemCoord,
|
||||
const int nel,
|
||||
const double *wtend,
|
||||
const double *boxinfo,
|
||||
const int hash_n,
|
||||
const double *hashMin,
|
||||
const double *hashFac,
|
||||
unsigned int *hashOffset,
|
||||
unsigned int *const code_base,
|
||||
unsigned int *const el_base,
|
||||
double *const r_base,
|
||||
double *const dist2_base,
|
||||
const double *gll1D,
|
||||
const double *lagcoeff,
|
||||
const int pN = 0 )
|
||||
{
|
||||
const int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
const int D1D = T_D1D ? T_D1D : pN;
|
||||
const int p_NEL = nel*D1D;
|
||||
MFEM_VERIFY(MD1<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(pN<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(D1D!=0, "Polynomial order not specified.");
|
||||
const int nThreads = D1D*sDIM;
|
||||
|
||||
mfem::forall_2D(npt, nThreads, 1, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
// 2D1D for seed, 3D1D + 7 for edge
|
||||
constexpr int size1 = 3*MD1 + 7;
|
||||
// edge coordinates = D1D*2
|
||||
constexpr int size2 = 2*MD1;
|
||||
// local element coordinates in shared memory
|
||||
constexpr int size3 = MD1*sDIM;
|
||||
|
||||
MFEM_SHARED findptsElementPoint_t el_pts[2];
|
||||
MFEM_SHARED double r_workspace[size1];
|
||||
|
||||
MFEM_SHARED double constraint_workspace[size2];
|
||||
|
||||
MFEM_SHARED double elem_coords[MD1 <= 6 ? size3 : 1];
|
||||
|
||||
double *r_workspace_ptr = r_workspace;
|
||||
findptsElementPoint_t *fpt, *tmp;
|
||||
fpt = el_pts + 0;
|
||||
tmp = el_pts + 1;
|
||||
|
||||
// x and y coord index within point_pos for point i
|
||||
int id_x = point_pos_ordering == 0 ? i : i*sDIM;
|
||||
int id_y = point_pos_ordering == 0 ? i+npt : i*sDIM+1;
|
||||
double x_i[2] = {x[id_x], x[id_y]};
|
||||
|
||||
unsigned int *code_i = code_base + i;
|
||||
double *dist2_i = dist2_base + i;
|
||||
|
||||
//---------------- map_points_to_els --------------------
|
||||
findptsLocalHashData_t hash;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
hash.bnd[d].min = hashMin[d];
|
||||
hash.fac[d] = hashFac[d];
|
||||
}
|
||||
hash.hash_n = hash_n;
|
||||
hash.offset = hashOffset;
|
||||
|
||||
const int hi = hash_index(&hash, x_i);
|
||||
const unsigned int *elp = hash.offset + hash.offset[hi];
|
||||
const unsigned int *const ele = hash.offset + hash.offset[hi+1];
|
||||
*code_i = CODE_NOT_FOUND;
|
||||
*dist2_i = HUGE_VAL;
|
||||
|
||||
for (; elp!=ele; ++elp)
|
||||
{
|
||||
const unsigned int el = *elp;
|
||||
|
||||
obbox_t box;
|
||||
int n_box_ents = 3*sDIM + sDIM2;
|
||||
|
||||
for (int idx = 0; idx < sDIM; ++idx)
|
||||
{
|
||||
box.c0[idx] = boxinfo[n_box_ents*el + idx];
|
||||
box.x[idx].min = boxinfo[n_box_ents*el + sDIM + idx];
|
||||
box.x[idx].max = boxinfo[n_box_ents*el + 2*sDIM + idx];
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < sDIM2; ++idx)
|
||||
{
|
||||
box.A[idx] = boxinfo[n_box_ents*el + 3*sDIM + idx];
|
||||
}
|
||||
|
||||
if (obbox_test(&box,x_i)>=0)
|
||||
{
|
||||
//------------ findpts_local ------------------
|
||||
{
|
||||
if (MD1 <= 6)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,D1D*sDIM)
|
||||
{
|
||||
const int qp = j % D1D;
|
||||
const int d = j / D1D;
|
||||
elem_coords[qp + d*D1D] =
|
||||
xElemCoord[qp + el*D1D + d*p_NEL];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
const double *elx[sDIM];
|
||||
for (int d=0; d<sDIM; d++)
|
||||
{
|
||||
elx[d] = MD1<= 6 ? &elem_coords[d*D1D] :
|
||||
xElemCoord + d*p_NEL + el*D1D;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
//// findpts_el ////
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
fpt->dist2 = HUGE_VAL;
|
||||
fpt->dist2p = 0;
|
||||
fpt->tr = 1;
|
||||
}
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
fpt->x[j] = x_i[j];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
{
|
||||
double *dist2_temp = r_workspace_ptr;
|
||||
double *r_temp = dist2_temp + D1D;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
seed_j(elx, x_i, gll1D, dist2_temp, r_temp, j, D1D);
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
for (int ir=0; ir<D1D; ++ir)
|
||||
{
|
||||
if (dist2_temp[ir]<fpt->dist2)
|
||||
{
|
||||
fpt->dist2 = dist2_temp[ir];
|
||||
fpt->r = r_temp[ir];
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
} //seed done
|
||||
|
||||
// Initialize tmp struct with fpt values before starting Newton iterations
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
tmp->dist2 = HUGE_VAL;
|
||||
tmp->dist2p = 0;
|
||||
tmp->tr = 1;
|
||||
tmp->flags = 0;
|
||||
tmp->r = fpt->r;
|
||||
}
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
tmp->x[j] = fpt->x[j];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
|
||||
for (int step=0; step<50; step++)
|
||||
{
|
||||
int nc = num_constrained(tmp->flags & FLAG_MASK);
|
||||
switch (nc)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
double *wt = r_workspace_ptr;
|
||||
double *resid = wt + 3*D1D;
|
||||
double *jac = resid + sDIM;
|
||||
double *hess = jac + sDIM*rDIM;
|
||||
|
||||
findptsElementGEdge_t edge;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
edge.x[d] = constraint_workspace + d*D1D;
|
||||
edge.x[d][j] = elx[d][j];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// compute basis function info upto 2nd derivative
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
lag_eval_second_der(wt, tmp->r, j, gll1D,
|
||||
lagcoeff, D1D);
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
resid[j] = tmp->x[j];
|
||||
jac[j] = 0.0;
|
||||
hess[j] = 0.0;
|
||||
for (int k=0; k<D1D; ++k)
|
||||
{
|
||||
resid[j] -= wt[ k]*edge.x[j][k];
|
||||
jac[j] += wt[D1D+k]*edge.x[j][k];
|
||||
hess[j] += wt[2*D1D+k]*edge.x[j][k];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
hess[2] = resid[0]*hess[0] + resid[1]*hess[1];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
if (!reject_prior_step_q(fpt, resid, tmp, tol))
|
||||
{
|
||||
newton_edge(fpt, jac, hess[2], resid,
|
||||
tmp->flags & FLAG_MASK, tmp, tol);
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
break;
|
||||
}
|
||||
case 1: // r is constrained to either -1 or 1
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
const int pi = point_index(tmp->flags &
|
||||
FLAG_MASK);
|
||||
const double *wt = wtend + pi*3*D1D;
|
||||
findptsElementGPT_t gpt;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
gpt.x[d] = elx[d][pi*(D1D-1)];
|
||||
gpt.jac[d] = 0.0;
|
||||
gpt.hes[d] = 0.0;
|
||||
for (int k=0; k<D1D; ++k)
|
||||
{
|
||||
gpt.jac[d] += wt[D1D +k]*elx[d][k];
|
||||
gpt.hes[d] += wt[2*D1D+k]*elx[d][k];
|
||||
}
|
||||
}
|
||||
|
||||
const double *const pt_x = gpt.x;
|
||||
const double *const jac = gpt.jac;
|
||||
const double *const hes = gpt.hes;
|
||||
double resid[sDIM], steep, sr;
|
||||
resid[0] = fpt->x[0] - pt_x[0];
|
||||
resid[1] = fpt->x[1] - pt_x[1];
|
||||
steep = jac[0]*resid[0] + jac[1]*resid[1];
|
||||
sr = steep*tmp->r;
|
||||
if ( !reject_prior_step_q(fpt, resid, tmp, tol) )
|
||||
{
|
||||
if (sr<0)
|
||||
{
|
||||
const double rhess = resid[0]*hes[0] +
|
||||
resid[1]*hes[1];
|
||||
newton_edge(fpt, jac, rhess,
|
||||
resid, 0, tmp, tol);
|
||||
}
|
||||
else // sr==0
|
||||
{
|
||||
fpt->r = tmp->r;
|
||||
fpt->dist2p = 0;
|
||||
fpt->flags = tmp->flags | CONVERGED_FLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
break;
|
||||
} // case 1
|
||||
} //switch
|
||||
if (fpt->flags & CONVERGED_FLAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
*tmp = *fpt;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
} //for int step<50
|
||||
} //findpts_el
|
||||
|
||||
bool converged_internal =
|
||||
((fpt->flags&FLAG_MASK) == CONVERGED_FLAG) &&
|
||||
(fpt->dist2<dist2tol);
|
||||
|
||||
if (*code_i == CODE_NOT_FOUND || converged_internal ||
|
||||
fpt->dist2 < *dist2_i)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
*(el_base+i) = el;
|
||||
*code_i = converged_internal ? CODE_INTERNAL : CODE_BORDER;
|
||||
*dist2_i = fpt->dist2;
|
||||
*(r_base+i) = fpt->r;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
if (converged_internal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //findpts_local
|
||||
} //obbox_test
|
||||
} //elp
|
||||
});
|
||||
}
|
||||
|
||||
void FindPointsGSLIB::FindPointsEdgeLocal2( const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &code,
|
||||
Array<unsigned int> &elem,
|
||||
Vector &ref,
|
||||
Vector &dist,
|
||||
int npt )
|
||||
{
|
||||
if (npt==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MFEM_VERIFY(dim==1 && spacedim==2,"Function for 2D edges only");
|
||||
bool use_dev = point_pos.UseDevice();
|
||||
auto pp = point_pos.Read(use_dev);
|
||||
auto pgslm = gsl_mesh.Read(use_dev);
|
||||
auto pwt = DEV.wtend.Read(use_dev);
|
||||
auto pbb = DEV.bb.Read(use_dev);
|
||||
auto plhm = DEV.lh_min.Read(use_dev);
|
||||
auto plhf = DEV.lh_fac.Read(use_dev);
|
||||
auto plho = DEV.lh_offset.ReadWrite(use_dev);
|
||||
auto pcode = code.Write(use_dev);
|
||||
auto pelem = elem.Write(use_dev);
|
||||
auto pref = ref.Write(use_dev);
|
||||
auto pdist = dist.Write(use_dev);
|
||||
auto pgll1d = DEV.gll1d.ReadWrite(use_dev);
|
||||
auto plc = DEV.lagcoeff.Read(use_dev);
|
||||
double dist2tol = DEV.surf_dist_tol;
|
||||
switch (DEV.dof1d)
|
||||
{
|
||||
case 2:
|
||||
return FindPointsEdgeLocal2D_Kernel<2>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
case 3:
|
||||
return FindPointsEdgeLocal2D_Kernel<3>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
case 4:
|
||||
return FindPointsEdgeLocal2D_Kernel<4>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
default:
|
||||
return FindPointsEdgeLocal2D_Kernel(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc, DEV.dof1d);
|
||||
}
|
||||
}
|
||||
#undef sDIM
|
||||
#undef rDIM
|
||||
#undef sDIM2
|
||||
#undef CODE_INTERNAL
|
||||
#undef CODE_BORDER
|
||||
#undef CODE_NOT_FOUND
|
||||
#else
|
||||
void FindPointsGSLIB::FindPointsEdgeLocal2( const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &code,
|
||||
Array<unsigned int> &elem,
|
||||
Vector &ref,
|
||||
Vector &dist,
|
||||
int npt ) {} ;
|
||||
#endif
|
||||
} // namespace mfem
|
||||
|
||||
#endif //ifdef MFEM_USE_GSLIB
|
||||
@@ -0,0 +1,733 @@
|
||||
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
|
||||
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
|
||||
// LICENSE and NOTICE for details. LLNL-CODE-806117.
|
||||
//
|
||||
// This file is part of the MFEM library. For more information and source code
|
||||
// availability visit https://mfem.org.
|
||||
//
|
||||
// MFEM is free software; you can redistribute it and/or modify it under the
|
||||
// terms of the BSD-3 license. We welcome feedback and contributions, see file
|
||||
// CONTRIBUTING.md for details.
|
||||
|
||||
#include "../gslib.hpp"
|
||||
#include "../../general/forall.hpp"
|
||||
|
||||
#ifdef MFEM_USE_GSLIB
|
||||
|
||||
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
#include "gslib.h"
|
||||
#ifndef GSLIB_RELEASE_VERSION //gslib v1.0.7
|
||||
#define GSLIB_RELEASE_VERSION 10007
|
||||
#endif
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
#if GSLIB_RELEASE_VERSION >= 10009
|
||||
#define CODE_INTERNAL 0
|
||||
#define CODE_BORDER 1
|
||||
#define CODE_NOT_FOUND 2
|
||||
#define sDIM 3
|
||||
#define rDIM 1
|
||||
#define sDIM2 (sDIM*sDIM)
|
||||
#define rDIM2 (rDIM*rDIM)
|
||||
|
||||
struct findptsElementPoint_t
|
||||
{
|
||||
double x[sDIM], r, oldr, dist2, dist2p, tr;
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct findptsElementGEdge_t
|
||||
{
|
||||
double *x[sDIM], *dxdn[sDIM], *d2xdn[sDIM];
|
||||
};
|
||||
|
||||
struct findptsElementGPT_t
|
||||
{
|
||||
double x[sDIM], jac[sDIM], hes[sDIM*(1+1)];
|
||||
};
|
||||
|
||||
struct dbl_range_t
|
||||
{
|
||||
double min, max;
|
||||
};
|
||||
|
||||
struct obbox_t
|
||||
{
|
||||
double c0[sDIM], A[sDIM*sDIM];
|
||||
dbl_range_t x[sDIM];
|
||||
};
|
||||
|
||||
struct findptsLocalHashData_t
|
||||
{
|
||||
int hash_n;
|
||||
dbl_range_t bnd[sDIM];
|
||||
double fac[sDIM];
|
||||
unsigned int *offset;
|
||||
};
|
||||
|
||||
static MFEM_HOST_DEVICE inline void lag_eval_second_der(double *p0, double x,
|
||||
int i, const double *z,
|
||||
const double *lCoeff,
|
||||
int pN)
|
||||
{
|
||||
double u0 = 1, u1 = 0, u2 = 0;
|
||||
for (int j=0; j<pN; ++j)
|
||||
{
|
||||
if (i!=j)
|
||||
{
|
||||
double d_j = 2 * (x-z[j]);
|
||||
u2 = d_j * u2 + u1;
|
||||
u1 = d_j * u1 + u0;
|
||||
u0 = d_j * u0;
|
||||
}
|
||||
}
|
||||
double *p1 = p0 + pN, *p2 = p0 + 2 * pN;
|
||||
p0[i] = lCoeff[i] * u0;
|
||||
p1[i] = 2.0 * lCoeff[i] * u1;
|
||||
p2[i] = 8.0 * lCoeff[i] * u2;
|
||||
}
|
||||
|
||||
/* positive when possibly inside */
|
||||
static MFEM_HOST_DEVICE inline double obbox_axis_test(const obbox_t *const b,
|
||||
const double x[sDIM])
|
||||
{
|
||||
double b_d;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
b_d = (x[d] - b->x[d].min) * (b->x[d].max - x[d]);
|
||||
if (b_d < 0) // if outside in any dimension
|
||||
{
|
||||
return b_d;
|
||||
}
|
||||
}
|
||||
return b_d; // only positive if inside in all dimensions
|
||||
}
|
||||
|
||||
/* positive when possibly inside */
|
||||
static MFEM_HOST_DEVICE inline double obbox_test(const obbox_t *const b,
|
||||
const double x[sDIM])
|
||||
{
|
||||
const double bxyz = obbox_axis_test(b, x);
|
||||
if (bxyz<0)
|
||||
{
|
||||
return bxyz;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dxyz[3];
|
||||
// dxyz: distance of the point from the center of the OBB
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
dxyz[d] = x[d] - b->c0[d];
|
||||
}
|
||||
// transform dxyz to the local coordinate system of the OBB,
|
||||
// and check if the point is inside the OBB [-1,1]^sDIM
|
||||
double test = 1;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
double rst = 0;
|
||||
for (int e=0; e<sDIM; ++e)
|
||||
{
|
||||
rst += b->A[d*sDIM + e] * dxyz[e];
|
||||
}
|
||||
double brst = (rst+1)*(1-rst);
|
||||
test = test<0 ? test : brst;
|
||||
}
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hash index in the hash table to the elements that possibly contain the point x */
|
||||
static MFEM_HOST_DEVICE inline int hash_index(const findptsLocalHashData_t *p,
|
||||
const double x[sDIM])
|
||||
{
|
||||
const int n = p->hash_n;
|
||||
int sum = 0;
|
||||
for (int d=sDIM-1; d>=0; --d)
|
||||
{
|
||||
sum *= n;
|
||||
int i = (int)floor((x[d] - p->bnd[d].min) * p->fac[d]);
|
||||
sum += i<0 ? 0 : (n-1 < i ? n-1 : i);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
static MFEM_HOST_DEVICE inline double norm2(const double x[sDIM])
|
||||
{
|
||||
return ( x[0]*x[0] + x[1]*x[1] + x[2]*x[2] );
|
||||
}
|
||||
|
||||
/* the bit structure of flags is CRR
|
||||
the C bit --- 1<<2 --- is set when the point is converged
|
||||
RR is 0 = 00b if r is unconstrained,
|
||||
1 = 01b if r is constrained at -1, i.e., rmin
|
||||
2 = 10b if r is constrained at +1, i.e., rmax
|
||||
*/
|
||||
#define CONVERGED_FLAG (1u<<2)
|
||||
#define FLAG_MASK 0x07u
|
||||
|
||||
/* returns the number of constrained reference coordinates, max 2
|
||||
*/
|
||||
static MFEM_HOST_DEVICE inline int num_constrained(const int flags)
|
||||
{
|
||||
const int y = (flags | flags>>1);
|
||||
return (y & 1u) + (y>>2 & 1u);
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE inline int point_index(const int x)
|
||||
{
|
||||
return ((x>>1)&1u) | ((x>>2)&2u);
|
||||
}
|
||||
|
||||
/* check reduction in objective against prediction, and adjust
|
||||
trust region radius (p->tr) accordingly;
|
||||
may reject the prior step, returning 1; otherwise returns 0
|
||||
sets out->dist2, out->index, out->x, out->oldr in any event,
|
||||
leaving out->r, out->dr, out->flags to be set when returning 0 */
|
||||
static MFEM_HOST_DEVICE bool reject_prior_step_q(findptsElementPoint_t *out,
|
||||
const double resid[3],
|
||||
const findptsElementPoint_t *p,
|
||||
const double tol)
|
||||
{
|
||||
const double dist2 = norm2(resid);
|
||||
const double decr = p->dist2 - dist2;
|
||||
const double pred = p->dist2p;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
out->x[d] = p->x[d];
|
||||
}
|
||||
out->oldr = p->r;
|
||||
out->dist2 = dist2;
|
||||
if (decr>=0.01*pred)
|
||||
{
|
||||
if (decr>=0.9*pred) // very good iteration
|
||||
{
|
||||
out->tr = 2*p->tr;
|
||||
}
|
||||
else // good iteration
|
||||
{
|
||||
out->tr = p->tr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else // if the iteration in not good
|
||||
{
|
||||
/* reject step; note: the point will pass through this routine
|
||||
again, and we set things up here so it gets classed as a
|
||||
"very good iteration" --- this doubles the trust radius,
|
||||
which is why we divide by 4 below */
|
||||
double v0 = fabs(p->r - p->oldr);
|
||||
out->tr = v0/4.0;
|
||||
out->dist2 = p->dist2;
|
||||
out->r = p->oldr;
|
||||
out->flags = p->flags>>3;
|
||||
out->dist2p = -HUGE_VAL;
|
||||
if (pred<dist2*tol)
|
||||
{
|
||||
out->flags |= CONVERGED_FLAG;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE inline void newton_edge(findptsElementPoint_t *const
|
||||
out,
|
||||
const double jac[sDIM*rDIM],
|
||||
const double rhes,
|
||||
const double resid[sDIM],
|
||||
int flags,
|
||||
const findptsElementPoint_t *const p,
|
||||
const double tol)
|
||||
{
|
||||
const double tr = p->tr;
|
||||
/* A = J^T J - resid_d H_d */
|
||||
const double A = jac[0]*jac[0]+ jac[1] * jac[1] + jac[2] * jac[2]
|
||||
- rhes;
|
||||
/* y = J^T r */
|
||||
const double y = jac[0]*resid[0] + jac[1]*resid[1] + jac[0+2]*resid[2];
|
||||
|
||||
const double oldr = p->r;
|
||||
double dr, nr, tdr, tnr;
|
||||
double v, tv;
|
||||
int new_flags = 0, tnew_flags = 0;
|
||||
|
||||
#define EVAL(dr) (dr*A - 2*y)*dr
|
||||
|
||||
/* if A is not SPD, quadratic model has no minimum */
|
||||
if (A>0)
|
||||
{
|
||||
dr = y/A;
|
||||
|
||||
if (fabs(dr)<tol)
|
||||
{
|
||||
dr=0.0;
|
||||
nr = oldr;
|
||||
}
|
||||
else
|
||||
{
|
||||
nr = oldr+dr;
|
||||
}
|
||||
if ( fabs(dr)<tr && fabs(nr)<1 )
|
||||
{
|
||||
v = EVAL(dr);
|
||||
goto newton_edge_fin;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (nr=oldr-tr)>-1 )
|
||||
{
|
||||
dr = -tr;
|
||||
}
|
||||
else
|
||||
{
|
||||
nr = -1, dr = -1-oldr, new_flags = flags | 1u;
|
||||
}
|
||||
v = EVAL(dr);
|
||||
|
||||
if ( (tnr = oldr+tr)<1 )
|
||||
{
|
||||
tdr = tr;
|
||||
}
|
||||
else
|
||||
{
|
||||
tnr = 1, tdr = 1-oldr, tnew_flags = flags | 2u;
|
||||
}
|
||||
tv = EVAL(tdr);
|
||||
|
||||
if (tv<v)
|
||||
{
|
||||
nr = tnr, dr = tdr, v = tv, new_flags = tnew_flags;
|
||||
}
|
||||
|
||||
newton_edge_fin:
|
||||
/* check convergence */
|
||||
if ( fabs(dr)<tol )
|
||||
{
|
||||
new_flags |= CONVERGED_FLAG;
|
||||
}
|
||||
out->r = nr;
|
||||
out->dist2p = -v;
|
||||
out->flags = flags | new_flags | ((p->flags & FLAG_MASK)<<3);
|
||||
#undef EVAL
|
||||
}
|
||||
|
||||
static MFEM_HOST_DEVICE void seed_j(const double *elx[sDIM],
|
||||
const double x[sDIM],
|
||||
const double *z,
|
||||
double *dist2,
|
||||
double *r,
|
||||
const int ir,
|
||||
const int pN)
|
||||
{
|
||||
if (ir>=pN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double dx[sDIM];
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
dx[d] = x[d] - elx[d][ir];
|
||||
}
|
||||
dist2[ir] = norm2(dx);;
|
||||
r[ir] = z[ir];
|
||||
}
|
||||
|
||||
template<int T_D1D = 0>
|
||||
static void FindPointsEdgeLocal3D_Kernel(const int npt,
|
||||
const double tol,
|
||||
const double dist2tol,
|
||||
const double *x,
|
||||
const int point_pos_ordering,
|
||||
const double *xElemCoord,
|
||||
const int nel,
|
||||
const double *wtend,
|
||||
const double *boxinfo,
|
||||
const int hash_n,
|
||||
const double *hashMin,
|
||||
const double *hashFac,
|
||||
unsigned int *hashOffset,
|
||||
unsigned int *const code_base,
|
||||
unsigned int *const el_base,
|
||||
double *const r_base,
|
||||
double *const dist2_base,
|
||||
const double *gll1D,
|
||||
const double *lagcoeff,
|
||||
const int pN = 0)
|
||||
{
|
||||
const int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
const int D1D = T_D1D ? T_D1D : pN;
|
||||
const int p_NEL = nel*D1D;
|
||||
MFEM_VERIFY(MD1<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(pN<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(D1D!=0, "Polynomial order not specified.");
|
||||
const int nThreads = D1D*sDIM;
|
||||
|
||||
mfem::forall_2D(npt, nThreads, 1, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
constexpr int size1 = 3*MD1 + 13;
|
||||
constexpr int size2 = 3*MD1;
|
||||
constexpr int size3 = MD1*sDIM;
|
||||
|
||||
MFEM_SHARED findptsElementPoint_t el_pts[2];
|
||||
MFEM_SHARED double r_workspace[size1];
|
||||
|
||||
MFEM_SHARED double constraint_workspace[size2];
|
||||
|
||||
MFEM_SHARED double elem_coords[MD1 <= 6 ? size3 : 1];
|
||||
|
||||
double *r_workspace_ptr = r_workspace;
|
||||
findptsElementPoint_t *fpt, *tmp;
|
||||
fpt = el_pts + 0;
|
||||
tmp = el_pts + 1;
|
||||
|
||||
int id_x = point_pos_ordering==0 ? i : i*sDIM;
|
||||
int id_y = point_pos_ordering==0 ? npt+i : 1+i*sDIM;
|
||||
int id_z = point_pos_ordering==0 ? 2*npt+i : 2+i*sDIM;
|
||||
double x_i[3] = {x[id_x], x[id_y], x[id_z]};
|
||||
|
||||
unsigned int *code_i = code_base + i;
|
||||
double *dist2_i = dist2_base + i;
|
||||
|
||||
//// map_points_to_els ////
|
||||
findptsLocalHashData_t hash;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
hash.bnd[d].min = hashMin[d];
|
||||
hash.fac[d] = hashFac[d];
|
||||
}
|
||||
hash.hash_n = hash_n;
|
||||
hash.offset = hashOffset;
|
||||
|
||||
const unsigned int hi = hash_index(&hash, x_i);
|
||||
const unsigned int *elp = hash.offset + hash.offset[hi];
|
||||
const unsigned int *const ele = hash.offset + hash.offset[hi+1];
|
||||
*code_i = CODE_NOT_FOUND;
|
||||
*dist2_i = HUGE_VAL;
|
||||
|
||||
for (; elp!=ele; ++elp)
|
||||
{
|
||||
const unsigned int el = *elp;
|
||||
obbox_t box;
|
||||
int n_box_ents = 3*sDIM + sDIM2;
|
||||
|
||||
for (int idx = 0; idx < sDIM; ++idx)
|
||||
{
|
||||
box.c0[idx] = boxinfo[n_box_ents*el + idx];
|
||||
box.x[idx].min = boxinfo[n_box_ents*el + sDIM + idx];
|
||||
box.x[idx].max = boxinfo[n_box_ents*el + 2*sDIM + idx];
|
||||
}
|
||||
for (int idx = 0; idx < sDIM2; ++idx)
|
||||
{
|
||||
box.A[idx] = boxinfo[n_box_ents*el + 3*sDIM + idx];
|
||||
}
|
||||
|
||||
if (obbox_test(&box, x_i)>=0)
|
||||
{
|
||||
//// findpts_local ////
|
||||
{
|
||||
if (MD1 <= 6)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,D1D*sDIM)
|
||||
{
|
||||
const int qp = j % D1D;
|
||||
const int d = j / D1D;
|
||||
elem_coords[qp + d*D1D] =
|
||||
xElemCoord[qp + el*D1D + d*p_NEL];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
const double *elx[sDIM];
|
||||
for (int d=0; d<sDIM; d++)
|
||||
{
|
||||
elx[d] = MD1<= 6 ? &elem_coords[d*D1D] :
|
||||
xElemCoord + d*p_NEL + el*D1D;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
//// findpts_el ////
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
fpt->dist2 = HUGE_VAL;
|
||||
fpt->dist2p = 0;
|
||||
fpt->tr = 1.0;
|
||||
}
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
fpt->x[j] = x_i[j];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
//// seed ////
|
||||
{
|
||||
double *dist2_temp = r_workspace_ptr;
|
||||
double *r_temp = dist2_temp + D1D;
|
||||
MFEM_FOREACH_THREAD(j,x,nThreads)
|
||||
{
|
||||
seed_j(elx, x_i, gll1D, dist2_temp, r_temp, j, D1D);
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
fpt->dist2 = HUGE_VAL;
|
||||
for (int ir=0; ir<D1D; ++ir)
|
||||
{
|
||||
if (dist2_temp[ir] < fpt->dist2)
|
||||
{
|
||||
fpt->dist2 = dist2_temp[ir];
|
||||
fpt->r = r_temp[ir];
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
} //seed done
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
tmp->dist2 = HUGE_VAL;
|
||||
tmp->dist2p = 0;
|
||||
tmp->tr = 1;
|
||||
tmp->flags = 0;
|
||||
tmp->r = fpt->r;
|
||||
}
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
tmp->x[j] = fpt->x[j];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
for (int step=0; step<50; step++)
|
||||
{
|
||||
switch (num_constrained(tmp->flags & FLAG_MASK))
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
double *wt = r_workspace_ptr;
|
||||
double *resid = wt + 3*D1D;
|
||||
double *jac = resid + sDIM;
|
||||
double *hess = jac + sDIM*rDIM;
|
||||
|
||||
findptsElementGEdge_t edge;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
edge.x[d] = constraint_workspace + d*D1D;
|
||||
edge.x[d][j] = elx[d][j];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
lag_eval_second_der(wt, tmp->r, j, gll1D,
|
||||
lagcoeff, D1D);
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,sDIM)
|
||||
{
|
||||
resid[j] = tmp->x[j];
|
||||
jac[j] = 0.0;
|
||||
hess[j] = 0.0;
|
||||
for (int k=0; k<D1D; ++k)
|
||||
{
|
||||
resid[j] -= wt[ k]*edge.x[j][k];
|
||||
jac[j] += wt[D1D+k]*edge.x[j][k];
|
||||
hess[j] += wt[2*D1D+k]*edge.x[j][k];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
hess[3] = resid[0]*hess[0] + resid[1]*hess[1] +
|
||||
resid[2]*hess[2];
|
||||
}
|
||||
|
||||
MFEM_FOREACH_THREAD(l,x,1)
|
||||
{
|
||||
if (!reject_prior_step_q(fpt,resid,tmp,tol))
|
||||
{
|
||||
newton_edge(fpt,jac,hess[3],resid,
|
||||
tmp->flags&FLAG_MASK,tmp,tol);
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
const int pi = point_index(tmp->flags &
|
||||
FLAG_MASK);
|
||||
const double *wt = wtend + pi*3*D1D;
|
||||
findptsElementGPT_t gpt;
|
||||
for (int d=0; d<sDIM; ++d)
|
||||
{
|
||||
gpt.x[d] = elx[d][pi*(D1D-1)];
|
||||
gpt.jac[d] = 0.0;
|
||||
gpt.hes[d] = 0.0;
|
||||
for (int k=0; k<D1D; ++k)
|
||||
{
|
||||
gpt.jac[d] += wt[D1D +k]*elx[d][k];
|
||||
gpt.hes[d] += wt[2*D1D+k]*elx[d][k];
|
||||
}
|
||||
}
|
||||
|
||||
const double *const pt_x = gpt.x;
|
||||
const double *const jac = gpt.jac;
|
||||
const double *const hes = gpt.hes;
|
||||
double resid[sDIM], steep, sr;
|
||||
resid[0] = fpt->x[0] - pt_x[0];
|
||||
resid[1] = fpt->x[1] - pt_x[1];
|
||||
resid[2] = fpt->x[2] - pt_x[2];
|
||||
steep = jac[0]*resid[0] + jac[1]*resid[1] +
|
||||
jac[2]*resid[2];
|
||||
sr = steep*tmp->r;
|
||||
if (!reject_prior_step_q(fpt, resid, tmp, tol))
|
||||
{
|
||||
if (sr<0)
|
||||
{
|
||||
const double rhess = resid[0]*hes[0] +
|
||||
resid[1]*hes[1] +
|
||||
resid[2]*hes[2];
|
||||
newton_edge(fpt, jac, rhess,
|
||||
resid, 0, tmp, tol);
|
||||
}
|
||||
else // sr==0
|
||||
{
|
||||
fpt->r = tmp->r;
|
||||
fpt->dist2p = 0;
|
||||
fpt->flags = tmp->flags | CONVERGED_FLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
break;
|
||||
} // case 1
|
||||
} //switch
|
||||
if (fpt->flags & CONVERGED_FLAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
*tmp = *fpt;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
} // for step<50
|
||||
} // findpts_el
|
||||
|
||||
bool converged_internal =
|
||||
((fpt->flags&FLAG_MASK) == CONVERGED_FLAG) &&
|
||||
(fpt->dist2<dist2tol);
|
||||
if (*code_i==CODE_NOT_FOUND || converged_internal ||
|
||||
fpt->dist2<*dist2_i)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
*(el_base+i) = el;
|
||||
*code_i = converged_internal?CODE_INTERNAL:CODE_BORDER;
|
||||
*dist2_i = fpt->dist2;
|
||||
*(r_base+i) = fpt->r;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
if (converged_internal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // findpts_local
|
||||
} // obbox_test
|
||||
} // elp
|
||||
});
|
||||
}
|
||||
|
||||
void FindPointsGSLIB::FindPointsEdgeLocal3(const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &code,
|
||||
Array<unsigned int> &elem,
|
||||
Vector &ref,
|
||||
Vector &dist,
|
||||
int npt)
|
||||
{
|
||||
if (npt == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MFEM_VERIFY(spacedim==3 && dim == 1,"Function for 3D edges only");
|
||||
bool use_dev = point_pos.UseDevice();
|
||||
auto pp = point_pos.Read(use_dev);
|
||||
auto pgslm = gsl_mesh.Read(use_dev);
|
||||
auto pwt = DEV.wtend.Read(use_dev);
|
||||
auto pbb = DEV.bb.Read(use_dev);
|
||||
auto plhm = DEV.lh_min.Read(use_dev);
|
||||
auto plhf = DEV.lh_fac.Read(use_dev);
|
||||
auto plho = DEV.lh_offset.ReadWrite(use_dev);
|
||||
auto pcode = code.Write(use_dev);
|
||||
auto pelem = elem.Write(use_dev);
|
||||
auto pref = ref.Write(use_dev);
|
||||
auto pdist = dist.Write(use_dev);
|
||||
auto pgll1d = DEV.gll1d.ReadWrite(use_dev);
|
||||
auto plc = DEV.lagcoeff.Read(use_dev);
|
||||
double dist2tol = DEV.surf_dist_tol;
|
||||
switch (DEV.dof1d)
|
||||
{
|
||||
case 2:
|
||||
return FindPointsEdgeLocal3D_Kernel<2>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
case 3:
|
||||
return FindPointsEdgeLocal3D_Kernel<3>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
case 4:
|
||||
return FindPointsEdgeLocal3D_Kernel<4>(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc);
|
||||
default:
|
||||
return FindPointsEdgeLocal3D_Kernel(
|
||||
npt, DEV.newt_tol, dist2tol, pp, point_pos_ordering, pgslm,
|
||||
NE_split_total, pwt, pbb, DEV.lh_nx, plhm, plhf,
|
||||
plho, pcode, pelem, pref, pdist, pgll1d, plc, DEV.dof1d);
|
||||
}
|
||||
}
|
||||
#undef rDIM2
|
||||
#undef sDIM2
|
||||
#undef rDIM
|
||||
#undef sDIM
|
||||
#undef CODE_INTERNAL
|
||||
#undef CODE_BORDER
|
||||
#undef CODE_NOT_FOUND
|
||||
#else
|
||||
void FindPointsGSLIB::FindPointsEdgeLocal3( const Vector &point_pos,
|
||||
int point_pos_ordering,
|
||||
Array<unsigned int> &code,
|
||||
Array<unsigned int> &elem,
|
||||
Vector &ref,
|
||||
Vector &dist,
|
||||
int npt ) {} ;
|
||||
#endif
|
||||
} // namespace mfem
|
||||
|
||||
#endif //ifdef MFEM_USE_GSLIB
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
|
||||
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
|
||||
// LICENSE and NOTICE for details. LLNL-CODE-806117.
|
||||
//
|
||||
// This file is part of the MFEM library. For more information and source code
|
||||
// availability visit https://mfem.org.
|
||||
//
|
||||
// MFEM is free software; you can redistribute it and/or modify it under the
|
||||
// terms of the BSD-3 license. We welcome feedback and contributions, see file
|
||||
// CONTRIBUTING.md for details.
|
||||
|
||||
#include "../gslib.hpp"
|
||||
#include "../../general/forall.hpp"
|
||||
#include "../../linalg/kernels.hpp"
|
||||
|
||||
#ifdef MFEM_USE_GSLIB
|
||||
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
#include "gslib.h"
|
||||
#ifndef GSLIB_RELEASE_VERSION //gslib v1.0.7
|
||||
#define GSLIB_RELEASE_VERSION 10007
|
||||
#endif
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
namespace mfem
|
||||
{
|
||||
#if GSLIB_RELEASE_VERSION >= 10009
|
||||
#define CODE_INTERNAL 0
|
||||
#define CODE_BORDER 1
|
||||
#define CODE_NOT_FOUND 2
|
||||
|
||||
static MFEM_HOST_DEVICE void lagrange_eval(double *p0, double x,
|
||||
int i, int p_Nq,
|
||||
double *z, double *lagrangeCoeff)
|
||||
{
|
||||
double p_i = (1 << (p_Nq - 1));
|
||||
for (int j=0; j<p_Nq; ++j)
|
||||
{
|
||||
p_i *= j==i ? 1 : x-z[j];
|
||||
}
|
||||
p0[i] = lagrangeCoeff[i] * p_i;
|
||||
}
|
||||
|
||||
template<int T_D1D = 0>
|
||||
static void InterpolateLocal1DKernel(const double *const gf_in,
|
||||
int *const el,
|
||||
double *const r,
|
||||
double *const int_out,
|
||||
const int npt,
|
||||
const int nfields,
|
||||
double *gll1D,
|
||||
double *lagcoeff,
|
||||
const int pN = 0)
|
||||
{
|
||||
const int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
const int D1D = T_D1D ? T_D1D : pN;
|
||||
const int p_Nq = D1D;
|
||||
MFEM_VERIFY(MD1 <= DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(pN<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(D1D != 0, "Polynomial order not specified.");
|
||||
// for each point of the npt points, create a thread block of size dof1Dsol
|
||||
mfem::forall_2D(npt, D1D, 1, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
MFEM_SHARED double wtr[MD1];
|
||||
MFEM_SHARED double sums[MD1];
|
||||
|
||||
// Evaluate basis functions at the reference space coordinates
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
lagrange_eval(wtr, r[i], j, p_Nq, gll1D, lagcoeff);
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
for (int fld=0; fld<nfields; ++fld)
|
||||
{
|
||||
// If using GetNodalValues, ordering is NDOFS x NEL x VDIM and the
|
||||
// offset would be `el[i] * p_Nq + fld * gf_offset`.
|
||||
// R->Mult produces element vectors in NDOFS x VDIM x NEL layout.
|
||||
const int elemOffset = el[i]*nfields*p_Nq + fld*p_Nq;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
sums[j] = wtr[j] * gf_in[elemOffset + j];
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD(j,x,1)
|
||||
{
|
||||
double sumv = 0.0;
|
||||
// sum the contributions of each lagrange polynomial
|
||||
for (int jj=0; jj<D1D; ++jj)
|
||||
{
|
||||
sumv += sums[jj];
|
||||
}
|
||||
int_out[fld*npt + i] = sumv;
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FindPointsGSLIB::InterpolateLocal1( const Vector &field_in,
|
||||
Array<int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt,
|
||||
int ncomp,
|
||||
int dof1Dsol )
|
||||
{
|
||||
MFEM_VERIFY(dim == 1, "Kernel for edges only.");
|
||||
if (npt == 0) { return; }
|
||||
bool use_dev = field_in.UseDevice();
|
||||
auto pfin = field_in.Read(use_dev);
|
||||
auto pgsl = gsl_elem_dev_l.ReadWrite(use_dev);
|
||||
auto pgslr = gsl_ref_l.ReadWrite(use_dev);
|
||||
auto pfout = field_out.Write(use_dev);
|
||||
auto pgll = DEV.gll1d_sol.ReadWrite(use_dev);
|
||||
auto plcf = DEV.lagcoeff_sol.ReadWrite(use_dev);
|
||||
switch (dof1Dsol)
|
||||
{
|
||||
case 2: return InterpolateLocal1DKernel<2>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 3: return InterpolateLocal1DKernel<3>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 4: return InterpolateLocal1DKernel<4>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 5: return InterpolateLocal1DKernel<5>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
default: return InterpolateLocal1DKernel(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp,
|
||||
pgll, plcf, dof1Dsol);
|
||||
}
|
||||
}
|
||||
#undef CODE_INTERNAL
|
||||
#undef CODE_BORDER
|
||||
#undef CODE_NOT_FOUND
|
||||
#else
|
||||
void FindPointsGSLIB::InterpolateLocal1(const Vector &field_in,
|
||||
Array<int> &gsl_elem_dev_l,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int dof1Dsol) {};
|
||||
#endif
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif //ifdef MFEM_USE_GSLIB
|
||||
@@ -52,8 +52,6 @@ static void InterpolateLocal2DKernel(const double *const gf_in,
|
||||
double *const int_out,
|
||||
const int npt,
|
||||
const int ncomp,
|
||||
const int nel,
|
||||
const int gf_offset,
|
||||
double *gll1D,
|
||||
double *lagcoeff,
|
||||
const int pN = 0)
|
||||
@@ -64,6 +62,8 @@ static void InterpolateLocal2DKernel(const double *const gf_in,
|
||||
const int p_Np = D1D*D1D;
|
||||
MFEM_VERIFY(MD1 <= DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(pN<=DofQuadLimits::MAX_D1D,
|
||||
"Increase Max allowable polynomial order.");
|
||||
MFEM_VERIFY(D1D != 0, "Polynomial order not specified.");
|
||||
mfem::forall_2D(npt, D1D, D1D, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
@@ -82,9 +82,9 @@ static void InterpolateLocal2DKernel(const double *const gf_in,
|
||||
|
||||
for (int fld = 0; fld < Nfields; ++fld)
|
||||
{
|
||||
// If using GetNodalValues, ordering is NDOFSxNELxVDIM
|
||||
// const int elemOffset = el[i] * p_Np + fld * gf_offset;
|
||||
//if using R->Mult for L -> E-Vec use below: NDOFSxVDIMxNEL
|
||||
// If using GetNodalValues, ordering is NDOFS x NEL x VDIM and the
|
||||
// offset would be `el[i] * p_Np + fld * gf_offset`.
|
||||
// R->Mult produces element vectors in NDOFS x VDIM x NEL layout.
|
||||
const int elemOffset = el[i] * p_Np * Nfields + fld * p_Np;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
@@ -120,32 +120,32 @@ void FindPointsGSLIB::InterpolateLocal2(const Vector &field_in,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1Dsol)
|
||||
int dof1Dsol)
|
||||
{
|
||||
if (npt == 0) { return; }
|
||||
const int gf_offset = field_in.Size()/ncomp;
|
||||
auto pfin = field_in.Read();
|
||||
auto pgsl = gsl_elem_dev_l.ReadWrite();
|
||||
auto pgslr = gsl_ref_l.ReadWrite();
|
||||
auto pfout = field_out.Write();
|
||||
auto pgll = DEV.gll1d_sol.ReadWrite();
|
||||
auto plcf = DEV.lagcoeff_sol.ReadWrite();
|
||||
bool use_dev = field_in.UseDevice();
|
||||
auto pfin = field_in.Read(use_dev);
|
||||
auto pgsl = gsl_elem_dev_l.ReadWrite(use_dev);
|
||||
auto pgslr = gsl_ref_l.ReadWrite(use_dev);
|
||||
auto pfout = field_out.Write(use_dev);
|
||||
auto pgll = DEV.gll1d_sol.ReadWrite(use_dev);
|
||||
auto plcf = DEV.lagcoeff_sol.ReadWrite(use_dev);
|
||||
switch (dof1Dsol)
|
||||
{
|
||||
case 2: return InterpolateLocal2DKernel<2>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 3: return InterpolateLocal2DKernel<3>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 4: return InterpolateLocal2DKernel<4>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 5: return InterpolateLocal2DKernel<5>(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
default: return InterpolateLocal2DKernel(pfin, pgsl, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf, dof1Dsol);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void FindPointsGSLIB::InterpolateLocal2(const Vector &field_in,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1Dsol) {};
|
||||
int dof1Dsol) {};
|
||||
#endif
|
||||
} // namespace mfem
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ static void InterpolateLocal3DKernel(const double *const gf_in,
|
||||
double *const int_out,
|
||||
const int npt,
|
||||
const int ncomp,
|
||||
const int nel,
|
||||
const int gf_offset,
|
||||
double *gll1D,
|
||||
double *lagcoeff,
|
||||
const int pN = 0)
|
||||
@@ -84,9 +82,9 @@ static void InterpolateLocal3DKernel(const double *const gf_in,
|
||||
|
||||
for (int fld = 0; fld < Nfields; ++fld)
|
||||
{
|
||||
// If using GetNodalValues, ordering is NDOFSxNELxVDIM
|
||||
// const int elemOffset = el[i] * p_Np + fld * gf_offset;
|
||||
//if using R->Mult for L -> E-Vec use below.
|
||||
// If using GetNodalValues, ordering is NDOFS x NEL x VDIM and the
|
||||
// offset would be `el[i] * p_Np + fld * gf_offset`.
|
||||
// R->Mult produces element vectors in NDOFS x VDIM x NEL layout.
|
||||
const int elemOffset = el[i] * p_Np * Nfields + fld * p_Np;
|
||||
MFEM_FOREACH_THREAD(j,x,D1D)
|
||||
{
|
||||
@@ -125,37 +123,38 @@ void FindPointsGSLIB::InterpolateLocal3(const Vector &field_in,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1Dsol)
|
||||
int dof1Dsol)
|
||||
{
|
||||
if (npt == 0) { return; }
|
||||
const int gf_offset = field_in.Size()/ncomp;
|
||||
auto pfin = field_in.Read();
|
||||
auto pgsle = gsl_elem_dev_l.ReadWrite();
|
||||
auto pgslr = gsl_ref_l.ReadWrite();
|
||||
auto pfout = field_out.Write();
|
||||
auto pgll = DEV.gll1d_sol.ReadWrite();
|
||||
auto plcf = DEV.lagcoeff_sol.ReadWrite();
|
||||
bool use_dev = field_in.UseDevice();
|
||||
auto pfin = field_in.Read(use_dev);
|
||||
auto pgsle = gsl_elem_dev_l.ReadWrite(use_dev);
|
||||
auto pgslr = gsl_ref_l.ReadWrite(use_dev);
|
||||
auto pfout = field_out.Write(use_dev);
|
||||
auto pgll = DEV.gll1d_sol.ReadWrite(use_dev);
|
||||
auto plcf = DEV.lagcoeff_sol.ReadWrite(use_dev);
|
||||
switch (dof1Dsol)
|
||||
{
|
||||
case 2: return InterpolateLocal3DKernel<2>(pfin, pgsle, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 3: return InterpolateLocal3DKernel<3>(pfin, pgsle, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 4: return InterpolateLocal3DKernel<4>(pfin, pgsle, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
case 5: return InterpolateLocal3DKernel<5>(pfin, pgsle, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf);
|
||||
default: return InterpolateLocal3DKernel(pfin, pgsle, pgslr, pfout,
|
||||
npt, ncomp, nel, gf_offset,
|
||||
npt, ncomp,
|
||||
pgll, plcf, dof1Dsol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef MAXC
|
||||
#undef CODE_INTERNAL
|
||||
#undef CODE_BORDER
|
||||
#undef CODE_NOT_FOUND
|
||||
@@ -165,7 +164,7 @@ void FindPointsGSLIB::InterpolateLocal3(const Vector &field_in,
|
||||
Vector &gsl_ref_l,
|
||||
Vector &field_out,
|
||||
int npt, int ncomp,
|
||||
int nel, int dof1Dsol) {};
|
||||
int dof1Dsol) {};
|
||||
#endif
|
||||
} // namespace mfem
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// CONTRIBUTING.md for details.
|
||||
|
||||
#include "bilininteg_diffusion_kernels.hpp"
|
||||
#include "bilininteg_diffusion_pa_simplices.hpp" // IWYU pragma: keep
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -19,6 +20,13 @@ namespace mfem
|
||||
DiffusionIntegrator::Kernels::Kernels()
|
||||
{
|
||||
// 2D
|
||||
// Q = P, only for simplex
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,2,1>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,3,2>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,4,3>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,5,4>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,6,5>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,7,6>();
|
||||
// Q = P+1
|
||||
DiffusionIntegrator::AddSpecialization<2,1,1>();
|
||||
DiffusionIntegrator::AddSpecialization<2,2,2>();
|
||||
@@ -40,7 +48,18 @@ DiffusionIntegrator::Kernels::Kernels()
|
||||
DiffusionIntegrator::AddSpecialization<2,8,9>();
|
||||
DiffusionIntegrator::AddSpecialization<2,9,10>();
|
||||
// others
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,2,5>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<2,3,6>();
|
||||
|
||||
// 3D
|
||||
// Q = P, only for simplex
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,2,1>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,3,2>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,4,3>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,5,4>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,6,5>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,7,6>();
|
||||
DiffusionIntegrator::AddSimplexSpecialization<3,8,7>();
|
||||
// Q = P+1
|
||||
DiffusionIntegrator::AddSpecialization<3,1,1>();
|
||||
DiffusionIntegrator::AddSpecialization<3,2,2>();
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#ifndef MFEM_BILININTEG_DIFFUSION_KERNELS_HPP
|
||||
#define MFEM_BILININTEG_DIFFUSION_KERNELS_HPP
|
||||
|
||||
#include "../kernel_dispatch.hpp"
|
||||
#include "../../config/config.hpp"
|
||||
#include "../../general/array.hpp"
|
||||
#include "../../general/forall.hpp"
|
||||
@@ -637,8 +636,8 @@ inline void SmemPADiffusionApply2D(const int NE,
|
||||
const bool symmetric,
|
||||
const Array<real_t> &b_,
|
||||
const Array<real_t> &g_,
|
||||
const Array<real_t> &bt_,
|
||||
const Array<real_t> >_,
|
||||
const Array<real_t> &,
|
||||
const Array<real_t> &,
|
||||
const Vector &d_,
|
||||
const Vector &x_,
|
||||
Vector &y_,
|
||||
@@ -1218,43 +1217,47 @@ inline void SmemPADiffusionApply3D(const int NE,
|
||||
namespace
|
||||
{
|
||||
using ApplyKernelType = DiffusionIntegrator::ApplyKernelType;
|
||||
using ApplySimplexKernelType = DiffusionIntegrator::ApplySimplexKernelType;
|
||||
using DiagonalKernelType = DiffusionIntegrator::DiagonalKernelType;
|
||||
}
|
||||
|
||||
template<int DIM, int T_D1D, int T_Q1D>
|
||||
template<int DIM, int D1D, int Q1D>
|
||||
ApplyKernelType DiffusionIntegrator::ApplyPAKernels::Kernel()
|
||||
{
|
||||
if constexpr (DIM == 2) { return internal::SmemPADiffusionApply2D<T_D1D,T_Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPADiffusionApply3D<T_D1D, T_Q1D>; }
|
||||
MFEM_ABORT("");
|
||||
if constexpr (DIM == 2) { return internal::SmemPADiffusionApply2D<D1D, Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPADiffusionApply3D<D1D, Q1D>; }
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline
|
||||
ApplyKernelType DiffusionIntegrator::ApplyPAKernels::Fallback(int DIM, int, int)
|
||||
ApplyKernelType DiffusionIntegrator::ApplyPAKernels::Fallback(int dim, int, int)
|
||||
{
|
||||
if (DIM == 2) { return internal::PADiffusionApply2D; }
|
||||
else if (DIM == 3) { return internal::PADiffusionApply3D; }
|
||||
if (dim == 2) { return internal::PADiffusionApply2D; }
|
||||
else if (dim == 3) { return internal::PADiffusionApply3D; }
|
||||
else { MFEM_ABORT(""); }
|
||||
}
|
||||
|
||||
template<int DIM, int D1D, int Q1D>
|
||||
DiagonalKernelType DiffusionIntegrator::DiagonalPAKernels::Kernel()
|
||||
{
|
||||
if constexpr (DIM == 2) { return internal::SmemPADiffusionDiagonal2D<D1D,Q1D>; }
|
||||
if constexpr (DIM == 2) { return internal::SmemPADiffusionDiagonal2D<D1D, Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPADiffusionDiagonal3D<D1D, Q1D>; }
|
||||
MFEM_ABORT("");
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline DiagonalKernelType
|
||||
DiffusionIntegrator::DiagonalPAKernels::Fallback(int DIM, int, int)
|
||||
DiffusionIntegrator::DiagonalPAKernels::Fallback(int dim, int, int)
|
||||
{
|
||||
if (DIM == 2) { return internal::PADiffusionDiagonal2D; }
|
||||
else if (DIM == 3) { return internal::PADiffusionDiagonal3D; }
|
||||
if (dim == 2) { return internal::PADiffusionDiagonal2D; }
|
||||
else if (dim == 3) { return internal::PADiffusionDiagonal3D; }
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// \endcond DO_NOT_DOCUMENT
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../../mesh/nurbs.hpp"
|
||||
#include "../ceed/integrators/diffusion/diffusion.hpp"
|
||||
#include "bilininteg_diffusion_kernels.hpp"
|
||||
#include "bilininteg_diffusion_pa_simplices.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -68,6 +69,24 @@ void DiffusionIntegrator::AddMultPA(const Vector &x, Vector &y) const
|
||||
}
|
||||
#endif // MFEM_USE_OCCA
|
||||
|
||||
if (fespace->UsesRaggedTensorBasis())
|
||||
{
|
||||
const auto *rmaps = static_cast<const RaggedDofToQuad*>(maps);
|
||||
return ApplySimplexPAKernels::Run(dim, dofs1D, quad1D, ne, symmetric,
|
||||
rmaps->lex_map,
|
||||
rmaps->forward_map2d_diff,
|
||||
rmaps->inverse_map2d_diff,
|
||||
rmaps->forward_map3d_diff,
|
||||
rmaps->inverse_map3d_diff,
|
||||
rmaps->Ga1,
|
||||
rmaps->Ga2,
|
||||
rmaps->Ga3,
|
||||
rmaps->Ga1t,
|
||||
rmaps->Ga2t,
|
||||
rmaps->Ga3t,
|
||||
Dv, x, y, dofs1D, quad1D);
|
||||
}
|
||||
|
||||
ApplyPAKernels::Run(dim, dofs1D, quad1D, ne, symmetric, B, G, Bt,
|
||||
Gt, Dv, x, y, dofs1D, quad1D);
|
||||
}
|
||||
@@ -94,7 +113,8 @@ void DiffusionIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
fespace = &fes;
|
||||
Mesh *mesh = fes.GetMesh();
|
||||
const FiniteElement &el = *fes.GetTypicalFE();
|
||||
const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el);
|
||||
const bool stroud = fes.UsesRaggedTensorBasis();
|
||||
const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, stroud);
|
||||
if (DeviceCanUseCeed())
|
||||
{
|
||||
delete ceedOp;
|
||||
@@ -119,13 +139,22 @@ void DiffusionIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
dim = mesh->Dimension();
|
||||
ne = fes.GetNE();
|
||||
geom = mesh->GetGeometricFactors(*ir, GeometricFactors::JACOBIANS, mt);
|
||||
if (stroud)
|
||||
{
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::RAGGED_TENSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::TENSOR);
|
||||
}
|
||||
const int sdim = mesh->SpaceDimension();
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::TENSOR);
|
||||
dofs1D = maps->ndof;
|
||||
quad1D = maps->nqpt;
|
||||
|
||||
QuadratureSpace qs(*mesh, *ir);
|
||||
CoefficientVector coeff(qs, CoefficientStorage::COMPRESSED);
|
||||
// QuadratureSpace expects ir defined in reference simplex for Bernstein
|
||||
// elements with partial assembly
|
||||
|
||||
if (MQ) { coeff.ProjectTranspose(*MQ); }
|
||||
else if (VQ) { coeff.Project(*VQ); }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
// CONTRIBUTING.md for details.
|
||||
|
||||
#include "bilininteg_mass_kernels.hpp"
|
||||
#include "bilininteg_mass_pa_simplices.hpp" // IWYU pragma: keep
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -39,8 +40,10 @@ MassIntegrator::Kernels::Kernels()
|
||||
MassIntegrator::AddSpecialization<2,9,10>();
|
||||
// others
|
||||
MassIntegrator::AddSpecialization<2,2,4>();
|
||||
MassIntegrator::AddSpecialization<2,2,5>();
|
||||
MassIntegrator::AddSpecialization<2,3,6>();
|
||||
MassIntegrator::AddSpecialization<2,4,6>();
|
||||
|
||||
// 3D
|
||||
// Q=P+1
|
||||
MassIntegrator::AddSpecialization<3,1,1>();
|
||||
|
||||
@@ -181,6 +181,12 @@ constexpr int NBZ(int D1D)
|
||||
{
|
||||
return ipow(2, D(D1D) >= 0 ? D(D1D) : 0);
|
||||
}
|
||||
constexpr int NBZ3D(int MDQ)
|
||||
{
|
||||
return MDQ > 0 ? std::min<int>(
|
||||
(128 + MDQ * MDQ * MDQ - 1) / (MDQ * MDQ * MDQ), 64)
|
||||
: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Shared memory PA Mass Diagonal 2D kernel
|
||||
@@ -804,19 +810,23 @@ void PAMassApply3D_Element(const int e,
|
||||
}
|
||||
}
|
||||
|
||||
template<int T_D1D, int T_Q1D, bool ACCUMULATE = true>
|
||||
MFEM_HOST_DEVICE inline
|
||||
void SmemPAMassApply3D_Element(const int e,
|
||||
const int NE,
|
||||
const real_t *b_,
|
||||
const real_t *d_,
|
||||
const real_t *x_,
|
||||
real_t *y_,
|
||||
const int d1d = 0,
|
||||
const int q1d = 0)
|
||||
template <int T_D1D, int T_Q1D, int TBATCH, bool ACCUMULATE = true>
|
||||
MFEM_HOST_DEVICE inline void
|
||||
SmemPAMassApply3D_Element(const int e, const int NE, const real_t *b_,
|
||||
const real_t *d_, const real_t *x_, real_t *y_,
|
||||
int d1d = 0, int q1d = 0)
|
||||
{
|
||||
constexpr int D1D = T_D1D ? T_D1D : d1d;
|
||||
constexpr int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
static_assert(TBATCH > 0, "TBATCH must be positive");
|
||||
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
|
||||
constexpr int tbatch = TBATCH;
|
||||
const int tidz = MFEM_THREAD_ID(z);
|
||||
#else
|
||||
// host always batch size 1
|
||||
constexpr int tbatch = 1;
|
||||
constexpr int tidz = 0;
|
||||
#endif
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
constexpr int MQ1 = T_Q1D ? T_Q1D : DofQuadLimits::MAX_Q1D;
|
||||
constexpr int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
constexpr int MDQ = (MQ1 > MD1) ? MQ1 : MD1;
|
||||
@@ -829,33 +839,37 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
MFEM_SHARED real_t sDQ[MQ1*MD1];
|
||||
real_t (*B)[MD1] = (real_t (*)[MD1]) sDQ;
|
||||
real_t (*Bt)[MQ1] = (real_t (*)[MQ1]) sDQ;
|
||||
MFEM_SHARED real_t sm0[MDQ*MDQ*MDQ];
|
||||
MFEM_SHARED real_t sm1[MDQ*MDQ*MDQ];
|
||||
real_t (*X)[MD1][MD1] = (real_t (*)[MD1][MD1]) sm0;
|
||||
real_t (*DDQ)[MD1][MQ1] = (real_t (*)[MD1][MQ1]) sm1;
|
||||
real_t (*DQQ)[MQ1][MQ1] = (real_t (*)[MQ1][MQ1]) sm0;
|
||||
real_t (*QQQ)[MQ1][MQ1] = (real_t (*)[MQ1][MQ1]) sm1;
|
||||
real_t (*QQD)[MQ1][MD1] = (real_t (*)[MQ1][MD1]) sm0;
|
||||
real_t (*QDD)[MD1][MD1] = (real_t (*)[MD1][MD1]) sm1;
|
||||
MFEM_FOREACH_THREAD(dy,y,D1D)
|
||||
MFEM_SHARED real_t sm0[tbatch][MDQ*MDQ*MDQ];
|
||||
MFEM_SHARED real_t sm1[tbatch][MDQ*MDQ*MDQ];
|
||||
real_t (*X)[MD1][MD1] = (real_t (*)[MD1][MD1]) (sm0+tidz);
|
||||
real_t (*DDQ)[MD1][MQ1] = (real_t (*)[MD1][MQ1]) (sm1+tidz);
|
||||
real_t (*DQQ)[MQ1][MQ1] = (real_t (*)[MQ1][MQ1]) (sm0+tidz);
|
||||
real_t (*QQQ)[MQ1][MQ1] = (real_t (*)[MQ1][MQ1]) (sm1+tidz);
|
||||
real_t (*QQD)[MQ1][MD1] = (real_t (*)[MQ1][MD1]) (sm0+tidz);
|
||||
real_t (*QDD)[MD1][MD1] = (real_t (*)[MD1][MD1]) (sm1+tidz);
|
||||
MFEM_FOREACH_THREAD(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(dx,x,D1D)
|
||||
MFEM_FOREACH_THREAD(dx, x, D1D)
|
||||
{
|
||||
MFEM_UNROLL(MD1)
|
||||
for (int dz = 0; dz < D1D; ++dz)
|
||||
{
|
||||
X[dz][dy][dx] = x(dx,dy,dz,e);
|
||||
X[dz][dy][dx] = x(dx, dy, dz, e);
|
||||
}
|
||||
}
|
||||
MFEM_FOREACH_THREAD(dx,x,Q1D)
|
||||
MFEM_FOREACH_THREAD(dx, x, Q1D) { B[dx][dy] = b(dx, dy); }
|
||||
}
|
||||
if (tidz == 0)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(dy, y, D1D)
|
||||
{
|
||||
B[dx][dy] = b(dx,dy);
|
||||
MFEM_FOREACH_THREAD(dx, x, Q1D) { B[dx][dy] = b(dx, dy); }
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(dy,y,D1D)
|
||||
MFEM_FOREACH_THREAD(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(qx,x,Q1D)
|
||||
MFEM_FOREACH_THREAD(qx, x, Q1D)
|
||||
{
|
||||
real_t u[D1D];
|
||||
MFEM_UNROLL(MD1)
|
||||
@@ -880,9 +894,9 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(qy,y,Q1D)
|
||||
MFEM_FOREACH_THREAD(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(qx,x,Q1D)
|
||||
MFEM_FOREACH_THREAD(qx, x, Q1D)
|
||||
{
|
||||
real_t u[D1D];
|
||||
MFEM_UNROLL(MD1)
|
||||
@@ -907,9 +921,9 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(qy,y,Q1D)
|
||||
MFEM_FOREACH_THREAD(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(qx,x,Q1D)
|
||||
MFEM_FOREACH_THREAD(qx, x, Q1D)
|
||||
{
|
||||
real_t u[Q1D];
|
||||
MFEM_UNROLL(MQ1)
|
||||
@@ -929,22 +943,22 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
MFEM_UNROLL(MQ1)
|
||||
for (int qz = 0; qz < Q1D; qz++)
|
||||
{
|
||||
QQQ[qz][qy][qx] = u[qz] * d(qx,qy,qz,e);
|
||||
QQQ[qz][qy][qx] = u[qz] * d(qx, qy, qz, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(di,y,D1D)
|
||||
if (tidz == 0)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(q,x,Q1D)
|
||||
MFEM_FOREACH_THREAD(di, y, D1D)
|
||||
{
|
||||
Bt[di][q] = b(q,di);
|
||||
MFEM_FOREACH_THREAD(q, x, Q1D) { Bt[di][q] = b(q, di); }
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(qy,y,Q1D)
|
||||
MFEM_FOREACH_THREAD(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(dx,x,D1D)
|
||||
MFEM_FOREACH_THREAD(dx, x, D1D)
|
||||
{
|
||||
real_t u[Q1D];
|
||||
MFEM_UNROLL(MQ1)
|
||||
@@ -969,9 +983,9 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(dy,y,D1D)
|
||||
MFEM_FOREACH_THREAD(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(dx,x,D1D)
|
||||
MFEM_FOREACH_THREAD(dx, x, D1D)
|
||||
{
|
||||
real_t u[Q1D];
|
||||
MFEM_UNROLL(MQ1)
|
||||
@@ -996,9 +1010,9 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
MFEM_FOREACH_THREAD(dy,y,D1D)
|
||||
MFEM_FOREACH_THREAD(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD(dx,x,D1D)
|
||||
MFEM_FOREACH_THREAD(dx, x, D1D)
|
||||
{
|
||||
real_t u[D1D];
|
||||
MFEM_UNROLL(MD1)
|
||||
@@ -1020,11 +1034,11 @@ void SmemPAMassApply3D_Element(const int e,
|
||||
{
|
||||
if (ACCUMULATE)
|
||||
{
|
||||
y(dx,dy,dz,e) += u[dz];
|
||||
y(dx, dy, dz, e) += u[dz];
|
||||
}
|
||||
else
|
||||
{
|
||||
y(dx,dy,dz,e) = u[dz];
|
||||
y(dx, dy, dz, e) = u[dz];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1115,8 +1129,8 @@ inline void PAMassApply3D(const int NE,
|
||||
});
|
||||
}
|
||||
|
||||
// Shared memory PA Mass Apply 2D kernel
|
||||
template<int T_D1D = 0, int T_Q1D = 0>
|
||||
// Shared memory PA Mass Apply 3D kernel
|
||||
template<int T_D1D = 0, int T_Q1D = 0, int TBATCH=1>
|
||||
inline void SmemPAMassApply3D(const int NE,
|
||||
const Array<real_t> &b_,
|
||||
const Array<real_t> &bt_,
|
||||
@@ -1126,6 +1140,9 @@ inline void SmemPAMassApply3D(const int NE,
|
||||
const int d1d = 0,
|
||||
const int q1d = 0)
|
||||
{
|
||||
static_assert(T_D1D > 0, "T_D1D must be positive");
|
||||
static_assert(T_Q1D > 0, "T_Q1D must be positive");
|
||||
static_assert(TBATCH > 0, "TBATCH must be positive");
|
||||
MFEM_CONTRACT_VAR(bt_);
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
@@ -1137,9 +1154,11 @@ inline void SmemPAMassApply3D(const int NE,
|
||||
const auto d = d_.Read();
|
||||
const auto x = x_.Read();
|
||||
auto y = y_.ReadWrite();
|
||||
mfem::forall_2D<T_Q1D*T_Q1D>(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE (int e)
|
||||
mfem::forall_2D_batch<T_Q1D * T_Q1D * TBATCH>(NE, Q1D, Q1D, TBATCH,
|
||||
[=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
internal::SmemPAMassApply3D_Element<T_D1D,T_Q1D>(e, NE, b, d, x, y, d1d, q1d);
|
||||
internal::SmemPAMassApply3D_Element<T_D1D, T_Q1D, TBATCH>(e, NE, b, d, x,
|
||||
y, d1d, q1d);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1389,42 +1408,57 @@ using ApplyKernelType = MassIntegrator::ApplyKernelType;
|
||||
using DiagonalKernelType = MassIntegrator::DiagonalKernelType;
|
||||
}
|
||||
|
||||
template<int DIM, int T_D1D, int T_Q1D>
|
||||
template<int DIM, int D1D, int Q1D>
|
||||
ApplyKernelType MassIntegrator::ApplyPAKernels::Kernel()
|
||||
{
|
||||
if constexpr (DIM == 1) { return internal::PAMassApply1D; }
|
||||
else if constexpr (DIM == 2) { return internal::SmemPAMassApply2D<T_D1D,T_Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPAMassApply3D<T_D1D, T_Q1D>; }
|
||||
MFEM_ABORT("");
|
||||
else if constexpr (DIM == 2) { return internal::SmemPAMassApply2D<D1D, Q1D>; }
|
||||
else if constexpr (DIM == 3)
|
||||
{
|
||||
constexpr int MDQ = D1D >= Q1D ? D1D : Q1D;
|
||||
// max 64 threads in z limit in cuda and hip
|
||||
if constexpr (MDQ > 0)
|
||||
{
|
||||
return internal::SmemPAMassApply3D<D1D, Q1D,
|
||||
internal::mass::NBZ3D(MDQ)>;
|
||||
}
|
||||
}
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline ApplyKernelType MassIntegrator::ApplyPAKernels::Fallback(
|
||||
int DIM, int, int)
|
||||
int dim, int, int)
|
||||
{
|
||||
if (DIM == 1) { return internal::PAMassApply1D; }
|
||||
else if (DIM == 2) { return internal::PAMassApply2D; }
|
||||
else if (DIM == 3) { return internal::PAMassApply3D; }
|
||||
if (dim == 1) { return internal::PAMassApply1D; }
|
||||
else if (dim == 2) { return internal::PAMassApply2D; }
|
||||
else if (dim == 3) { return internal::PAMassApply3D; }
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<int DIM, int T_D1D, int T_Q1D>
|
||||
template<int DIM, int D1D, int Q1D>
|
||||
DiagonalKernelType MassIntegrator::DiagonalPAKernels::Kernel()
|
||||
{
|
||||
if constexpr (DIM == 1) { return internal::PAMassAssembleDiagonal1D; }
|
||||
else if constexpr (DIM == 2) { return internal::SmemPAMassAssembleDiagonal2D<T_D1D,T_Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPAMassAssembleDiagonal3D<T_D1D, T_Q1D>; }
|
||||
MFEM_ABORT("");
|
||||
else if constexpr (DIM == 2) { return internal::SmemPAMassAssembleDiagonal2D<D1D, Q1D>; }
|
||||
else if constexpr (DIM == 3) { return internal::SmemPAMassAssembleDiagonal3D<D1D, Q1D>; }
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline DiagonalKernelType MassIntegrator::DiagonalPAKernels::Fallback(
|
||||
int DIM, int, int)
|
||||
int dim, int, int)
|
||||
{
|
||||
if (DIM == 1) { return internal::PAMassAssembleDiagonal1D; }
|
||||
else if (DIM == 2) { return internal::PAMassAssembleDiagonal2D; }
|
||||
else if (DIM == 3) { return internal::PAMassAssembleDiagonal3D; }
|
||||
if (dim == 1) { return internal::PAMassAssembleDiagonal1D; }
|
||||
else if (dim == 2) { return internal::PAMassAssembleDiagonal2D; }
|
||||
else if (dim == 3) { return internal::PAMassAssembleDiagonal3D; }
|
||||
else { MFEM_ABORT(""); }
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// \endcond DO_NOT_DOCUMENT
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../qfunction.hpp"
|
||||
#include "../ceed/integrators/mass/mass.hpp"
|
||||
#include "bilininteg_mass_kernels.hpp"
|
||||
#include "bilininteg_mass_pa_simplices.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -29,9 +30,11 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
// Assuming the same element type
|
||||
fespace = &fes;
|
||||
Mesh *mesh = fes.GetMesh();
|
||||
dim = mesh->Dimension();
|
||||
const FiniteElement &el = *fes.GetTypicalFE();
|
||||
ElementTransformation *T0 = mesh->GetTypicalElementTransformation();
|
||||
const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, *T0);
|
||||
const bool stroud = fes.UsesRaggedTensorBasis();
|
||||
const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, *T0, stroud);
|
||||
if (DeviceCanUseCeed())
|
||||
{
|
||||
delete ceedOp;
|
||||
@@ -48,17 +51,25 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
return;
|
||||
}
|
||||
int map_type = el.GetMapType();
|
||||
dim = mesh->Dimension();
|
||||
ne = fes.GetMesh()->GetNE();
|
||||
nq = ir->GetNPoints();
|
||||
geom = mesh->GetGeometricFactors(*ir, GeometricFactors::DETERMINANTS, mt);
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::TENSOR);
|
||||
if (stroud)
|
||||
{
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::RAGGED_TENSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
maps = &el.GetDofToQuad(*ir, DofToQuad::TENSOR);
|
||||
}
|
||||
dofs1D = maps->ndof;
|
||||
quad1D = maps->nqpt;
|
||||
pa_data.SetSize(ne*nq, mt);
|
||||
|
||||
QuadratureSpace qs(*mesh, *ir);
|
||||
CoefficientVector coeff(Q, qs, CoefficientStorage::COMPRESSED);
|
||||
// QuadratureSpace expects ir defined in reference simplex for Bernstein
|
||||
// elements with partial assembly
|
||||
{
|
||||
const int NE = ne;
|
||||
const int NQ = nq;
|
||||
@@ -147,9 +158,10 @@ void MassIntegrator::AddMultPA(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int D1D = dofs1D;
|
||||
const int Q1D = quad1D;
|
||||
const Vector &D = pa_data;
|
||||
const Array<real_t> &B = maps->B;
|
||||
const Array<real_t> &Bt = maps->Bt;
|
||||
const Vector &D = pa_data;
|
||||
|
||||
#ifdef MFEM_USE_OCCA
|
||||
if (DeviceCanUseOcca())
|
||||
{
|
||||
@@ -164,7 +176,31 @@ void MassIntegrator::AddMultPA(const Vector &x, Vector &y) const
|
||||
MFEM_ABORT("OCCA PA Mass Apply unknown kernel!");
|
||||
}
|
||||
#endif // MFEM_USE_OCCA
|
||||
ApplyPAKernels::Run(dim, D1D, Q1D, ne, B, Bt, D, x, y, D1D, Q1D);
|
||||
|
||||
if (fespace->UsesRaggedTensorBasis())
|
||||
{
|
||||
const auto *rmaps = static_cast<const RaggedDofToQuad*>(maps);
|
||||
|
||||
const Array<real_t> &Ba1 = rmaps->Ba1;
|
||||
const Array<real_t> &Ba2 = rmaps->Ba2;
|
||||
const Array<real_t> &Ba3 = rmaps->Ba3;
|
||||
const Array<real_t> &Ba1t = rmaps->Ba1t;
|
||||
const Array<real_t> &Ba2t = rmaps->Ba2t;
|
||||
const Array<real_t> &Ba3t = rmaps->Ba3t;
|
||||
const Array<int> &lex_map = rmaps->lex_map;
|
||||
const Array<int> &forward_map2d = rmaps->forward_map2d_mass;
|
||||
const Array<int> &inverse_map2d = rmaps->inverse_map2d_mass;
|
||||
const Array<int> &forward_map3d = rmaps->forward_map3d_mass;
|
||||
const Array<int> &inverse_map3d = rmaps->inverse_map3d_mass;
|
||||
ApplySimplexPAKernels::Run(dim, D1D, Q1D, ne, lex_map, forward_map2d,
|
||||
inverse_map2d,
|
||||
forward_map3d, inverse_map3d, Ba1, Ba2, Ba3, Ba1t, Ba2t, Ba3t,
|
||||
D, x, y, D1D, Q1D);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyPAKernels::Run(dim, D1D, Q1D, ne, B, Bt, D, x, y, D1D, Q1D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +213,8 @@ void MassIntegrator::AddAbsMultPA(const Vector &x, Vector &y) const
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_VERIFY(!fespace->UsesRaggedTensorBasis(),
|
||||
"AbsMultPA not implemented for ragged tensor basis");
|
||||
Vector abs_pa_data(pa_data);
|
||||
abs_pa_data.Abs();
|
||||
Array<real_t> absB(maps->B);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -236,6 +236,58 @@ IntegrationRule::ApplyToKnotIntervals(KnotVector const& kv) const
|
||||
return kvir;
|
||||
}
|
||||
|
||||
IntegrationRule IntegrationRule::Reorder(const Array<int> &ordering) const
|
||||
{
|
||||
const int np = GetNPoints();
|
||||
MFEM_VERIFY(np == ordering.Size(), "Invalid permutation size");
|
||||
IntegrationRule ir(np);
|
||||
ir.SetOrder(GetOrder());
|
||||
|
||||
for (int i = 0; i < np; i++)
|
||||
{
|
||||
IntegrationPoint &ip_new = ir.IntPoint(i);
|
||||
const IntegrationPoint &ip_old = IntPoint(ordering[i]);
|
||||
ip_new.Set(ip_old.x, ip_old.y, ip_old.z, ip_old.weight);
|
||||
}
|
||||
|
||||
return ir;
|
||||
}
|
||||
|
||||
IntegrationRule DuffyTrans(const IntegrationRule &ir, int dim)
|
||||
{
|
||||
IntegrationRule ir_mapped(ir.GetNPoints());
|
||||
ir_mapped.SetOrder(ir.GetOrder());
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
{
|
||||
IntegrationPoint &ip_mapped = ir_mapped.IntPoint(i);
|
||||
ip_mapped.y = ir.IntPoint(i).y * (1 - ir.IntPoint(i).x);
|
||||
ip_mapped.x = ir.IntPoint(i).x;
|
||||
ip_mapped.weight = ir.IntPoint(i).weight;
|
||||
}
|
||||
return ir_mapped;
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
{
|
||||
IntegrationPoint &ip_mapped = ir_mapped.IntPoint(i);
|
||||
ip_mapped.z = ir.IntPoint(i).z * (1 - ir.IntPoint(i).x) * (1 - ir.IntPoint(
|
||||
i).y);
|
||||
ip_mapped.y = ir.IntPoint(i).y * (1 - ir.IntPoint(i).x);
|
||||
ip_mapped.x = ir.IntPoint(i).x;
|
||||
ip_mapped.weight = ir.IntPoint(i).weight;
|
||||
}
|
||||
return ir_mapped;
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_ABORT("Duffy transformation not implemented for this dimension!");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPFR
|
||||
|
||||
// Class for computing hi-precision (HP) quadrature in 1D
|
||||
@@ -433,6 +485,142 @@ public:
|
||||
#endif // MFEM_USE_MPFR
|
||||
|
||||
|
||||
void QuadratureFunctions1D::GaussJacobi(const int np, const real_t alpha,
|
||||
const real_t beta, IntegrationRule* ir)
|
||||
{
|
||||
/* The np-point Gauss-Jacobi quadrature rule is exact for polynomials of
|
||||
degree 2np - 1 with weight function w(x) = (1-x)^alpha * x^beta. The
|
||||
nodes are the zeros of the Jacobi polynomial P_{np}^{alpha,beta} and
|
||||
the weights are
|
||||
|
||||
w_i = C / [(1 - x_i^2) * P'_{np}^{alpha,beta}(x_i)^2]
|
||||
C = 2^{alpha + beta + 1} * Gamma(np + alpha + 1) * Gamma(np + beta + 1)
|
||||
/ [Gamma(np + alpha + beta + 1) * Gamma(np + 1)].
|
||||
|
||||
The nodes are computed via nonlinear solve (Newton's method) with an
|
||||
initial guess corresponding to Gatteschi's asymptotic expansions of the
|
||||
Jacobi polynomial roots [1].
|
||||
|
||||
The current initial guess has been tested and performs well for
|
||||
np <= 200 and -1 <= alpha, beta <= 4. For larger np, it may be necessary
|
||||
utilize different initial guesses in the vicinity of x = -1,+1 [2].
|
||||
|
||||
[1] Gautschi, W., & Giordano, C. (2008). Luigi Gatteschi’s work on
|
||||
asymptotics of special functions and their zeros. Numerical Algorithms,
|
||||
49, 11-31.
|
||||
[2] Hale, N., & Townsend, A. (2013). Fast and accurate computation of
|
||||
Gauss--Legendre and Gauss--Jacobi quadrature nodes and weights.
|
||||
SIAM Journal on Scientific Computing, 35(2), A652-A674.
|
||||
*/
|
||||
ir->SetSize(np);
|
||||
ir->SetPointIndices();
|
||||
ir->SetOrder(2*np - 1);
|
||||
|
||||
if (alpha <= -1.0 || beta <= -1.0)
|
||||
{
|
||||
MFEM_ABORT("Gauss-Jacobi quadrature only defined for alpha > -1 and beta > -1");
|
||||
}
|
||||
// Jacobi weight function is undefined whenever alpha <= -1 or beta <= -1
|
||||
|
||||
if (alpha > 4.0 || beta > 4.0)
|
||||
{
|
||||
MFEM_ABORT("Current Gauss-Jacobi quadrature implementation only tested for alpha <= 4 and beta <= 4");
|
||||
}
|
||||
// current asymptotic expansions for initial guess may perform poorly for large alpha, beta
|
||||
|
||||
switch (np)
|
||||
{
|
||||
case 1:
|
||||
real_t x = (beta - alpha) / (alpha + beta + 2);
|
||||
real_t w = pow(2, alpha + beta + 1) * tgamma(alpha + 2) * tgamma(
|
||||
beta + 2) / (tgamma(alpha + beta + 2));
|
||||
w = 0.5 * w / pow(2, alpha + beta);
|
||||
// map weight to to [0,1], with additional 1/(2^(alpha + beta)) factor coming from mapping
|
||||
// the weight (1-x)^alpha * (1+x)^beta to [0,1] as well.
|
||||
ir->IntPoint(0).Set1w(0.5 * x + 0.5,
|
||||
4.0 * w / ((1.0 - x*x) * (alpha + beta + 2) * (alpha + beta + 2)));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef MFEM_USE_MPFR
|
||||
|
||||
const int n = np;
|
||||
// common constants for Jacobi polynomials
|
||||
real_t ab = alpha + beta;
|
||||
real_t a2_minus_b2 = (alpha - beta) * (alpha + beta);
|
||||
|
||||
// roots of P^(alpha,beta)_n in the interval [-1,1]
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
// rather than using Chebyshev points for initial guess, use Gatteschi's asymptotic expansion for roots of Jacobi
|
||||
// polynomials
|
||||
real_t n_ab_plus_1 = 2 * n + alpha + beta + 1;
|
||||
real_t v = (2 * i + alpha - 0.5) * M_PI / n_ab_plus_1;
|
||||
real_t theta = v + 1.0 / (n_ab_plus_1*n_ab_plus_1) * ((0.25 - alpha*alpha) *
|
||||
1.0/tan(0.5*v) - (0.25 - beta*beta) * tan(0.5*v));
|
||||
real_t z = cos(theta);
|
||||
|
||||
real_t pp, p1, dz, xi = 0.;
|
||||
bool done = false;
|
||||
while (1)
|
||||
{
|
||||
real_t p2 = 1;
|
||||
p1 = ((alpha-beta) + (alpha + beta + 2) * z) / 2;
|
||||
for (int j = 1; j <= n-1; j++)
|
||||
{
|
||||
real_t p3 = p2;
|
||||
p2 = p1;
|
||||
|
||||
real_t jx2_ab = 2 * j + ab;
|
||||
real_t an = (jx2_ab) * (jx2_ab + 2);
|
||||
real_t bn = a2_minus_b2;
|
||||
real_t cn = 2 * (j + alpha) * (j + beta) * (jx2_ab + 2) / (jx2_ab + 1);
|
||||
|
||||
real_t D = (jx2_ab + 1) / (2 * (j + 1) * (j + ab + 1) * (jx2_ab));
|
||||
p1 = ((an * z + bn) * p2 - cn * p3) * D;
|
||||
}
|
||||
// p1 is Jacobi polynomial
|
||||
pp = n * (alpha - beta - (2 * n + ab) * z) * p1 + 2 * (n + alpha) *
|
||||
(n + beta) * p2;
|
||||
pp = pp / ((2 * n + ab) * (1 - z*z));
|
||||
// derivative of the Jacobi polynomial
|
||||
if (done) { break; }
|
||||
|
||||
dz = p1/pp;
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
if (std::abs(dz) < 1e-7)
|
||||
#elif defined MFEM_USE_DOUBLE
|
||||
if (std::abs(dz) < std::numeric_limits<real_t>::epsilon())
|
||||
// this seems to cause trouble if we try std::abs(dz) < 1e-16
|
||||
#else
|
||||
MFEM_ABORT("Floating point type undefined");
|
||||
// if (std::abs(dz) < 1e-16)
|
||||
#endif
|
||||
{
|
||||
done = true;
|
||||
xi = z - dz;
|
||||
}
|
||||
z -= dz;
|
||||
}
|
||||
real_t c0 = exp(lgamma(n + alpha + 1) - lgamma(n + ab + 1)) * exp(lgamma(
|
||||
n + beta + 1) - lgamma(n + 1));
|
||||
// ratio of gamma functions prone to overflow for large n, so compute logarithms
|
||||
// of Gamma function instead, i.e. Gamma(a)/Gamma(b) = exp(lgamma(a) - lgamma(b))
|
||||
ir->IntPoint(n-i).x = 0.5 * xi + 0.5;
|
||||
ir->IntPoint(n-i).weight = 0.5 * c0 * pow(2.0,
|
||||
ab + 1) / ((1.0 - xi*xi)*pp*pp) / pow(2, ab);
|
||||
// map nodes and weights to the interval [0,1]
|
||||
}
|
||||
|
||||
#else // MFEM_USE_MPFR is defined
|
||||
|
||||
MFEM_ABORT("MPFR implementation of Gauss-Jacobi quadrature not defined yet");
|
||||
|
||||
#endif // MFEM_USE_MPFR
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QuadratureFunctions1D::GaussLegendre(const int np, IntegrationRule* ir)
|
||||
{
|
||||
ir->SetSize(np);
|
||||
@@ -2362,6 +2550,194 @@ IntegrationRule *IntegrationRules::CubeIntegrationRule(int Order)
|
||||
return CubeIntRules[Order];
|
||||
}
|
||||
|
||||
StroudIntegrationRules StroudIntRules;
|
||||
|
||||
StroudIntegrationRules::StroudIntegrationRules()
|
||||
{
|
||||
const MemoryType h_mt = MemoryType::HOST;
|
||||
SquareStroudIntRules.SetSize(32, h_mt);
|
||||
SquareStroudIntRules = NULL;
|
||||
|
||||
TriangleStroudIntRules.SetSize(32, h_mt);
|
||||
TriangleStroudIntRules = NULL;
|
||||
|
||||
CubeStroudIntRules.SetSize(32, h_mt);
|
||||
CubeStroudIntRules = NULL;
|
||||
|
||||
TetrahedronStroudIntRules.SetSize(32, h_mt);
|
||||
TetrahedronStroudIntRules = NULL;
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
IntRuleLocks.SetSize(Geometry::NUM_GEOMETRIES, h_mt);
|
||||
for (int i = 0; i < Geometry::NUM_GEOMETRIES; i++)
|
||||
{
|
||||
omp_init_lock(&IntRuleLocks[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const IntegrationRule &StroudIntegrationRules::Get(int GeomType, int Order)
|
||||
{
|
||||
Array<IntegrationRule *> *ir_array = NULL;
|
||||
|
||||
switch (GeomType)
|
||||
{
|
||||
case Geometry::TRIANGLE: ir_array = &TriangleStroudIntRules; break;
|
||||
case Geometry::TETRAHEDRON: ir_array = &TetrahedronStroudIntRules; break;
|
||||
case Geometry::INVALID:
|
||||
case Geometry::NUM_GEOMETRIES:
|
||||
MFEM_ABORT("Unknown type of reference element!");
|
||||
default:
|
||||
MFEM_ABORT("Stroud rules only valid for triangular and tetrahedral elements!");
|
||||
}
|
||||
|
||||
if (Order < 0)
|
||||
{
|
||||
Order = 0;
|
||||
}
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
omp_set_lock(&IntRuleLocks[GeomType]);
|
||||
#endif
|
||||
|
||||
if (!HaveIntRule(*ir_array, Order))
|
||||
{
|
||||
IntegrationRule *ir = GenerateIntegrationRule(GeomType, Order);
|
||||
#ifdef MFEM_DEBUG
|
||||
int RealOrder = Order;
|
||||
while (RealOrder+1 < ir_array->Size() && (*ir_array)[RealOrder+1] == ir)
|
||||
{
|
||||
RealOrder++;
|
||||
}
|
||||
MFEM_VERIFY(RealOrder == ir->GetOrder(), "internal error");
|
||||
#else
|
||||
MFEM_CONTRACT_VAR(ir);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
omp_unset_lock(&IntRuleLocks[GeomType]);
|
||||
#endif
|
||||
|
||||
return *(*ir_array)[Order];
|
||||
}
|
||||
|
||||
void StroudIntegrationRules::DeleteIntRuleArray(
|
||||
Array<IntegrationRule *> &ir_array) const
|
||||
{
|
||||
// Many of the intrules have multiple contiguous copies in the ir_array
|
||||
// so we have to be careful to not delete them twice.
|
||||
IntegrationRule *ir = NULL;
|
||||
for (int i = 0; i < ir_array.Size(); i++)
|
||||
{
|
||||
if (ir_array[i] != NULL && ir_array[i] != ir)
|
||||
{
|
||||
ir = ir_array[i];
|
||||
delete ir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StroudIntegrationRules::~StroudIntegrationRules()
|
||||
{
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
for (int i = 0; i < Geometry::NUM_GEOMETRIES; i++)
|
||||
{
|
||||
omp_destroy_lock(&IntRuleLocks[i]);
|
||||
}
|
||||
#endif
|
||||
DeleteIntRuleArray(SquareStroudIntRules);
|
||||
DeleteIntRuleArray(TriangleStroudIntRules);
|
||||
DeleteIntRuleArray(CubeStroudIntRules);
|
||||
DeleteIntRuleArray(TetrahedronStroudIntRules);
|
||||
}
|
||||
|
||||
|
||||
IntegrationRule *StroudIntegrationRules::GenerateIntegrationRule(int GeomType,
|
||||
int Order)
|
||||
{
|
||||
switch (GeomType)
|
||||
{
|
||||
case Geometry::TRIANGLE:
|
||||
return TriangleStroudIntegrationRule(Order);
|
||||
case Geometry::TETRAHEDRON:
|
||||
return TetrahedronStroudIntegrationRule(Order);
|
||||
case Geometry::INVALID:
|
||||
case Geometry::NUM_GEOMETRIES:
|
||||
MFEM_ABORT("Unknown type of reference element!");
|
||||
default:
|
||||
MFEM_ABORT("Stroud rules only valid for triangular and tetrahedral elements!");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Integration rule in reference triangle according to tensor product Gauss-Jacobi rule.
|
||||
The nodes and weights are used in the original form defined on the reference
|
||||
square to evaluate the component 1D basis functions. Mapping to the reference
|
||||
triangle via IntegrationRule::DuffyTrans() occurs only in evaluation of coefficient
|
||||
vectors, see e.g. MassIntegrator::AssemblePASimplex. */
|
||||
IntegrationRule *StroudIntegrationRules::TriangleStroudIntegrationRule(
|
||||
int Order)
|
||||
{
|
||||
int RealOrder = GetSegmentRealOrder(Order);
|
||||
// Order is one of {RealOrder-1,RealOrder}
|
||||
// if (!HaveIntRule(SegmentIntRules, RealOrder))
|
||||
// {
|
||||
// SegmentIntegrationRule(RealOrder);
|
||||
// }
|
||||
IntegrationRule ir_0_0;
|
||||
// Gauss-Jacobi is exact for 2*n-1
|
||||
int n = RealOrder/2 + 1;
|
||||
QuadratureFunctions1D::GaussJacobi(n, 0.0, 0.0, &ir_0_0);
|
||||
|
||||
IntegrationRule ir_1_0;
|
||||
QuadratureFunctions1D::GaussJacobi(n, 1.0, 0.0, &ir_1_0);
|
||||
|
||||
AllocIntRule(TriangleStroudIntRules, RealOrder); // RealOrder >= Order
|
||||
// create rule in unit square
|
||||
TriangleStroudIntRules[RealOrder-1] =
|
||||
TriangleStroudIntRules[RealOrder] =
|
||||
new IntegrationRule(ir_1_0, ir_0_0);
|
||||
// map rule to reference triangle
|
||||
// TriangleStroudIntRules[RealOrder-1]->DuffyTrans(2);
|
||||
*TriangleStroudIntRules[RealOrder-1] =
|
||||
DuffyTrans(*TriangleStroudIntRules[RealOrder-1], 2);
|
||||
return TriangleStroudIntRules[Order];
|
||||
}
|
||||
|
||||
/* Integration rule in reference tetrahedron according to tensor product Gauss-Jacobi rule.
|
||||
The nodes and weights are used in the original form defined on the reference
|
||||
square to evaluate the component 1D basis functions. Mapping to the reference
|
||||
triangle via IntegrationRule::DuffyTrans() occurs only in evaluation of coefficient
|
||||
vectors, see e.g. MassIntegrator::AssemblePASimplex. */
|
||||
IntegrationRule *StroudIntegrationRules::TetrahedronStroudIntegrationRule(
|
||||
int Order)
|
||||
{
|
||||
int RealOrder = GetSegmentRealOrder(Order);
|
||||
// Order is one of {RealOrder-1,RealOrder}
|
||||
|
||||
IntegrationRule ir_0_0;
|
||||
int n = RealOrder/2 + 1;
|
||||
QuadratureFunctions1D::GaussJacobi(n, 0.0, 0.0, &ir_0_0);
|
||||
|
||||
IntegrationRule ir_1_0;
|
||||
QuadratureFunctions1D::GaussJacobi(n, 1.0, 0.0, &ir_1_0);
|
||||
|
||||
IntegrationRule ir_2_0;
|
||||
QuadratureFunctions1D::GaussJacobi(n, 2.0, 0.0, &ir_2_0);
|
||||
|
||||
AllocIntRule(TetrahedronStroudIntRules, RealOrder); // RealOrder >= Order
|
||||
// create rule in unit cube
|
||||
TetrahedronStroudIntRules[RealOrder-1] =
|
||||
TetrahedronStroudIntRules[RealOrder] =
|
||||
new IntegrationRule(ir_2_0, ir_1_0, ir_0_0);
|
||||
// map rule to reference tetrahedron
|
||||
// TetrahedronStroudIntRules[RealOrder-1]->DuffyTrans(3);
|
||||
*TetrahedronStroudIntRules[RealOrder-1] =
|
||||
DuffyTrans(*TetrahedronStroudIntRules[RealOrder-1], 3);
|
||||
return TetrahedronStroudIntRules[Order];
|
||||
}
|
||||
|
||||
IntegrationRule& NURBSMeshRules::GetElementRule(const int elem,
|
||||
const int patch, const int *ijk,
|
||||
Array<const KnotVector*> const& kv) const
|
||||
|
||||
@@ -269,6 +269,13 @@ public:
|
||||
/// applying this rule on each knot interval.
|
||||
IntegrationRule* ApplyToKnotIntervals(KnotVector const& kv) const;
|
||||
|
||||
/** @brief Returns an integration rule such that the new IntegrationPoints
|
||||
* are re-ordered based on @a ordering.
|
||||
*
|
||||
* @details In the new integration rule, ip_new[i] = ip_old[ordering[i]]
|
||||
*/
|
||||
IntegrationRule Reorder(const Array<int> &ordering) const;
|
||||
|
||||
/// Destroys an IntegrationRule object
|
||||
~IntegrationRule() { }
|
||||
};
|
||||
@@ -378,6 +385,8 @@ public:
|
||||
These methods calculate the actual points and weights for the different
|
||||
types of quadrature rules. */
|
||||
///@{
|
||||
static void GaussJacobi(const int np, const real_t alpha, const real_t beta,
|
||||
IntegrationRule* ir);
|
||||
static void GaussLegendre(const int np, IntegrationRule* ir);
|
||||
static void GaussLobatto(const int np, IntegrationRule *ir);
|
||||
static void OpenUniform(const int np, IntegrationRule *ir);
|
||||
@@ -487,12 +496,71 @@ public:
|
||||
~IntegrationRules();
|
||||
};
|
||||
|
||||
/// Container class for integration rules
|
||||
class StroudIntegrationRules
|
||||
{
|
||||
private:
|
||||
Array<IntegrationRule *> SquareStroudIntRules;
|
||||
Array<IntegrationRule *> TriangleStroudIntRules;
|
||||
Array<IntegrationRule *> CubeStroudIntRules;
|
||||
Array<IntegrationRule *> TetrahedronStroudIntRules;
|
||||
|
||||
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
|
||||
Array<omp_lock_t> IntRuleLocks;
|
||||
#endif
|
||||
|
||||
void AllocIntRule(Array<IntegrationRule *> &ir_array, int Order) const
|
||||
{
|
||||
if (ir_array.Size() <= Order)
|
||||
{
|
||||
ir_array.SetSize(Order + 1, NULL);
|
||||
}
|
||||
}
|
||||
bool HaveIntRule(Array<IntegrationRule *> &ir_array, int Order) const
|
||||
{
|
||||
return (ir_array.Size() > Order && ir_array[Order] != NULL);
|
||||
}
|
||||
int GetSegmentRealOrder(int Order) const
|
||||
{
|
||||
return Order | 1; // valid for all quad_type's
|
||||
}
|
||||
void DeleteIntRuleArray(Array<IntegrationRule *> &ir_array) const;
|
||||
|
||||
/// The following methods allocate new IntegrationRule objects without
|
||||
/// checking if they already exist. To avoid memory leaks use
|
||||
/// IntegrationRules::Get(int GeomType, int Order) instead.
|
||||
IntegrationRule *GenerateIntegrationRule(int GeomType, int Order);
|
||||
IntegrationRule *TriangleStroudIntegrationRule(int Order);
|
||||
IntegrationRule *TetrahedronStroudIntegrationRule(int Order);
|
||||
|
||||
public:
|
||||
/// Sets initial sizes for the integration rule arrays, but rules
|
||||
/// are defined the first time they are requested with the Get method.
|
||||
explicit StroudIntegrationRules();
|
||||
|
||||
/// Returns a Stroud integration rule for given GeomType and Order.
|
||||
const IntegrationRule &Get(int GeomType, int Order);
|
||||
|
||||
/// Destroys an StroudIntegrationRules object
|
||||
~StroudIntegrationRules();
|
||||
};
|
||||
|
||||
/// A global object with all integration rules (defined in intrules.cpp)
|
||||
extern MFEM_EXPORT IntegrationRules IntRules;
|
||||
|
||||
/// A global object with all refined integration rules
|
||||
extern MFEM_EXPORT IntegrationRules RefinedIntRules;
|
||||
|
||||
/// A global object with all Stroud integration rules (defined in intrules.cpp)
|
||||
extern MFEM_EXPORT StroudIntegrationRules StroudIntRules;
|
||||
|
||||
/// Duffy Transformation of 2D and 3D tensor product rules of the form
|
||||
/// $X(t) = \sum_{i=1}^{d+1} \lambda_i(t) * x_i$, where $x_i$ are the vertices
|
||||
/// of the simplex and $\lambda_i = t_i * (1-\lambda_1-...-\lambda_{i-1})$, with
|
||||
/// $t$ being the coordinates in the unit square/cube. This function is used only
|
||||
/// in the partial assembly of Bernstein elements on simplices and does NOT
|
||||
/// modify the quadrature weights.
|
||||
IntegrationRule DuffyTrans(const IntegrationRule &ir, int dim);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -284,12 +284,12 @@ GeometricMultigrid::GeometricMultigrid(
|
||||
ownedProlongations.SetSize(nlevels - 1);
|
||||
ownedProlongations = have_ess_bdr;
|
||||
|
||||
if (have_ess_bdr)
|
||||
essentialTrueDofs.SetSize(nlevels);
|
||||
for (int level = 0; level < nlevels; ++level)
|
||||
{
|
||||
essentialTrueDofs.SetSize(nlevels);
|
||||
for (int level = 0; level < nlevels; ++level)
|
||||
essentialTrueDofs[level] = new Array<int>;
|
||||
if (have_ess_bdr)
|
||||
{
|
||||
essentialTrueDofs[level] = new Array<int>;
|
||||
fespaces.GetFESpaceAtLevel(level).GetEssentialTrueDofs(
|
||||
ess_bdr, *essentialTrueDofs[level]);
|
||||
}
|
||||
|
||||
+1
-2
@@ -187,8 +187,7 @@ public:
|
||||
/// mesh boundary element attributes that define the essential DOFs.
|
||||
///
|
||||
/// If @a ess_bdr is empty, or all its entries are 0, then no essential
|
||||
/// boundary conditions are imposed and the protected array essentialTrueDofs
|
||||
/// remains empty.
|
||||
/// boundary conditions are imposed.
|
||||
GeometricMultigrid(const FiniteElementSpaceHierarchy& fespaces_,
|
||||
const Array<int> &ess_bdr);
|
||||
|
||||
|
||||
+31
-3
@@ -349,6 +349,7 @@ void ParFiniteElementSpace::GetGroupComm(
|
||||
}
|
||||
}
|
||||
|
||||
bool have_sign_flips = false;
|
||||
if (g_ldof_sign)
|
||||
{
|
||||
g_ldof_sign->SetSize(GetNDofs());
|
||||
@@ -428,6 +429,7 @@ void ParFiniteElementSpace::GetGroupComm(
|
||||
if (g_ldof_sign)
|
||||
{
|
||||
(*g_ldof_sign)[dofs[l]] = -1;
|
||||
have_sign_flips = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -466,6 +468,7 @@ void ParFiniteElementSpace::GetGroupComm(
|
||||
if (g_ldof_sign)
|
||||
{
|
||||
(*g_ldof_sign)[dofs[l]] = -1;
|
||||
have_sign_flips = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -504,6 +507,7 @@ void ParFiniteElementSpace::GetGroupComm(
|
||||
if (g_ldof_sign)
|
||||
{
|
||||
(*g_ldof_sign)[dofs[l]] = -1;
|
||||
have_sign_flips = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -527,12 +531,18 @@ void ParFiniteElementSpace::GetGroupComm(
|
||||
group_ldof.GetI()[gr+1] = group_ldof_counter;
|
||||
}
|
||||
|
||||
if (g_ldof_sign && have_sign_flips == false)
|
||||
{
|
||||
g_ldof_sign->DeleteAll();
|
||||
}
|
||||
|
||||
gc.Finalize();
|
||||
}
|
||||
|
||||
void ParFiniteElementSpace::ApplyLDofSigns(Array<int> &dofs) const
|
||||
{
|
||||
MFEM_ASSERT(Conforming(), "wrong code path");
|
||||
if (!HaveDofSigns()) { return; }
|
||||
|
||||
for (int i = 0; i < dofs.Size(); i++)
|
||||
{
|
||||
@@ -559,6 +569,24 @@ void ParFiniteElementSpace::ApplyLDofSigns(Table &el_dof) const
|
||||
ApplyLDofSigns(all_dofs);
|
||||
}
|
||||
|
||||
void ParFiniteElementSpace::ApplyDofSigns(real_t *h_data) const
|
||||
{
|
||||
if (!HaveDofSigns()) { return; }
|
||||
|
||||
const bool byvdim = (ordering == Ordering::byVDIM);
|
||||
for (int i = 0; i < ndofs; i++)
|
||||
{
|
||||
if (ldof_sign[i] < 0)
|
||||
{
|
||||
for (int d = 0; d < vdim; d++)
|
||||
{
|
||||
const int idx = byvdim ? d+vdim*i : i+ndofs*d;
|
||||
h_data[idx] = -h_data[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParFiniteElementSpace::GetElementDofs(int i, Array<int> &dofs,
|
||||
DofTransformation &doftrans) const
|
||||
{
|
||||
@@ -1193,15 +1221,15 @@ void ParFiniteElementSpace::GetEssentialTrueDofsVar(const Array<int>
|
||||
MFEM_VERIFY(IsVariableOrder() && R,
|
||||
"GetEssentialTrueDofsVar is only for variable-order spaces");
|
||||
|
||||
true_ess_dofs.SetSize(R->Height(), Device::GetDeviceMemoryType());
|
||||
true_ess_dofs.SetSize(R->Height());
|
||||
true_ess_dofs.HostWrite();
|
||||
true_ess_dofs = 0;
|
||||
|
||||
const int ntdofs = tdof2ldof.Size();
|
||||
MFEM_VERIFY(vdim * ntdofs == R->NumRows() &&
|
||||
vdim * ntdofs == true_ess_dofs.Size(), "");
|
||||
MFEM_VERIFY(ldof_ltdof.Size() == ndofs && ess_dofs.Size() == vdim * ndofs, "");
|
||||
|
||||
true_ess_dofs = 0;
|
||||
|
||||
const bool bynodes = (ordering == Ordering::byNODES);
|
||||
const int vdim_factor = bynodes ? 1 : vdim;
|
||||
const int num_true_dofs = R->NumRows() / vdim;
|
||||
|
||||
+14
-2
@@ -340,8 +340,20 @@ public:
|
||||
|
||||
inline ParMesh *GetParMesh() const { return pmesh; }
|
||||
|
||||
int GetDofSign(int i)
|
||||
{ return NURBSext || Nonconforming() ? 1 : ldof_sign[VDofToDof(i)]; }
|
||||
/** @brief Return true if the parallel FE space has DOFs with signs opposite
|
||||
of the DOFs in the respective serial FE space. */
|
||||
bool HaveDofSigns() const { return ldof_sign.Size() != 0; }
|
||||
|
||||
/** @brief Apply the DOF signs to the given host data @a h_data which must be
|
||||
of size GetVSize() if HaveDofSigns() is true. If HaveDofSigns() is false,
|
||||
this method is no-op and returns immediately. */
|
||||
void ApplyDofSigns(real_t *h_data) const;
|
||||
|
||||
/** @brief Return -1 if the given (vector) DOF @a i has a sign opposite of
|
||||
the DOF in the respecive serial FE space. Otherwise, return 1. */
|
||||
int GetDofSign(int i) const
|
||||
{ return !HaveDofSigns() ? 1 : ldof_sign[VDofToDof(i)]; }
|
||||
|
||||
HYPRE_BigInt *GetDofOffsets() const { return dof_offsets; }
|
||||
HYPRE_BigInt *GetTrueDofOffsets() const { return tdof_offsets; }
|
||||
HYPRE_BigInt GlobalVSize() const
|
||||
|
||||
+18
-9
@@ -80,6 +80,8 @@ ParGridFunction::ParGridFunction(ParMesh *pmesh, std::istream &input)
|
||||
fes->GetOrdering());
|
||||
delete fes;
|
||||
fes = pfes;
|
||||
|
||||
pfes->ApplyDofSigns(HostReadWrite());
|
||||
}
|
||||
|
||||
void ParGridFunction::Update()
|
||||
@@ -1082,18 +1084,17 @@ real_t ParGridFunction::ComputeDGFaceJumpError(Coefficient *exsol,
|
||||
|
||||
void ParGridFunction::Save(std::ostream &os) const
|
||||
{
|
||||
real_t *data_ = const_cast<real_t*>(HostRead());
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (pfes->GetDofSign(i) < 0) { data_[i] = -data_[i]; }
|
||||
}
|
||||
// We use const_cast + HostRead (instead of HostReadWrite) because we only
|
||||
// need to change the host data temporarily and this way we do not invalidate
|
||||
// the data if it is on device. If we use HostReadWrite here, later calls to
|
||||
// Read or ReadWrite will need to copy the data from host to device. With the
|
||||
// approach used here, the host-to-device copy is avoided.
|
||||
real_t *h_data = const_cast<real_t*>(HostRead());
|
||||
pfes->ApplyDofSigns(h_data);
|
||||
|
||||
GridFunction::Save(os);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (pfes->GetDofSign(i) < 0) { data_[i] = -data_[i]; }
|
||||
}
|
||||
pfes->ApplyDofSigns(h_data);
|
||||
}
|
||||
|
||||
void ParGridFunction::Save(const char *fname, int precision) const
|
||||
@@ -1264,7 +1265,13 @@ void ParGridFunction::SaveAsOne(std::ostream &os) const
|
||||
int *nfdofs = new int[NRanks];
|
||||
int *nrdofs = new int[NRanks];
|
||||
|
||||
// We use const_cast + HostRead (instead of HostReadWrite) because we only
|
||||
// need to change the host data temporarily and this way we do not invalidate
|
||||
// the data if it is on device. If we use HostReadWrite here, later calls to
|
||||
// Read or ReadWrite will need to copy the data from host to device. With the
|
||||
// approach used here, the host-to-device copy is avoided.
|
||||
real_t * h_data = const_cast<real_t *>(this->HostRead());
|
||||
pfes->ApplyDofSigns(h_data); // temporarily flip the dof signs
|
||||
|
||||
values[0] = h_data;
|
||||
nv[0] = pfes -> GetVSize();
|
||||
@@ -1371,6 +1378,8 @@ void ParGridFunction::SaveAsOne(std::ostream &os) const
|
||||
MPI_Send(h_data, nv[0], MPITypeMap<real_t>::mpi_type, 0, 460, MyComm);
|
||||
}
|
||||
|
||||
pfes->ApplyDofSigns(h_data); // restore the original h_data
|
||||
|
||||
delete [] values;
|
||||
delete [] nv;
|
||||
delete [] nvdofs;
|
||||
|
||||
+9
-2
@@ -50,14 +50,21 @@ ElementRestriction::ElementRestriction(const FiniteElementSpace &f,
|
||||
const FiniteElement *fe = fes.GetFE(e);
|
||||
auto el_t = dynamic_cast<const TensorBasisElement*>(fe);
|
||||
auto el_n = dynamic_cast<const NodalFiniteElement*>(fe);
|
||||
if (el_t || el_n) { continue; }
|
||||
auto el_p = dynamic_cast<const H1Pos_TriangleElement*>(fe) ||
|
||||
dynamic_cast<const H1Pos_TetrahedronElement*>(fe);
|
||||
if (el_t || el_n || el_p) { continue; }
|
||||
MFEM_ABORT("Finite element not suitable for lexicographic ordering");
|
||||
}
|
||||
const FiniteElement *fe = fes.GetTypicalFE();
|
||||
auto el_t = dynamic_cast<const TensorBasisElement*>(fe);
|
||||
auto el_n = dynamic_cast<const NodalFiniteElement*>(fe);
|
||||
auto el_p_tri = dynamic_cast<const H1Pos_TriangleElement*>(fe);
|
||||
auto el_p_tet = dynamic_cast<const H1Pos_TetrahedronElement*>(fe);
|
||||
const Array<int> &fe_dof_map =
|
||||
(el_t) ? el_t->GetDofMap() : el_n->GetLexicographicOrdering();
|
||||
el_n ? el_n->GetLexicographicOrdering() :
|
||||
el_t ? el_t->GetDofMap() :
|
||||
el_p_tri ? el_p_tri->GetDofMap() :
|
||||
el_p_tet->GetDofMap();
|
||||
MFEM_VERIFY(fe_dof_map.Size() > 0, "invalid dof map");
|
||||
dof_map = fe_dof_map.HostRead();
|
||||
}
|
||||
|
||||
+348
-102
@@ -3758,7 +3758,8 @@ void TMOP_Integrator::SetInitialMeshPos(const GridFunction *x0)
|
||||
TMOP_Integrator::~TMOP_Integrator()
|
||||
{
|
||||
delete lim_func;
|
||||
delete adapt_lim_gf;
|
||||
for (int i = 0; i < adapt_lim_gf.Size(); i++) { delete adapt_lim_gf[i]; }
|
||||
for (int i = 0; i < adapt_lim_gf0.Size(); i++) { delete adapt_lim_gf0[i]; }
|
||||
delete surf_fit_gf;
|
||||
delete surf_fit_limiter;
|
||||
delete surf_fit_grad;
|
||||
@@ -3797,36 +3798,129 @@ void TMOP_Integrator::EnableLimiting(const GridFunction &n0, Coefficient &w0,
|
||||
|
||||
void TMOP_Integrator::EnableAdaptiveLimiting(const GridFunction &z0,
|
||||
Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae)
|
||||
AdaptivityEvaluator &ae,
|
||||
real_t delta_max)
|
||||
{
|
||||
adapt_lim_gf0 = &z0;
|
||||
delete adapt_lim_gf;
|
||||
adapt_lim_gf = new GridFunction(z0);
|
||||
adapt_lim_coeff = &coeff;
|
||||
adapt_lim_eval = &ae;
|
||||
|
||||
adapt_lim_eval->SetSerialMetaInfo(*z0.FESpace()->GetMesh(),
|
||||
*z0.FESpace());
|
||||
adapt_lim_eval->SetInitialField
|
||||
(*adapt_lim_gf->FESpace()->GetMesh()->GetNodes(), *adapt_lim_gf);
|
||||
Array<const GridFunction *> z0_arr(1);
|
||||
Array<Coefficient *> c_arr(1);
|
||||
Array<real_t> d_arr(1);
|
||||
z0_arr[0] = &z0;
|
||||
c_arr[0] = &coeff;
|
||||
d_arr[0] = delta_max;
|
||||
EnableAdaptiveLimiting(z0_arr, c_arr, ae, d_arr);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOP_Integrator::EnableAdaptiveLimiting(const ParGridFunction &z0,
|
||||
Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae)
|
||||
AdaptivityEvaluator &ae,
|
||||
real_t delta_max)
|
||||
{
|
||||
adapt_lim_gf0 = &z0;
|
||||
adapt_lim_pgf0 = &z0;
|
||||
delete adapt_lim_gf;
|
||||
adapt_lim_gf = new GridFunction(z0);
|
||||
adapt_lim_coeff = &coeff;
|
||||
adapt_lim_eval = &ae;
|
||||
Array<const ParGridFunction *> z0_arr(1);
|
||||
Array<Coefficient *> c_arr(1);
|
||||
Array<real_t> d_arr(1);
|
||||
z0_arr[0] = &z0;
|
||||
c_arr[0] = &coeff;
|
||||
d_arr[0] = delta_max;
|
||||
EnableAdaptiveLimiting(z0_arr, c_arr, ae, d_arr);
|
||||
}
|
||||
#endif
|
||||
|
||||
adapt_lim_eval->SetParMetaInfo(*z0.ParFESpace()->GetParMesh(),
|
||||
*z0.ParFESpace());
|
||||
adapt_lim_eval->SetInitialField
|
||||
(*adapt_lim_gf->FESpace()->GetMesh()->GetNodes(), *adapt_lim_gf);
|
||||
void TMOP_Integrator::
|
||||
EnableAdaptiveLimiting(const Array<const GridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae, const Array<real_t> &delta_max)
|
||||
{
|
||||
MFEM_VERIFY(z0.Size() > 0, "Requires at least one field.");
|
||||
MFEM_VERIFY(z0.Size() == coeff.Size(), "Requires one Coefficient per field.");
|
||||
MFEM_VERIFY(z0.Size() == delta_max.Size(), "Requires one delta_max per field.");
|
||||
for (int i = 0; i < delta_max.Size(); i++)
|
||||
{
|
||||
MFEM_VERIFY(delta_max[i] > 0.0, "Requires delta_max > 0.0.");
|
||||
}
|
||||
|
||||
// Verify compatibility of input fields.
|
||||
const FiniteElementSpace *sfes = z0[0]->FESpace();
|
||||
MFEM_VERIFY(sfes->GetVDim() == 1, "Expects scalar input GridFunctions.");
|
||||
const int ndofs = sfes->GetVSize();
|
||||
Mesh *mesh = sfes->GetMesh();
|
||||
MFEM_VERIFY(mesh->GetNodes(), "EnableAdaptiveLimiting requires mesh Nodes.");
|
||||
for (int i = 0; i < z0.Size(); i++)
|
||||
{
|
||||
MFEM_VERIFY(z0[i], "NULL GridFunction pointer.");
|
||||
const FiniteElementSpace *fes_i = z0[i]->FESpace();
|
||||
MFEM_VERIFY(fes_i->GetVDim() == 1, "Expects scalar input GridFunctions.");
|
||||
MFEM_VERIFY(fes_i->GetVSize() == ndofs,
|
||||
"All fields must be on the same FE space.");
|
||||
MFEM_VERIFY(fes_i->GetMesh() == mesh,
|
||||
"All fields must be on the same Mesh.");
|
||||
MFEM_VERIFY(coeff[i], "NULL Coefficient pointer.");
|
||||
}
|
||||
|
||||
// Delete previous adaptive limiting data.
|
||||
for (int i = 0; i < adapt_lim_gf.Size(); i++) { delete adapt_lim_gf[i]; }
|
||||
for (int i = 0; i < adapt_lim_gf0.Size(); i++) { delete adapt_lim_gf0[i]; }
|
||||
|
||||
adapt_lim_coeff.SetSize(coeff.Size());
|
||||
for (int i = 0; i < coeff.Size(); i++) { adapt_lim_coeff[i] = coeff[i]; }
|
||||
adapt_lim_eval = &ae;
|
||||
adapt_lim_delta_max = delta_max;
|
||||
adapt_lim_init_nodes = *mesh->GetNodes();
|
||||
|
||||
// Use one internal vector field (vdim = #fields) so remapping can be done in
|
||||
// one call and incremental remap state (when provided by the evaluator) is
|
||||
// preserved across TMOP iterations.
|
||||
//
|
||||
// Use Ordering::byNODES for the packed vector field so packing / unpacking
|
||||
// can be done with contiguous sub-vector copies (device-friendly).
|
||||
const int nal = z0.Size();
|
||||
const Ordering::Type packed_ord = Ordering::byNODES;
|
||||
|
||||
// Setup the evaluator.
|
||||
#ifdef MFEM_USE_MPI
|
||||
if (auto pfes = dynamic_cast<const ParFiniteElementSpace *>(sfes))
|
||||
{
|
||||
auto *pm = pfes->GetParMesh();
|
||||
MFEM_VERIFY(pm, "Invalid ParMesh.");
|
||||
ParFiniteElementSpace vfes(pm, pfes->FEColl(), nal, packed_ord);
|
||||
adapt_lim_eval->SetParMetaInfo(*pm, vfes);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
FiniteElementSpace vfes(mesh, sfes->FEColl(), nal, packed_ord);
|
||||
adapt_lim_eval->SetSerialMetaInfo(*mesh, vfes);
|
||||
}
|
||||
|
||||
// Copy the initial fields; remapped fields are initialized to the same data.
|
||||
adapt_lim_gf0.SetSize(z0.Size());
|
||||
adapt_lim_gf.SetSize(z0.Size());
|
||||
for (int i = 0; i < z0.Size(); i++)
|
||||
{
|
||||
adapt_lim_gf0[i] = new GridFunction(*z0[i]);
|
||||
adapt_lim_gf[i] = new GridFunction(*z0[i]);
|
||||
}
|
||||
|
||||
// Initialize the evaluator with the packed vector field.
|
||||
Vector init_field_vec;
|
||||
init_field_vec.SetSize(nal * ndofs, *adapt_lim_gf0[0]);
|
||||
init_field_vec.UseDevice(adapt_lim_gf0[0]->UseDevice());
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
init_field_vec.SetVector(*adapt_lim_gf0[c], c * ndofs);
|
||||
}
|
||||
adapt_lim_eval->SetInitialField(adapt_lim_init_nodes, init_field_vec);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOP_Integrator::
|
||||
EnableAdaptiveLimiting(const Array<const ParGridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae, const Array<real_t> &delta_max)
|
||||
{
|
||||
Array<const GridFunction *> z0_base(z0.Size());
|
||||
for (int i = 0; i < z0.Size(); i++) { z0_base[i] = z0[i]; }
|
||||
EnableAdaptiveLimiting(z0_base, coeff, ae, delta_max);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4147,26 +4241,61 @@ void TMOP_Integrator::GetSurfaceFittingErrors(const Vector &d_loc,
|
||||
|
||||
void TMOP_Integrator::UpdateAfterMeshTopologyChange()
|
||||
{
|
||||
if (adapt_lim_gf)
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{
|
||||
adapt_lim_gf->Update();
|
||||
adapt_lim_eval->SetSerialMetaInfo(*adapt_lim_gf->FESpace()->GetMesh(),
|
||||
*adapt_lim_gf->FESpace());
|
||||
adapt_lim_eval->SetInitialField
|
||||
(*adapt_lim_gf->FESpace()->GetMesh()->GetNodes(), *adapt_lim_gf);
|
||||
for (int i = 0; i < adapt_lim_gf0.Size(); i++) { adapt_lim_gf0[i]->Update(); }
|
||||
for (int i = 0; i < adapt_lim_gf.Size(); i++) { adapt_lim_gf[i]->Update(); }
|
||||
|
||||
Mesh *mesh = adapt_lim_gf[0]->FESpace()->GetMesh();
|
||||
|
||||
// Same setup as in EnableAdaptiveLimiting().
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
const Ordering::Type packed_ord = Ordering::byNODES;
|
||||
FiniteElementSpace vfes(mesh, adapt_lim_gf[0]->FESpace()->FEColl(), nal,
|
||||
packed_ord);
|
||||
adapt_lim_eval->SetSerialMetaInfo(*mesh, vfes);
|
||||
|
||||
adapt_lim_init_nodes = *mesh->GetNodes();
|
||||
const int ndofs = adapt_lim_gf0[0]->Size();
|
||||
Vector init_field_vec;
|
||||
init_field_vec.SetSize(nal * ndofs, *adapt_lim_gf0[0]);
|
||||
init_field_vec.UseDevice(adapt_lim_gf0[0]->UseDevice());
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
init_field_vec.SetVector(*adapt_lim_gf0[c], c * ndofs);
|
||||
}
|
||||
adapt_lim_eval->SetInitialField(adapt_lim_init_nodes, init_field_vec);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOP_Integrator::ParUpdateAfterMeshTopologyChange()
|
||||
{
|
||||
if (adapt_lim_gf)
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{
|
||||
adapt_lim_gf->Update();
|
||||
adapt_lim_eval->SetParMetaInfo(*adapt_lim_pgf0->ParFESpace()->GetParMesh(),
|
||||
*adapt_lim_pgf0->ParFESpace());
|
||||
adapt_lim_eval->SetInitialField
|
||||
(*adapt_lim_gf->FESpace()->GetMesh()->GetNodes(), *adapt_lim_gf);
|
||||
for (int i = 0; i < adapt_lim_gf0.Size(); i++) { adapt_lim_gf0[i]->Update(); }
|
||||
for (int i = 0; i < adapt_lim_gf.Size(); i++) { adapt_lim_gf[i]->Update(); }
|
||||
|
||||
// Same setup as in EnableAdaptiveLimiting().
|
||||
auto *pfes = dynamic_cast<ParFiniteElementSpace *>(adapt_lim_gf[0]->FESpace());
|
||||
MFEM_VERIFY(pfes, "internal error");
|
||||
ParMesh *pmesh = pfes->GetParMesh();
|
||||
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
const Ordering::Type packed_ord = Ordering::byNODES;
|
||||
ParFiniteElementSpace vfes(pmesh, pfes->FEColl(), nal, packed_ord);
|
||||
adapt_lim_eval->SetParMetaInfo(*pmesh, vfes);
|
||||
|
||||
adapt_lim_init_nodes = *pmesh->GetNodes();
|
||||
const int ndofs = adapt_lim_gf0[0]->Size();
|
||||
Vector init_field_vec;
|
||||
init_field_vec.SetSize(nal * ndofs, *adapt_lim_gf0[0]);
|
||||
init_field_vec.UseDevice(adapt_lim_gf0[0]->UseDevice());
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
init_field_vec.SetVector(*adapt_lim_gf0[c], c * ndofs);
|
||||
}
|
||||
adapt_lim_eval->SetInitialField(adapt_lim_init_nodes, init_field_vec);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4198,7 +4327,8 @@ real_t TMOP_Integrator::GetElementEnergy(const FiniteElement &el,
|
||||
// No adaptive limiting / surface fitting terms if the function is called
|
||||
// as part of a FD derivative computation (because we include the exact
|
||||
// derivatives of these terms in FD computations).
|
||||
const bool adaptive_limiting = (adapt_lim_gf && fd_call_flag == false);
|
||||
const bool adaptive_limiting = (adapt_lim_gf.Size() > 0 &&
|
||||
fd_call_flag == false);
|
||||
const bool surface_fit = (surf_fit_marker && fd_call_flag == false);
|
||||
|
||||
DSh.SetSize(dof, dim);
|
||||
@@ -4261,11 +4391,21 @@ real_t TMOP_Integrator::GetElementEnergy(const FiniteElement &el,
|
||||
// the physical coordinates (i.e. changes in 'elfun'), e.g. when the
|
||||
// coefficient is a ConstantCoefficient or a GridFunctionCoefficient.
|
||||
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
const int nqp = ir.GetNPoints();
|
||||
Vector adapt_lim_gf_q, adapt_lim_gf0_q;
|
||||
if (adaptive_limiting)
|
||||
{
|
||||
adapt_lim_gf->GetValues(el_id, ir, adapt_lim_gf_q);
|
||||
adapt_lim_gf0->GetValues(el_id, ir, adapt_lim_gf0_q);
|
||||
adapt_lim_gf_q.SetSize(nal * nqp);
|
||||
adapt_lim_gf0_q.SetSize(nal * nqp);
|
||||
Vector zc, z0c;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
zc.MakeRef(adapt_lim_gf_q, c * nqp, nqp);
|
||||
z0c.MakeRef(adapt_lim_gf0_q, c * nqp, nqp);
|
||||
adapt_lim_gf[c]->GetValues(el_id, ir, zc);
|
||||
adapt_lim_gf0[c]->GetValues(el_id, ir, z0c);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
@@ -4297,8 +4437,13 @@ real_t TMOP_Integrator::GetElementEnergy(const FiniteElement &el,
|
||||
// Contribution from the adaptive limiting term.
|
||||
if (adaptive_limiting)
|
||||
{
|
||||
const real_t diff = adapt_lim_gf_q(i) - adapt_lim_gf0_q(i);
|
||||
val += adapt_lim_coeff->Eval(*Tpr, ip) * lim_normal * diff * diff;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const int idx = c * nqp + i;
|
||||
const real_t diff = (adapt_lim_gf_q(idx) - adapt_lim_gf0_q(idx)) /
|
||||
adapt_lim_delta_max[c];
|
||||
val += adapt_lim_coeff[c]->Eval(*Tpr, ip) * lim_normal * diff * diff;
|
||||
}
|
||||
}
|
||||
|
||||
energy += weight * val;
|
||||
@@ -4591,7 +4736,7 @@ void TMOP_Integrator::AssembleElementVectorExact(const FiniteElement &el,
|
||||
|
||||
// Define ref->physical transformation, when a Coefficient is specified.
|
||||
IsoparametricTransformation *Tpr = NULL;
|
||||
if (metric_coeff || lim_coeff || adapt_lim_gf ||
|
||||
if (metric_coeff || lim_coeff || adapt_lim_gf.Size() > 0 ||
|
||||
surf_fit_gf || surf_fit_pos || exact_action)
|
||||
{
|
||||
Tpr = new IsoparametricTransformation;
|
||||
@@ -4689,7 +4834,7 @@ void TMOP_Integrator::AssembleElementVectorExact(const FiniteElement &el,
|
||||
}
|
||||
}
|
||||
|
||||
if (adapt_lim_gf) { AssembleElemVecAdaptLim(el, *Tpr, ir, weights, PMatO); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleElemVecAdaptLim(el, *Tpr, ir, weights, PMatO); }
|
||||
if (surf_fit_gf || surf_fit_pos) { AssembleElemVecSurfFit(el, *Tpr, PMatO); }
|
||||
|
||||
delete Tpr;
|
||||
@@ -4763,7 +4908,8 @@ void TMOP_Integrator::AssembleElementGradExact(const FiniteElement &el,
|
||||
|
||||
// Define ref->physical transformation, when a Coefficient is specified.
|
||||
IsoparametricTransformation *Tpr = NULL;
|
||||
if (metric_coeff || lim_coeff || adapt_lim_gf || surf_fit_gf || surf_fit_pos)
|
||||
if (metric_coeff || lim_coeff || adapt_lim_gf.Size() > 0 ||
|
||||
surf_fit_gf || surf_fit_pos)
|
||||
{
|
||||
Tpr = new IsoparametricTransformation;
|
||||
Tpr->SetFE(&el);
|
||||
@@ -4818,7 +4964,7 @@ void TMOP_Integrator::AssembleElementGradExact(const FiniteElement &el,
|
||||
}
|
||||
}
|
||||
|
||||
if (adapt_lim_gf) { AssembleElemGradAdaptLim(el, *Tpr, ir, weights, elmat); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleElemGradAdaptLim(el, *Tpr, ir, weights, elmat); }
|
||||
if (surf_fit_gf || surf_fit_pos) { AssembleElemGradSurfFit(el, *Tpr, elmat);}
|
||||
|
||||
delete Tpr;
|
||||
@@ -4831,32 +4977,42 @@ void TMOP_Integrator::AssembleElemVecAdaptLim(const FiniteElement &el,
|
||||
DenseMatrix &mat)
|
||||
{
|
||||
const int dof = el.GetDof(), dim = el.GetDim(), nqp = weights.Size();
|
||||
Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
|
||||
Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q(nqp), adapt_lim_gf0_q(nqp);
|
||||
Array<int> dofs;
|
||||
adapt_lim_gf->FESpace()->GetElementDofs(Tpr.ElementNo, dofs);
|
||||
adapt_lim_gf->GetSubVector(dofs, adapt_lim_gf_e);
|
||||
adapt_lim_gf->GetValues(Tpr.ElementNo, ir, adapt_lim_gf_q);
|
||||
adapt_lim_gf0->GetValues(Tpr.ElementNo, ir, adapt_lim_gf0_q);
|
||||
adapt_lim_gf[0]->FESpace()->GetElementDofs(Tpr.ElementNo, dofs);
|
||||
|
||||
// Project the gradient of adapt_lim_gf in the same space.
|
||||
// The FE coefficients of the gradient go in adapt_lim_gf_grad_e.
|
||||
DenseMatrix adapt_lim_gf_grad_e(dof, dim);
|
||||
DenseMatrix grad_phys; // This will be (dof x dim, dof).
|
||||
el.ProjectGrad(el, Tpr, grad_phys);
|
||||
Vector grad_ptr(adapt_lim_gf_grad_e.GetData(), dof*dim);
|
||||
grad_phys.Mult(adapt_lim_gf_e, grad_ptr);
|
||||
|
||||
Vector adapt_lim_gf_grad_q(dim);
|
||||
|
||||
for (int q = 0; q < nqp; q++)
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(q);
|
||||
el.CalcShape(ip, shape);
|
||||
adapt_lim_gf_grad_e.MultTranspose(shape, adapt_lim_gf_grad_q);
|
||||
adapt_lim_gf_grad_q *= 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q));
|
||||
adapt_lim_gf_grad_q *= weights(q) * lim_normal * adapt_lim_coeff->Eval(Tpr, ip);
|
||||
AddMultVWt(shape, adapt_lim_gf_grad_q, mat);
|
||||
const real_t delta2 = adapt_lim_delta_max[c] * adapt_lim_delta_max[c];
|
||||
adapt_lim_gf[c]->GetSubVector(dofs, adapt_lim_gf_e);
|
||||
adapt_lim_gf[c]->GetValues(Tpr.ElementNo, ir, adapt_lim_gf_q);
|
||||
adapt_lim_gf0[c]->GetValues(Tpr.ElementNo, ir, adapt_lim_gf0_q);
|
||||
|
||||
DenseMatrix adapt_lim_gf_grad_e(dof, dim);
|
||||
Vector grad_ptr(adapt_lim_gf_grad_e.GetData(), dof*dim);
|
||||
grad_phys.Mult(adapt_lim_gf_e, grad_ptr);
|
||||
|
||||
for (int q = 0; q < nqp; q++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(q);
|
||||
el.CalcShape(ip, shape);
|
||||
|
||||
adapt_lim_gf_grad_e.MultTranspose(shape, adapt_lim_gf_grad_q);
|
||||
adapt_lim_gf_grad_q *= 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) /
|
||||
delta2;
|
||||
adapt_lim_gf_grad_q *=
|
||||
weights(q) * lim_normal * adapt_lim_coeff[c]->Eval(Tpr, ip);
|
||||
|
||||
AddMultVWt(shape, adapt_lim_gf_grad_q, mat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4867,55 +5023,66 @@ void TMOP_Integrator::AssembleElemGradAdaptLim(const FiniteElement &el,
|
||||
DenseMatrix &mat)
|
||||
{
|
||||
const int dof = el.GetDof(), dim = el.GetDim(), nqp = weights.Size();
|
||||
Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
|
||||
Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q(nqp), adapt_lim_gf0_q(nqp);
|
||||
Array<int> dofs;
|
||||
adapt_lim_gf->FESpace()->GetElementDofs(Tpr.ElementNo, dofs);
|
||||
adapt_lim_gf->GetSubVector(dofs, adapt_lim_gf_e);
|
||||
adapt_lim_gf->GetValues(Tpr.ElementNo, ir, adapt_lim_gf_q);
|
||||
adapt_lim_gf0->GetValues(Tpr.ElementNo, ir, adapt_lim_gf0_q);
|
||||
adapt_lim_gf[0]->FESpace()->GetElementDofs(Tpr.ElementNo, dofs);
|
||||
|
||||
// Project the gradient of adapt_lim_gf in the same space.
|
||||
// The FE coefficients of the gradient go in adapt_lim_gf_grad_e.
|
||||
DenseMatrix adapt_lim_gf_grad_e(dof, dim);
|
||||
DenseMatrix grad_phys; // This will be (dof x dim, dof).
|
||||
el.ProjectGrad(el, Tpr, grad_phys);
|
||||
Vector grad_ptr(adapt_lim_gf_grad_e.GetData(), dof*dim);
|
||||
grad_phys.Mult(adapt_lim_gf_e, grad_ptr);
|
||||
|
||||
// Project the gradient of each gradient of adapt_lim_gf in the same space.
|
||||
// The FE coefficients of the second derivatives go in adapt_lim_gf_hess_e.
|
||||
DenseMatrix adapt_lim_gf_hess_e(dof*dim, dim);
|
||||
Mult(grad_phys, adapt_lim_gf_grad_e, adapt_lim_gf_hess_e);
|
||||
// Reshape to be more convenient later (no change in the data).
|
||||
adapt_lim_gf_hess_e.SetSize(dof, dim*dim);
|
||||
|
||||
Vector adapt_lim_gf_grad_q(dim);
|
||||
DenseMatrix adapt_lim_gf_hess_q(dim, dim);
|
||||
|
||||
for (int q = 0; q < nqp; q++)
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(q);
|
||||
el.CalcShape(ip, shape);
|
||||
const real_t delta2 = adapt_lim_delta_max[c] * adapt_lim_delta_max[c];
|
||||
adapt_lim_gf[c]->GetSubVector(dofs, adapt_lim_gf_e);
|
||||
adapt_lim_gf[c]->GetValues(Tpr.ElementNo, ir, adapt_lim_gf_q);
|
||||
adapt_lim_gf0[c]->GetValues(Tpr.ElementNo, ir, adapt_lim_gf0_q);
|
||||
|
||||
adapt_lim_gf_grad_e.MultTranspose(shape, adapt_lim_gf_grad_q);
|
||||
Vector gg_ptr(adapt_lim_gf_hess_q.GetData(), dim*dim);
|
||||
adapt_lim_gf_hess_e.MultTranspose(shape, gg_ptr);
|
||||
DenseMatrix adapt_lim_gf_grad_e(dof, dim);
|
||||
Vector grad_ptr(adapt_lim_gf_grad_e.GetData(), dof*dim);
|
||||
grad_phys.Mult(adapt_lim_gf_e, grad_ptr);
|
||||
|
||||
const real_t w = weights(q) * lim_normal * adapt_lim_coeff->Eval(Tpr, ip);
|
||||
for (int i = 0; i < dof * dim; i++)
|
||||
// Project the gradient of each gradient of adapt_lim_gf in the same space.
|
||||
// The FE coefficients of the second derivatives go in adapt_lim_gf_hess_e.
|
||||
DenseMatrix adapt_lim_gf_hess_e(dof*dim, dim);
|
||||
Mult(grad_phys, adapt_lim_gf_grad_e, adapt_lim_gf_hess_e);
|
||||
// Reshape to be more convenient later (no change in the data).
|
||||
adapt_lim_gf_hess_e.SetSize(dof, dim*dim);
|
||||
|
||||
for (int q = 0; q < nqp; q++)
|
||||
{
|
||||
const int idof = i % dof, idim = i / dof;
|
||||
for (int j = 0; j <= i; j++)
|
||||
const IntegrationPoint &ip = ir.IntPoint(q);
|
||||
el.CalcShape(ip, shape);
|
||||
|
||||
adapt_lim_gf_grad_e.MultTranspose(shape, adapt_lim_gf_grad_q);
|
||||
Vector gg_ptr(adapt_lim_gf_hess_q.GetData(), dim*dim);
|
||||
adapt_lim_gf_hess_e.MultTranspose(shape, gg_ptr);
|
||||
|
||||
const real_t coeff_q = adapt_lim_coeff[c]->Eval(Tpr, ip);
|
||||
const real_t factor =
|
||||
weights(q) * lim_normal * coeff_q * 2.0 /
|
||||
delta2;
|
||||
|
||||
for (int i = 0; i < dof * dim; i++)
|
||||
{
|
||||
const int jdof = j % dof, jdim = j / dof;
|
||||
const real_t entry =
|
||||
w * ( 2.0 * adapt_lim_gf_grad_q(idim) * shape(idof) *
|
||||
/* */ adapt_lim_gf_grad_q(jdim) * shape(jdof) +
|
||||
2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) *
|
||||
adapt_lim_gf_hess_q(idim, jdim) * shape(idof) * shape(jdof));
|
||||
mat(i, j) += entry;
|
||||
if (i != j) { mat(j, i) += entry; }
|
||||
const int idof = i % dof, idim = i / dof;
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
const int jdof = j % dof, jdim = j / dof;
|
||||
const real_t entry =
|
||||
factor *
|
||||
(adapt_lim_gf_grad_q(idim) * shape(idof) *
|
||||
adapt_lim_gf_grad_q(jdim) * shape(jdof) +
|
||||
(adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) *
|
||||
adapt_lim_gf_hess_q(idim, jdim) * shape(idof) * shape(jdof));
|
||||
mat(i, j) += entry;
|
||||
if (i != j) { mat(j, i) += entry; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5188,7 +5355,7 @@ void TMOP_Integrator::AssembleElementVectorFD(const FiniteElement &el,
|
||||
fd_call_flag = false;
|
||||
|
||||
// Contributions from adaptive limiting, surface fitting (exact derivatives).
|
||||
if (adapt_lim_gf || surf_fit_gf || surf_fit_pos)
|
||||
if (adapt_lim_gf.Size() > 0 || surf_fit_gf || surf_fit_pos)
|
||||
{
|
||||
const IntegrationRule &ir = ActionIntegrationRule(el);
|
||||
const int nqp = ir.GetNPoints();
|
||||
@@ -5212,7 +5379,7 @@ void TMOP_Integrator::AssembleElementVectorFD(const FiniteElement &el,
|
||||
}
|
||||
|
||||
PMatO.UseExternalData(elvect.GetData(), dof, dim);
|
||||
if (adapt_lim_gf) { AssembleElemVecAdaptLim(el, Tpr, ir, weights, PMatO); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleElemVecAdaptLim(el, Tpr, ir, weights, PMatO); }
|
||||
if (surf_fit_gf || surf_fit_pos) { AssembleElemVecSurfFit(el, Tpr, PMatO); }
|
||||
}
|
||||
}
|
||||
@@ -5298,7 +5465,7 @@ void TMOP_Integrator::AssembleElementGradFD(const FiniteElement &el,
|
||||
fd_call_flag = false;
|
||||
|
||||
// Contributions from adaptive limiting.
|
||||
if (adapt_lim_gf || surf_fit_gf || surf_fit_pos)
|
||||
if (adapt_lim_gf.Size() > 0 || surf_fit_gf || surf_fit_pos)
|
||||
{
|
||||
const IntegrationRule &ir = GradientIntegrationRule(el);
|
||||
const int nqp = ir.GetNPoints();
|
||||
@@ -5321,7 +5488,7 @@ void TMOP_Integrator::AssembleElementGradFD(const FiniteElement &el,
|
||||
ir.IntPoint(q).weight;
|
||||
}
|
||||
|
||||
if (adapt_lim_gf) { AssembleElemGradAdaptLim(el, Tpr, ir, weights, elmat); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleElemGradAdaptLim(el, Tpr, ir, weights, elmat); }
|
||||
if (surf_fit_gf || surf_fit_pos) { AssembleElemGradSurfFit(el, Tpr, elmat); }
|
||||
}
|
||||
}
|
||||
@@ -5668,9 +5835,46 @@ UpdateAfterMeshPositionChange(const Vector &d, const FiniteElementSpace &d_fes)
|
||||
}
|
||||
|
||||
// Update adapt_lim_gf if adaptive limiting is enabled.
|
||||
if (adapt_lim_gf)
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{
|
||||
adapt_lim_eval->ComputeAtNewPosition(x_loc, *adapt_lim_gf, ordering);
|
||||
// All adapt_lim_gf are remapped as a multi-component vector.
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
const int ndofs = adapt_lim_gf0[0]->Size();
|
||||
Vector new_field_vec;
|
||||
new_field_vec.SetSize(nal * ndofs, *adapt_lim_gf[0]);
|
||||
new_field_vec.UseDevice(adapt_lim_gf[0]->UseDevice());
|
||||
adapt_lim_eval->ComputeAtNewPosition(x_loc, new_field_vec, ordering);
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t *src = new_field_vec.Read() + c * ndofs;
|
||||
real_t *dst = adapt_lim_gf[c]->Write();
|
||||
internal::device_copy(dst, src, ndofs);
|
||||
}
|
||||
|
||||
if (PA.enabled)
|
||||
{
|
||||
PA.AL_grads_assembled = false;
|
||||
|
||||
// Step 1 of PA.ALFmF0 update: subtract the old ALF.
|
||||
PA.ALFmF0 -= PA.ALF;
|
||||
|
||||
// Refresh PA.ALF from the updated adapt_lim_gf.
|
||||
const ElementDofOrdering ord = ElementDofOrdering::LEXICOGRAPHIC;
|
||||
const FiniteElementSpace *alfes = adapt_lim_gf[0]->FESpace();
|
||||
const Operator *alf_R = alfes->GetElementRestriction(ord);
|
||||
|
||||
const int Esize = alf_R->Height();
|
||||
Vector ALFc;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
MFEM_VERIFY(adapt_lim_gf[c]->Size() == ndofs, "internal error");
|
||||
ALFc.MakeRef(PA.ALF, c * Esize, Esize);
|
||||
alf_R->Mult(*adapt_lim_gf[c], ALFc);
|
||||
}
|
||||
|
||||
// Step 2 of PA.ALFmF0 update: add the new ALF.
|
||||
PA.ALFmF0 += PA.ALF;
|
||||
}
|
||||
}
|
||||
|
||||
// Update surf_fit_gf (and optionally its gradients) if surface
|
||||
@@ -5883,7 +6087,7 @@ ComputeUntangleMetricQuantiles(const Vector &d, const FiniteElementSpace &fes)
|
||||
dynamic_cast<const ParFiniteElementSpace *>(&fes);
|
||||
#endif
|
||||
|
||||
if (wcuo && wcuo->GetBarrierType() ==
|
||||
if (wcuo->GetBarrierType() ==
|
||||
TMOP_WorstCaseUntangleOptimizer_Metric::BarrierType::Shifted)
|
||||
{
|
||||
real_t min_detT = ComputeMinDetT(x_loc, fes);
|
||||
@@ -5895,7 +6099,7 @@ ComputeUntangleMetricQuantiles(const Vector &d, const FiniteElementSpace &fes)
|
||||
MPITypeMap<real_t>::mpi_type, MPI_MIN, pfes->GetComm());
|
||||
}
|
||||
#endif
|
||||
if (wcuo) { wcuo->SetMinDetT(min_detT_all); }
|
||||
wcuo->SetMinDetT(min_detT_all);
|
||||
}
|
||||
|
||||
real_t max_muT = ComputeUntanglerMaxMuBarrier(x_loc, fes);
|
||||
@@ -5931,6 +6135,48 @@ void TMOPComboIntegrator::EnableLimiting(const GridFunction &n0,
|
||||
for (int i = 1; i < tmopi.Size(); i++) { tmopi[i]->DisableLimiting(); }
|
||||
}
|
||||
|
||||
void TMOPComboIntegrator::EnableAdaptiveLimiting(const GridFunction &z0,
|
||||
Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
real_t delta_max)
|
||||
{
|
||||
MFEM_VERIFY(tmopi.Size() > 0, "No TMOP_Integrators were added.");
|
||||
|
||||
tmopi[0]->EnableAdaptiveLimiting(z0, coeff, ae, delta_max);
|
||||
}
|
||||
|
||||
void TMOPComboIntegrator::
|
||||
EnableAdaptiveLimiting(const Array<const GridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae, const Array<real_t> &delta_max)
|
||||
{
|
||||
MFEM_VERIFY(tmopi.Size() > 0, "No TMOP_Integrators were added.");
|
||||
|
||||
tmopi[0]->EnableAdaptiveLimiting(z0, coeff, ae, delta_max);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOPComboIntegrator::EnableAdaptiveLimiting(const ParGridFunction &z0,
|
||||
Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
real_t delta_max)
|
||||
{
|
||||
MFEM_VERIFY(tmopi.Size() > 0, "No TMOP_Integrators were added.");
|
||||
|
||||
tmopi[0]->EnableAdaptiveLimiting(z0, coeff, ae, delta_max);
|
||||
}
|
||||
|
||||
void TMOPComboIntegrator::
|
||||
EnableAdaptiveLimiting(const Array<const ParGridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae, const Array<real_t> &delta_max)
|
||||
{
|
||||
MFEM_VERIFY(tmopi.Size() > 0, "No TMOP_Integrators were added.");
|
||||
|
||||
tmopi[0]->EnableAdaptiveLimiting(z0, coeff, ae, delta_max);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOPComboIntegrator::SetLimitingNodes(const GridFunction &n0)
|
||||
{
|
||||
MFEM_VERIFY(tmopi.Size() > 0, "No TMOP_Integrators were added.");
|
||||
|
||||
+93
-19
@@ -1440,6 +1440,7 @@ public:
|
||||
void Eval_d2(const Vector &x, const Vector &x0, real_t dist,
|
||||
DenseMatrix &d2) const override
|
||||
{
|
||||
MFEM_CONTRACT_VAR(x0);
|
||||
MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
|
||||
|
||||
d2.Diag(1.0 / (dist * dist), x.Size());
|
||||
@@ -2037,13 +2038,17 @@ protected:
|
||||
real_t lim_normal;
|
||||
|
||||
// Adaptive limiting.
|
||||
const GridFunction *adapt_lim_gf0; // Not owned.
|
||||
#ifdef MFEM_USE_MPI
|
||||
const ParGridFunction *adapt_lim_pgf0;
|
||||
#endif
|
||||
GridFunction *adapt_lim_gf; // Owned. Updated by adapt_lim_eval.
|
||||
Coefficient *adapt_lim_coeff; // Not owned.
|
||||
AdaptivityEvaluator *adapt_lim_eval; // Not owned.
|
||||
// Adaptive limiting fields. Each field adds a term to the integral:
|
||||
// int [ c_k (z_k(x) - z_k0(x0))^2 / delta_max_k^2 ] dx
|
||||
// with one Coefficient per field. The fields z_k(x) are remapped from their
|
||||
// initial values z_k0(x0) through a single AdaptivityEvaluator instance.
|
||||
// All GridFunctions must use the same FE space.
|
||||
Array<GridFunction *> adapt_lim_gf0; // Owned. Initial fields z_k0(x0).
|
||||
Array<GridFunction *> adapt_lim_gf; // Owned. Remapped fields z_k(x).
|
||||
Vector adapt_lim_init_nodes; // Owned. Initial mesh nodes (ldofs).
|
||||
Array<Coefficient *> adapt_lim_coeff; // Not owned, one per field.
|
||||
AdaptivityEvaluator *adapt_lim_eval; // Not owned. Used for all fields.
|
||||
Array<real_t> adapt_lim_delta_max; // Per-field delta_max_k (>0).
|
||||
|
||||
// Surface fitting.
|
||||
const Array<bool> *surf_fit_marker; // Not owned. Nodes to fit.
|
||||
@@ -2110,9 +2115,20 @@ protected:
|
||||
// Updated by every call to PANonlinearFormExtension::GetGradient().
|
||||
// MC: Q-Vector for the metric Coefficient.
|
||||
// Updated when the mesh nodes change.
|
||||
// ALC: Q-Vector for spatial weight used for the adaptive limiting term.
|
||||
// Updated when the mesh nodes change.
|
||||
// ALF: E-Vector constructed using adaptive limiting GF zeta.
|
||||
// The zeta is remapped when the mesh nodes change.
|
||||
// ALFmF0: E-Vector constructed using adaptive limiting GF zeta.
|
||||
// It stores difference zeta-zeta0, as all computations use this.
|
||||
// ALFG: Q-Vector for gradient of ALF at quadrature points.
|
||||
// Updated by every call to PANonlinearFormExtension::GetGradient().
|
||||
// ALFH: Q-Vector for Hessian of ALF at quadrature points.
|
||||
// Updated by every call to PANonlinearFormExtension::GetGradient().
|
||||
//
|
||||
// maps: Dof2Quad map for fes associated with the nodal coordinates.
|
||||
// maps_lim: Dof2Quad map for fes associated with the limiting dist GridFunc.
|
||||
// maps: Dof2Quad map for fes associated with the nodal coordinates.
|
||||
// maps_lim: Dof2Quad map for fes associated with the limiting dist GF.
|
||||
// maps_nodes: like maps, but the quad points are the FE nodes.
|
||||
//
|
||||
// Jtr_debug_grad
|
||||
// We keep track if Jtr was set by AssembleGradPA() in Jtr_debug_grad: it
|
||||
@@ -2128,12 +2144,16 @@ protected:
|
||||
{
|
||||
bool enabled;
|
||||
int dim, ne, nq;
|
||||
int nal = 0; // number of adaptive limiting fields
|
||||
mutable DenseTensor Jtr;
|
||||
mutable bool Jtr_needs_update;
|
||||
mutable bool Jtr_debug_grad;
|
||||
mutable Vector E, O, X0, XL, H, C0, LD, H0, MC;
|
||||
mutable Vector E, O, X0, XL, H, C0, LD, H0, MC, ALC,
|
||||
ALF, ALFmF0, ALFG, ALFH, ALD;
|
||||
mutable bool AL_grads_assembled;
|
||||
const DofToQuad *maps;
|
||||
const DofToQuad *maps_lim = nullptr;
|
||||
const DofToQuad *maps_nodes = nullptr;
|
||||
const GeometricFactors *geom;
|
||||
const FiniteElementSpace *fes;
|
||||
const IntegrationRule *ir;
|
||||
@@ -2216,16 +2236,25 @@ protected:
|
||||
return EnergyIntegrationRule(el);
|
||||
}
|
||||
|
||||
//
|
||||
// Auxiliary PA methods
|
||||
//
|
||||
|
||||
// PA quadrature data computation - metric term / limiting / adapt limiting.
|
||||
void AssembleGradPA_2D(const Vector&) const;
|
||||
void AssembleGradPA_3D(const Vector&) const;
|
||||
void AssembleGradPA_C0_2D(const Vector&) const;
|
||||
void AssembleGradPA_C0_3D(const Vector&) const;
|
||||
void AssembleGradPA_AdaptLim_2D(const Vector&) const;
|
||||
void AssembleGradPA_AdaptLim_3D(const Vector&) const;
|
||||
|
||||
// PA energy computation - metric term / limiting / adaptive limiting.
|
||||
void GetLocalStateEnergyPA_2D(const Vector &x, real_t &energy) const;
|
||||
void GetLocalStateEnergyPA_3D(const Vector&, real_t &energy) const;
|
||||
void GetLocalStateEnergyPA_3D(const Vector &x, real_t &energy) const;
|
||||
real_t GetLocalStateEnergyPA_C0_2D(const Vector&) const;
|
||||
real_t GetLocalStateEnergyPA_C0_3D(const Vector&) const;
|
||||
real_t GetLocalStateEnergyPA_AdaptLim_2D() const;
|
||||
real_t GetLocalStateEnergyPA_AdaptLim_3D() const;
|
||||
void GetLocalNormalizationEnergiesPA_2D(const Vector &x,
|
||||
real_t &met_energy,
|
||||
real_t &lim_energy) const;
|
||||
@@ -2233,22 +2262,35 @@ protected:
|
||||
real_t &met_energy,
|
||||
real_t &lim_energy) const;
|
||||
|
||||
// PA gradient computation - metric term / limiting / adaptive limiting.
|
||||
void AddMultPA_2D(const Vector&, Vector&) const;
|
||||
void AddMultPA_3D(const Vector&, Vector&) const;
|
||||
void AddMultPA_C0_2D(const Vector&, Vector&) const;
|
||||
void AddMultPA_C0_3D(const Vector&, Vector&) const;
|
||||
void AddMultPA_AdaptLim_2D(const Vector&, Vector&) const;
|
||||
void AddMultPA_AdaptLim_3D(const Vector&, Vector&) const;
|
||||
|
||||
// PA Hessian AddMult - metric term / limiting / adaptive limiting.
|
||||
void AddMultGradPA_2D(const Vector&, Vector&) const;
|
||||
void AddMultGradPA_3D(const Vector&, Vector&) const;
|
||||
void AddMultGradPA_C0_2D(const Vector&, Vector&) const;
|
||||
void AddMultGradPA_C0_3D(const Vector&, Vector&) const;
|
||||
void AddMultGradPA_AdaptLim_2D(const Vector&, Vector&) const;
|
||||
void AddMultGradPA_AdaptLim_3D(const Vector&, Vector&) const;
|
||||
|
||||
// PA diagonal assemblies - metric term / limiting / adaptive limiting.
|
||||
void AssembleDiagonalPA_2D(Vector&) const;
|
||||
void AssembleDiagonalPA_3D(Vector&) const;
|
||||
void AssembleDiagonalPA_C0_2D(Vector&) const;
|
||||
void AssembleDiagonalPA_C0_3D(Vector&) const;
|
||||
void AssembleDiagonalPA_AdaptLim_2D(Vector&) const;
|
||||
void AssembleDiagonalPA_AdaptLim_3D(Vector&) const;
|
||||
|
||||
// Setup of PA data structures related to the limiting term.
|
||||
void AssemblePA_Limiting();
|
||||
// Setup of PA data structures related to the adaptive limiting term.
|
||||
void AssemblePA_AdaptLim();
|
||||
// Compute reference->target Jacobians for all quad points.
|
||||
void ComputeAllElementTargets(const Vector &xe = Vector()) const;
|
||||
// Updates the Q-vectors for the metric_coeff and lim_coeff, based on the
|
||||
// new physical positions of the quadrature points.
|
||||
@@ -2275,7 +2317,6 @@ public:
|
||||
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),
|
||||
adapt_lim_gf0(NULL), adapt_lim_gf(NULL), adapt_lim_coeff(NULL),
|
||||
adapt_lim_eval(NULL),
|
||||
surf_fit_marker(NULL), surf_fit_coeff(NULL),
|
||||
surf_fit_gf(NULL), surf_fit_eval(NULL),
|
||||
@@ -2351,21 +2392,34 @@ public:
|
||||
|
||||
/** @brief Restriction of the node positions to certain regions.
|
||||
|
||||
Adds the term $ \int c (z(x) - z_0(x_0))^2 $, where z0(x0) is a given
|
||||
function on the starting mesh, and z(x) is its image on the new mesh.
|
||||
Minimizing this term means that a node at x0 is allowed to move to a
|
||||
position x(x0) only if z(x) ~ z0(x0).
|
||||
Adds the term $ \int c (z(x) - z_0(x_0))^2 / delta_max^2 $, where z0(x0)
|
||||
is a given function on the starting mesh, and z(x) is its image on the
|
||||
new mesh. Minimizing this term means that a node at x0 is allowed to
|
||||
move to a position x(x0) only if z(x) ~ z0(x0).
|
||||
Such term can be used for tangential mesh relaxation.
|
||||
|
||||
@param[in] z0 Function z0 that controls the adaptive limiting.
|
||||
@param[in] coeff Coefficient c for the above integral.
|
||||
@param[in] ae AdaptivityEvaluator to compute z(x) from z0(x0). */
|
||||
@param[in] ae AdaptivityEvaluator to compute z(x) from z0(x0).
|
||||
@param[in] delta_max Controls the allowable deviation from z0.
|
||||
Smaller values activate the term faster. */
|
||||
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae);
|
||||
AdaptivityEvaluator &ae, real_t delta_max = 1.0);
|
||||
/// Multi-field adaptive limiting with per-field delta_max values. All
|
||||
/// GridFunctions must be on the same FiniteElementSpace.
|
||||
void EnableAdaptiveLimiting(const Array<const GridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
const Array<real_t> &delta_max);
|
||||
#ifdef MFEM_USE_MPI
|
||||
/// Parallel support for adaptive limiting.
|
||||
void EnableAdaptiveLimiting(const ParGridFunction &z0, Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae);
|
||||
AdaptivityEvaluator &ae, real_t delta_max = 1.0);
|
||||
/// Multi-field parallel adaptive limiting with per-field delta_max values.
|
||||
void EnableAdaptiveLimiting(const Array<const ParGridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
const Array<real_t> &delta_max);
|
||||
#endif
|
||||
|
||||
/** @brief Fitting of certain DOFs to the zero level set of a function.
|
||||
@@ -2588,6 +2642,26 @@ public:
|
||||
void EnableLimiting(const GridFunction &n0, Coefficient &w0,
|
||||
TMOP_LimiterFunction *lfunc = NULL);
|
||||
|
||||
/// Adds the adaptive limiting term to the first integrator.
|
||||
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae, real_t delta_max = 1.0);
|
||||
/// Multi-field adaptive limiting with per-field delta_max values.
|
||||
void EnableAdaptiveLimiting(const Array<const GridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
const Array<real_t> &delta_max);
|
||||
#ifdef MFEM_USE_MPI
|
||||
/// Parallel support for adaptive limiting.
|
||||
void EnableAdaptiveLimiting(const ParGridFunction &z0, Coefficient &coeff,
|
||||
AdaptivityEvaluator &ae, real_t delta_max = 1.0);
|
||||
/// Multi-field parallel adaptive limiting with per-field delta_max values.
|
||||
void EnableAdaptiveLimiting(const Array<const ParGridFunction *> &z0,
|
||||
const Array<Coefficient *> &coeff,
|
||||
AdaptivityEvaluator &ae,
|
||||
const Array<real_t> &delta_max);
|
||||
#endif
|
||||
|
||||
|
||||
/// Update the original/reference nodes used for limiting.
|
||||
void SetLimitingNodes(const GridFunction &n0);
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "../pa.hpp"
|
||||
#include "../../tmop.hpp"
|
||||
#include "../../kernels.hpp"
|
||||
#include "../../../general/forall.hpp"
|
||||
#include "../../../linalg/kernels.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -64,6 +66,92 @@ void TMOP_AssembleDiagPA_C0_2D(const int NE,
|
||||
});
|
||||
}
|
||||
|
||||
// Diagonal assembly for AdaptLim limiting (2D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AssembleDiagPA_AdaptLim_2D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<3, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<5, const real_t> &J,
|
||||
const ConstDeviceMatrix &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<4, const real_t> &ALF_grad,
|
||||
const DeviceTensor<5, const real_t> &ALF_hess,
|
||||
const ConstDeviceCube &ALFmF0,
|
||||
DeviceTensor<4> &D,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// ALF and ALF0 values at quad points.
|
||||
kernels::internal::s_regs2d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval2d(D1D, Q1D, smem, sB, alf_dof, alf_quad);
|
||||
|
||||
MFEM_SHARED real_t qd[MQ1 * MD1];
|
||||
DeviceTensor<2, real_t> QD(qd, MQ1, MD1);
|
||||
|
||||
for (int v = 0; v < 2; v++)
|
||||
{
|
||||
// Contract in y.
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
QD(qx, dy) = 0.0;
|
||||
for (int qy = 0; qy < Q1D; ++qy)
|
||||
{
|
||||
const real_t By = sB[dy][qy];
|
||||
const real_t bb = By * By;
|
||||
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, e);
|
||||
const real_t detJtr = kernels::Det<2>(Jtr);
|
||||
const real_t weight = W(qx, qy) * detJtr;
|
||||
const real_t coeff = const_coeff ? ALC(0,0,0) : ALC(qx, qy, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq;
|
||||
|
||||
const real_t diff = alf_quad(qy, qx);
|
||||
const real_t grad_v = ALF_grad(v, qx, qy, e);
|
||||
const real_t hess_vv = ALF_hess(v, v, qx, qy, e);
|
||||
|
||||
QD(qx, dy) += bb * factor * (grad_v*grad_v + diff * hess_vv);
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// Contract in x.
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
real_t d = 0.0;
|
||||
for (int qx = 0; qx < Q1D; ++qx)
|
||||
{
|
||||
const real_t Bx = sB[dx][qx];
|
||||
const real_t bb = Bx * Bx;
|
||||
d += bb * QD(qx, dy);
|
||||
}
|
||||
D(dx, dy, v, e) += d;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleDiagCoef2D, TMOP_AssembleDiagPA_C0_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleDiagCoef2D);
|
||||
|
||||
@@ -80,4 +168,52 @@ void TMOP_Integrator::AssembleDiagonalPA_C0_2D(Vector &diagonal) const
|
||||
TMOPAssembleDiagCoef2D::Run(d, q, NE, B, H0, D, d, q);
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleDiagAdaptLim2D,
|
||||
TMOP_AssembleDiagPA_AdaptLim_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleDiagAdaptLim2D);
|
||||
|
||||
void TMOP_Integrator::AssembleDiagonalPA_AdaptLim_2D(Vector &diagonal) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 2, 2, q, q, NE);
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
auto D = Reshape(diagonal.ReadWrite(), d, d, 2, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d;
|
||||
const int nqp_el = q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 2 * nqp_el * NE;
|
||||
const int ALFH_stride = 2 * 2 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
const real_t *ALFH_all = PA.ALFH.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 2, q, q, NE);
|
||||
const auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 2, 2, q, q, NE);
|
||||
|
||||
TMOPAssembleDiagAdaptLim2D::Run(d, q, ln, delta_max, const_coeff, ALC, NE,
|
||||
J, W, B, ALF_grad, ALF_hess, ALFmF0, D, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "../../tmop.hpp"
|
||||
#include "../../kernels.hpp"
|
||||
#include "../../../general/forall.hpp"
|
||||
#include "../../../linalg/kernels.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -128,4 +129,181 @@ void TMOP_Integrator::AssembleDiagonalPA_C0_3D(Vector &diagonal) const
|
||||
TMOPAssembleDiagCoef3D::Run(d, q, NE, B, H0, D, d, q);
|
||||
}
|
||||
|
||||
// Diagonal assembly for AdaptLim limiting (3D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AssembleDiagPA_AdaptLim_3D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<4, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<6, const real_t> &J,
|
||||
const ConstDeviceCube &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<5, const real_t> &ALF_grad,
|
||||
const DeviceTensor<6, const real_t> &ALF_hess,
|
||||
const DeviceTensor<4, const real_t> &ALFmF0,
|
||||
DeviceTensor<5> &D,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// ALF and ALF0 values at quad points.
|
||||
kernels::internal::s_regs3d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval3d(D1D, Q1D, smem, sB, alf_dof, alf_quad);
|
||||
|
||||
kernels::internal::s_regs3d_t<MQ1> r0, r1;
|
||||
|
||||
for (int v = 0; v < 3; ++v)
|
||||
{
|
||||
// Contract in z.
|
||||
for (int dz = 0; dz < D1D; ++dz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
real_t u = 0.0;
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
const real_t Bz = sB[dz][qz];
|
||||
const real_t bb = Bz * Bz;
|
||||
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, qz, e);
|
||||
const real_t detJtr = kernels::Det<3>(Jtr);
|
||||
const real_t weight = W(qx, qy, qz) * detJtr;
|
||||
const real_t coeff =
|
||||
const_coeff ? ALC(0, 0, 0, 0) : ALC(qx, qy, qz, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq;
|
||||
|
||||
const real_t diff = alf_quad(qz, qy, qx);
|
||||
const real_t grad_v = ALF_grad(v, qx, qy, qz, e);
|
||||
const real_t hess_vv = ALF_hess(v, v, qx, qy, qz, e);
|
||||
|
||||
u += bb * factor * (grad_v * grad_v + diff * hess_vv);
|
||||
}
|
||||
r0[dz][qy][qx] = u;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
// Contract in y.
|
||||
for (int dz = 0; dz < D1D; ++dz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
smem[qy][qx] = r0[dz][qy][qx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
real_t u = 0.0;
|
||||
for (int qy = 0; qy < Q1D; ++qy)
|
||||
{
|
||||
const real_t By = sB[dy][qy];
|
||||
u += (By * By) * smem[qy][qx];
|
||||
}
|
||||
r1[dz][dy][qx] = u;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
// Contract in x.
|
||||
for (int dz = 0; dz < D1D; ++dz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
smem[dy][qx] = r1[dz][dy][qx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
real_t u = 0.0;
|
||||
for (int qx = 0; qx < Q1D; ++qx)
|
||||
{
|
||||
const real_t Bx = sB[dx][qx];
|
||||
u += (Bx * Bx) * smem[dy][qx];
|
||||
}
|
||||
D(dx, dy, dz, v, e) += u;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleDiagAdaptLim3D,
|
||||
TMOP_AssembleDiagPA_AdaptLim_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleDiagAdaptLim3D);
|
||||
|
||||
void TMOP_Integrator::AssembleDiagonalPA_AdaptLim_3D(Vector &diagonal) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 3, 3, q, q, q, NE);
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q, q);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
auto D = Reshape(diagonal.ReadWrite(), d, d, d, 3, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d * d;
|
||||
const int nqp_el = q * q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 3 * nqp_el * NE;
|
||||
const int ALFH_stride = 3 * 3 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
const real_t *ALFH_all = PA.ALFH.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 3, q, q, q, NE);
|
||||
const auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 3, 3, q, q, q, NE);
|
||||
|
||||
TMOPAssembleDiagAdaptLim3D::Run(d, q, ln, delta_max, const_coeff, ALC, NE,
|
||||
J, W, B, ALF_grad, ALF_hess, ALFmF0, D, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -113,6 +113,178 @@ void TMOP_AssembleGradPA_C0_2D(const real_t lim_normal,
|
||||
});
|
||||
}
|
||||
|
||||
// Assemble gradient and Hessian of ALF field at quad points for AdaptLim (2D).
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AssembleGradPA_AdaptLim_2D(const int NE,
|
||||
const real_t *B_nodes,
|
||||
const real_t *G_nodes,
|
||||
const real_t *B,
|
||||
const DeviceTensor<4, const real_t> &X,
|
||||
const ConstDeviceCube &ALF,
|
||||
DeviceTensor<4> &ALF_grad,
|
||||
DeviceTensor<5> &ALF_hess,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
mfem::forall_2D<T_Q1D*T_Q1D>(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
// MD1 x MD1 or MQ1 x MQ1 shared memory block.
|
||||
MFEM_SHARED union { real_t d[MD1][MD1]; real_t q[MQ1][MQ1]; } smem;
|
||||
MFEM_SHARED real_t sB_nodes[MD1][MD1], sG_nodes[MD1][MD1];
|
||||
MFEM_SHARED real_t sB_q[MD1][MQ1];
|
||||
|
||||
kernels::internal::s_regs2d_t<MD1> grad_c;
|
||||
kernels::internal::v_regs2d_t<2, MD1> hess_c;
|
||||
|
||||
// Maps nodes - nodes.
|
||||
kernels::internal::LoadMatrix(D1D, D1D, B_nodes, sB_nodes);
|
||||
kernels::internal::LoadMatrix(D1D, D1D, G_nodes, sG_nodes);
|
||||
// Map nodes - quads.
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, B, sB_q);
|
||||
|
||||
// Compute the physical Jacobian at DOF nodes.
|
||||
kernels::internal::vd_regs2d_t<2, 2, MD1> r_X, r_J;
|
||||
kernels::internal::LoadDofs2d(e, D1D, X, r_X);
|
||||
kernels::internal::Grad2d(D1D, D1D, smem.d, sB_nodes, sG_nodes, r_X, r_J);
|
||||
|
||||
// Compute the reference derivatives of ALF at DOF nodes.
|
||||
kernels::internal::s_regs2d_t<MD1> alf_n, dalf_dx_n, dalf_dy_n;
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALF, alf_n);
|
||||
kernels::internal::Contract2d<false, MD1>(D1D, D1D, smem.d,
|
||||
sG_nodes, sB_nodes,
|
||||
alf_n, dalf_dx_n);
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALF, alf_n);
|
||||
kernels::internal::Contract2d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sG_nodes,
|
||||
alf_n, dalf_dy_n);
|
||||
|
||||
// Interpolation workspaces.
|
||||
kernels::internal::s_regs2d_t<MQ1> r0, r1;
|
||||
|
||||
// Precompute the inverse of the physical Jacobian.
|
||||
kernels::internal::vd_regs2d_t<2, 2, MD1> Jpr_inv;
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
const real_t Jpr[4] =
|
||||
{
|
||||
r_J[0][0][dy][dx], r_J[1][0][dy][dx],
|
||||
r_J[0][1][dy][dx], r_J[1][1][dy][dx]
|
||||
};
|
||||
real_t Jpri[4];
|
||||
kernels::CalcInverse<2>(Jpr, Jpri);
|
||||
Jpr_inv(0, 0, dx, dy) = Jpri[0];
|
||||
Jpr_inv(1, 0, dx, dy) = Jpri[1];
|
||||
Jpr_inv(0, 1, dx, dy) = Jpri[2];
|
||||
Jpr_inv(1, 1, dx, dy) = Jpri[3];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// Compute/interpolate gradient and Hessian, one component at a time.
|
||||
for (int c = 0; c < 2; c++)
|
||||
{
|
||||
kernels::internal::s_regs2d_t<MD1> rgrad_nodes, ddalf_dx_n, ddalf_dy_n;
|
||||
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
grad_c[dy][dx] =
|
||||
Jpr_inv(0, c, dx, dy) * dalf_dx_n[dy][dx] +
|
||||
Jpr_inv(1, c, dx, dy) * dalf_dy_n[dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// Compute ALF_grad with intermediate workspaces
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
r0[dy][dx] = grad_c[dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::Eval2d<MQ1>(D1D, Q1D, smem.q, sB_q, r0, r1);
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
ALF_grad(c, qx, qy, e) = r1[qy][qx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// Compute ddalf_dx_n.
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
rgrad_nodes[dy][dx] = grad_c[dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::Contract2d<false, MD1>(D1D, D1D, smem.d,
|
||||
sG_nodes, sB_nodes,
|
||||
rgrad_nodes, ddalf_dx_n);
|
||||
// Compute ddalf_dy_n.
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
rgrad_nodes[dy][dx] = grad_c[dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::Contract2d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sG_nodes,
|
||||
rgrad_nodes, ddalf_dy_n);
|
||||
// Compute hess_c with ddalf_[dx, dy]_n.
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
const real_t ddalf_dx = ddalf_dx_n[dy][dx];
|
||||
const real_t ddalf_dy = ddalf_dy_n[dy][dx];
|
||||
const real_t ddx = Jpr_inv(0, 0, dy, dx) * ddalf_dx +
|
||||
Jpr_inv(1, 0, dy, dx) * ddalf_dy;
|
||||
const real_t ddy = Jpr_inv(0, 1, dy, dx) * ddalf_dx +
|
||||
Jpr_inv(1, 1, dy, dx) * ddalf_dy;
|
||||
hess_c[0][dy][dx] = ddx;
|
||||
hess_c[1][dy][dx] = ddy;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
r0[dy][dx] = hess_c[j][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::Eval2d<MQ1>(D1D, Q1D, smem.q, sB_q, r0, r1);
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
ALF_hess(c, j, qx, qy, e) = r1[qy][qx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleGradCoef2D, TMOP_AssembleGradPA_C0_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleGradCoef2D);
|
||||
|
||||
@@ -142,4 +314,44 @@ void TMOP_Integrator::AssembleGradPA_C0_2D(const Vector &x) const
|
||||
J, W, b, bld, XL, X, H0, exp_lim, d, q);
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleGradAdaptLim2D,
|
||||
TMOP_AssembleGradPA_AdaptLim_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleGradAdaptLim2D);
|
||||
|
||||
void TMOP_Integrator::AssembleGradPA_AdaptLim_2D(const Vector &x) const
|
||||
{
|
||||
if (PA.AL_grads_assembled) { return; }
|
||||
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
|
||||
const auto *B_nodes = PA.maps_nodes->B.Read(),
|
||||
*G_nodes = PA.maps_nodes->G.Read();
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto X = Reshape(x.Read(), d, d, 2, NE);
|
||||
const int ndof_el = d * d;
|
||||
const int nqp_el = q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 2 * nqp_el * NE;
|
||||
const int ALFH_stride = 2 * 2 * nqp_el * NE;
|
||||
|
||||
const real_t *ALF_all = PA.ALF.Read();
|
||||
real_t *ALFG_all = PA.ALFG.Write();
|
||||
real_t *ALFH_all = PA.ALFH.Write();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const auto ALF = Reshape(ALF_all + c * ALF_stride, d, d, NE);
|
||||
auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 2, q, q, NE);
|
||||
auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 2, 2, q, q, NE);
|
||||
|
||||
TMOPAssembleGradAdaptLim2D::Run(d, q, NE, B_nodes, G_nodes, B, X, ALF,
|
||||
ALF_grad, ALF_hess, d, q);
|
||||
}
|
||||
PA.AL_grads_assembled = true;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -164,4 +164,269 @@ void TMOP_Integrator::AssembleGradPA_C0_3D(const Vector &x) const
|
||||
J, W, b, bld, XL, X, H0, exp_lim, d, q);
|
||||
}
|
||||
|
||||
// Assemble gradient and Hessian of ALF field at quadr points for AdaptLim (3D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AssembleGradPA_AdaptLim_3D(const int NE,
|
||||
const real_t *B_nodes,
|
||||
const real_t *G_nodes,
|
||||
const real_t *B,
|
||||
const DeviceTensor<5, const real_t> &X,
|
||||
const DeviceTensor<4, const real_t> &ALF,
|
||||
DeviceTensor<5> &ALF_grad,
|
||||
DeviceTensor<6> &ALF_hess,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
mfem::forall_2D<T_Q1D*T_Q1D>(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
// MD1 x MD1 or MQ1 x MQ1 shared memory block.
|
||||
MFEM_SHARED union { real_t d[MD1][MD1]; real_t q[MQ1][MQ1]; } smem;
|
||||
MFEM_SHARED real_t sB_nodes[MD1][MD1], sG_nodes[MD1][MD1];
|
||||
MFEM_SHARED real_t sB_q[MD1][MQ1];
|
||||
|
||||
kernels::internal::s_regs3d_t<MD1> grad_c;
|
||||
kernels::internal::v_regs3d_t<3, MD1> hess_c;
|
||||
|
||||
// Maps nodes - nodes.
|
||||
kernels::internal::LoadMatrix(D1D, D1D, B_nodes, sB_nodes);
|
||||
kernels::internal::LoadMatrix(D1D, D1D, G_nodes, sG_nodes);
|
||||
// Map nodes - quads.
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, B, sB_q);
|
||||
|
||||
// Compute the physical Jacobian at DOF nodes.
|
||||
kernels::internal::vd_regs3d_t<3, 3, MD1> r_X, r_J;
|
||||
kernels::internal::LoadDofs3d(e, D1D, X, r_X);
|
||||
kernels::internal::Grad3d(D1D, D1D, smem.d, sB_nodes, sG_nodes, r_X, r_J);
|
||||
|
||||
// Compute the reference derivatives of ALF at DOF nodes.
|
||||
kernels::internal::s_regs3d_t<MD1> alf_n;
|
||||
kernels::internal::s_regs3d_t<MD1> dalf_dxi_n, dalf_deta_n, dalf_dzeta_n;
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALF, alf_n);
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sG_nodes, sB_nodes, sB_nodes,
|
||||
alf_n, dalf_dxi_n);
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALF, alf_n);
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sG_nodes, sB_nodes,
|
||||
alf_n, dalf_deta_n);
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALF, alf_n);
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sB_nodes, sG_nodes,
|
||||
alf_n, dalf_dzeta_n);
|
||||
|
||||
// Interpolation workspaces.
|
||||
kernels::internal::s_regs3d_t<MQ1> r0, r1;
|
||||
|
||||
// Compute/interpolate gradient and Hessian one vector component at a time.
|
||||
for (int c = 0; c < 3; c++)
|
||||
{
|
||||
kernels::internal::s_regs3d_t<MD1> rgrad_nodes;
|
||||
kernels::internal::s_regs3d_t<MD1> dd_dxi_n, dd_deta_n, dd_dzeta_n;
|
||||
|
||||
// Precompute the inverse of the physical Jacobian.
|
||||
kernels::internal::vd_regs3d_t<3, 3, MD1> Jpr_inv;
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
const real_t Jpr[9] =
|
||||
{
|
||||
r_J[0][0][dz][dy][dx], r_J[1][0][dz][dy][dx], r_J[2][0][dz][dy][dx],
|
||||
r_J[0][1][dz][dy][dx], r_J[1][1][dz][dy][dx], r_J[2][1][dz][dy][dx],
|
||||
r_J[0][2][dz][dy][dx], r_J[1][2][dz][dy][dx], r_J[2][2][dz][dy][dx]
|
||||
};
|
||||
real_t Jpri[9];
|
||||
kernels::CalcInverse<3>(Jpr, Jpri);
|
||||
Jpr_inv(0, 0, dx, dy, dz) = Jpri[0];
|
||||
Jpr_inv(1, 0, dx, dy, dz) = Jpri[1];
|
||||
Jpr_inv(2, 0, dx, dy, dz) = Jpri[2];
|
||||
Jpr_inv(0, 1, dx, dy, dz) = Jpri[3];
|
||||
Jpr_inv(1, 1, dx, dy, dz) = Jpri[4];
|
||||
Jpr_inv(2, 1, dx, dy, dz) = Jpri[5];
|
||||
Jpr_inv(0, 2, dx, dy, dz) = Jpri[6];
|
||||
Jpr_inv(1, 2, dx, dy, dz) = Jpri[7];
|
||||
Jpr_inv(2, 2, dx, dy, dz) = Jpri[8];
|
||||
|
||||
grad_c[dz][dy][dx] =
|
||||
Jpr_inv(0, c, dx, dy, dz) * dalf_dxi_n[dz][dy][dx] +
|
||||
Jpr_inv(1, c, dx, dy, dz) * dalf_deta_n[dz][dy][dx] +
|
||||
Jpr_inv(2, c, dx, dy, dz) * dalf_dzeta_n[dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
// Compute ALF_grad with intermediate workspaces.
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
r0[dz][dy][dx] = grad_c[dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
kernels::internal::Eval3d<MQ1>(D1D, Q1D, smem.q, sB_q, r0, r1);
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
ALF_grad(c, qx, qy, qz, e) = r1[qz][qy][qx];
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
// Compute dd_dxi_n.
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
rgrad_nodes[dz][dy][dx] = grad_c[dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sG_nodes, sB_nodes, sB_nodes,
|
||||
rgrad_nodes, dd_dxi_n);
|
||||
// Compute dd_deta_n.
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
rgrad_nodes[dz][dy][dx] = grad_c[dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sG_nodes, sB_nodes,
|
||||
rgrad_nodes, dd_deta_n);
|
||||
// Compute dd_dzeta_n.
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
rgrad_nodes[dz][dy][dx] = grad_c[dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
kernels::internal::Contract3d<false, MD1>(D1D, D1D, smem.d,
|
||||
sB_nodes, sB_nodes, sG_nodes,
|
||||
rgrad_nodes, dd_dzeta_n);
|
||||
|
||||
// Compute hess_c with dd_[dxi, deta, dzeta]_n.
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
const real_t dd_dxi = dd_dxi_n[dz][dy][dx];
|
||||
const real_t dd_deta = dd_deta_n[dz][dy][dx];
|
||||
const real_t dd_dzeta = dd_dzeta_n[dz][dy][dx];
|
||||
const real_t ddx = Jpr_inv(0, 0, dx, dy, dz) * dd_dxi +
|
||||
Jpr_inv(1, 0, dx, dy, dz) * dd_deta +
|
||||
Jpr_inv(2, 0, dx, dy, dz) * dd_dzeta;
|
||||
const real_t ddy = Jpr_inv(0, 1, dx, dy, dz) * dd_dxi +
|
||||
Jpr_inv(1, 1, dx, dy, dz) * dd_deta +
|
||||
Jpr_inv(2, 1, dx, dy, dz) * dd_dzeta;
|
||||
const real_t ddz = Jpr_inv(0, 2, dx, dy, dz) * dd_dxi +
|
||||
Jpr_inv(1, 2, dx, dy, dz) * dd_deta +
|
||||
Jpr_inv(2, 2, dx, dy, dz) * dd_dzeta;
|
||||
hess_c[0][dz][dy][dx] = ddx;
|
||||
hess_c[1][dz][dy][dx] = ddy;
|
||||
hess_c[2][dz][dy][dx] = ddz;
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
for (int dz = 0; dz < D1D; dz++)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D)
|
||||
{
|
||||
r0[dz][dy][dx] = hess_c[j][dz][dy][dx];
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
kernels::internal::Eval3d<MQ1>(D1D, Q1D, smem.q, sB_q, r0, r1);
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
ALF_hess(c, j, qx, qy, qz, e) = r1[qz][qy][qx];
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleGradAdaptLim3D,
|
||||
TMOP_AssembleGradPA_AdaptLim_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleGradAdaptLim3D);
|
||||
|
||||
void TMOP_Integrator::AssembleGradPA_AdaptLim_3D(const Vector &x) const
|
||||
{
|
||||
if (PA.AL_grads_assembled) { return; }
|
||||
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
|
||||
const auto *B_nodes = PA.maps_nodes->B.Read(),
|
||||
*G_nodes = PA.maps_nodes->G.Read();
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto X = Reshape(x.Read(), d, d, d, 3, NE);
|
||||
const int ndof_el = d * d * d;
|
||||
const int nqp_el = q * q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 3 * nqp_el * NE;
|
||||
const int ALFH_stride = 3 * 3 * nqp_el * NE;
|
||||
|
||||
const real_t *ALF_all = PA.ALF.Read();
|
||||
real_t *ALFG_all = PA.ALFG.Write();
|
||||
real_t *ALFH_all = PA.ALFH.Write();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const auto ALF = Reshape(ALF_all + c * ALF_stride, d, d, d, NE);
|
||||
auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 3, q, q, q, NE);
|
||||
auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 3, 3, q, q, q, NE);
|
||||
|
||||
TMOPAssembleGradAdaptLim3D::Run(d, q, NE, B_nodes, G_nodes, B, X, ALF,
|
||||
ALF_grad, ALF_hess, d, q);
|
||||
}
|
||||
PA.AL_grads_assembled = true;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -67,6 +67,96 @@ void TMOP_AddMultGradPA_C0_2D(const int NE,
|
||||
});
|
||||
}
|
||||
|
||||
// Gradient action for AdaptLim limiting (2D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AddMultGradPA_AdaptLim_2D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<3, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<5, const real_t> &J,
|
||||
const ConstDeviceMatrix &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<4, const real_t> &R,
|
||||
const DeviceTensor<4, const real_t> &ALF_grad,
|
||||
const DeviceTensor<5, const real_t> &ALF_hess,
|
||||
const ConstDeviceCube &ALFmF0,
|
||||
DeviceTensor<4> &Y,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// ALF and ALF0 values at quad points.
|
||||
kernels::internal::s_regs2d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval2d(D1D, Q1D, smem, sB, alf_dof, alf_quad);
|
||||
|
||||
// Input vector R at quad points.
|
||||
kernels::internal::v_regs2d_t<2,MQ1> r_R_dof, r_R_quad;
|
||||
kernels::internal::LoadDofs2d(e, D1D, R, r_R_dof);
|
||||
kernels::internal::Eval2d(D1D, Q1D, smem, sB, r_R_dof, r_R_quad);
|
||||
|
||||
kernels::internal::v_regs2d_t<2,MQ1> r00, r01;
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, e);
|
||||
const real_t detJtr = kernels::Det<2>(Jtr);
|
||||
const real_t weight = W(qx, qy) * detJtr;
|
||||
const real_t diff = alf_quad(qy, qx);
|
||||
|
||||
// Load precomputed gradient at this quad point.
|
||||
real_t grad_alf[2] =
|
||||
{
|
||||
ALF_grad(0, qx, qy, e),
|
||||
ALF_grad(1, qx, qy, e)
|
||||
};
|
||||
|
||||
// Load precomputed Hessian at this quad point.
|
||||
real_t hess_alf[2][2];
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
hess_alf[i][j] = ALF_hess(i, j, qx, qy, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Get input vector at this quad point.
|
||||
const real_t R_q[2] = { r_R_quad(0, qy, qx), r_R_quad(1, qy, qx) };
|
||||
|
||||
// Hessian action:
|
||||
// H = factor * (grad x grad + (gf - gf0) * hess)
|
||||
const real_t coeff = const_coeff ? ALC(0, 0, 0) : ALC(qx, qy, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq;
|
||||
const real_t grad_dot_R = grad_alf[0] * R_q[0] + grad_alf[1] * R_q[1];
|
||||
real_t hess_R[2];
|
||||
hess_R[0] = hess_alf[0][0] * R_q[0] + hess_alf[0][1] * R_q[1];
|
||||
hess_R[1] = hess_alf[1][0] * R_q[0] + hess_alf[1][1] * R_q[1];
|
||||
|
||||
r00(0, qy, qx) = factor * (grad_alf[0] * grad_dot_R + diff * hess_R[0]);
|
||||
r00(1, qy, qx) = factor * (grad_alf[1] * grad_dot_R + diff * hess_R[1]);
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::EvalTranspose2d(D1D, Q1D, smem, sB, r00, r01);
|
||||
kernels::internal::WriteDofs2d(e, D1D, r01, Y);
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultGradCoefKernels, TMOP_AddMultGradPA_C0_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultGradCoefKernels);
|
||||
|
||||
@@ -85,4 +175,53 @@ void TMOP_Integrator::AddMultGradPA_C0_2D(const Vector &R, Vector &C) const
|
||||
TMOPMultGradCoefKernels::Run(d, q, NE, b, H0, X, Y, d, q);
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultGradAdaptLim, TMOP_AddMultGradPA_AdaptLim_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultGradAdaptLim);
|
||||
|
||||
void TMOP_Integrator::AddMultGradPA_AdaptLim_2D(const Vector &R,
|
||||
Vector &C) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 2, 2, q, q, NE);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q);
|
||||
const auto RR = Reshape(R.Read(), d, d, 2, NE);
|
||||
auto Y = Reshape(C.ReadWrite(), d, d, 2, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d;
|
||||
const int nqp_el = q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 2 * nqp_el * NE;
|
||||
const int ALFH_stride = 2 * 2 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
const real_t *ALFH_all = PA.ALFH.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 2, q, q, NE);
|
||||
const auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 2, 2, q, q, NE);
|
||||
|
||||
TMOPMultGradAdaptLim::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J, W, B,
|
||||
RR, ALF_grad, ALF_hess, ALFmF0, Y, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -98,4 +98,159 @@ void TMOP_Integrator::AddMultGradPA_C0_3D(const Vector &R, Vector &C) const
|
||||
TMOPMultGradCoefKernels3D::Run(d, q, NE, b, H0, X, Y, d, q);
|
||||
}
|
||||
|
||||
// Gradient action for AdaptLim limiting (3D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AddMultGradPA_AdaptLim_3D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<4, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<6, const real_t> &J,
|
||||
const ConstDeviceCube &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<5, const real_t> &R,
|
||||
const DeviceTensor<5, const real_t> &ALF_grad,
|
||||
const DeviceTensor<6, const real_t> &ALF_hess,
|
||||
const DeviceTensor<4, const real_t> &ALFmF0,
|
||||
DeviceTensor<5> &Y,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// ALF and ALF0 values at quad points.
|
||||
kernels::internal::s_regs3d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval3d(D1D, Q1D, smem, sB, alf_dof, alf_quad);
|
||||
|
||||
// Input vector R at quad points.
|
||||
kernels::internal::v_regs3d_t<3, MQ1> r_R_dof, r_R_quad;
|
||||
kernels::internal::LoadDofs3d(e, D1D, R, r_R_dof);
|
||||
kernels::internal::Eval3d(D1D, Q1D, smem, sB, r_R_dof, r_R_quad);
|
||||
|
||||
kernels::internal::v_regs3d_t<3, MQ1> r00, r01;
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, qz, e);
|
||||
const real_t detJtr = kernels::Det<3>(Jtr);
|
||||
const real_t weight = W(qx, qy, qz) * detJtr;
|
||||
const real_t diff = alf_quad(qz, qy, qx);
|
||||
|
||||
// Load precomputed gradient at this quad point.
|
||||
const real_t grad_alf[3] =
|
||||
{
|
||||
ALF_grad(0, qx, qy, qz, e),
|
||||
ALF_grad(1, qx, qy, qz, e),
|
||||
ALF_grad(2, qx, qy, qz, e)
|
||||
};
|
||||
|
||||
// Get input vector at this quad point.
|
||||
const real_t R_q[3] =
|
||||
{
|
||||
r_R_quad(0, qz, qy, qx),
|
||||
r_R_quad(1, qz, qy, qx),
|
||||
r_R_quad(2, qz, qy, qx)
|
||||
};
|
||||
|
||||
// Hessian action:
|
||||
// H = factor * (grad x grad + (gf - gf0) * hess)
|
||||
const real_t coeff =
|
||||
const_coeff ? ALC(0, 0, 0, 0) : ALC(qx, qy, qz, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq;
|
||||
const real_t grad_dot_R = grad_alf[0] * R_q[0] +
|
||||
grad_alf[1] * R_q[1] +
|
||||
grad_alf[2] * R_q[2];
|
||||
real_t hess_R[3];
|
||||
hess_R[0] =
|
||||
ALF_hess(0, 0, qx, qy, qz, e) * R_q[0] +
|
||||
ALF_hess(0, 1, qx, qy, qz, e) * R_q[1] +
|
||||
ALF_hess(0, 2, qx, qy, qz, e) * R_q[2];
|
||||
hess_R[1] =
|
||||
ALF_hess(1, 0, qx, qy, qz, e) * R_q[0] +
|
||||
ALF_hess(1, 1, qx, qy, qz, e) * R_q[1] +
|
||||
ALF_hess(1, 2, qx, qy, qz, e) * R_q[2];
|
||||
hess_R[2] =
|
||||
ALF_hess(2, 0, qx, qy, qz, e) * R_q[0] +
|
||||
ALF_hess(2, 1, qx, qy, qz, e) * R_q[1] +
|
||||
ALF_hess(2, 2, qx, qy, qz, e) * R_q[2];
|
||||
|
||||
r00(0, qz, qy, qx) = factor * (grad_alf[0] * grad_dot_R +
|
||||
diff * hess_R[0]);
|
||||
r00(1, qz, qy, qx) = factor * (grad_alf[1] * grad_dot_R +
|
||||
diff * hess_R[1]);
|
||||
r00(2, qz, qy, qx) = factor * (grad_alf[2] * grad_dot_R +
|
||||
diff * hess_R[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
kernels::internal::EvalTranspose3d(D1D, Q1D, smem, sB, r00, r01);
|
||||
kernels::internal::WriteDofs3d(e, D1D, r01, Y);
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultGradAdaptLim3D, TMOP_AddMultGradPA_AdaptLim_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultGradAdaptLim3D);
|
||||
|
||||
void TMOP_Integrator::AddMultGradPA_AdaptLim_3D(const Vector &R,
|
||||
Vector &C) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 3, 3, q, q, q, NE);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q, q);
|
||||
const auto RR = Reshape(R.Read(), d, d, d, 3, NE);
|
||||
auto Y = Reshape(C.ReadWrite(), d, d, d, 3, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d * d;
|
||||
const int nqp_el = q * q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 3 * nqp_el * NE;
|
||||
const int ALFH_stride = 3 * 3 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
const real_t *ALFH_all = PA.ALFH.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 3, q, q, q, NE);
|
||||
const auto ALF_hess = Reshape(ALFH_all + c * ALFH_stride, 3, 3, q, q, q, NE);
|
||||
|
||||
TMOPMultGradAdaptLim3D::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J,
|
||||
W, B, RR, ALF_grad, ALF_hess, ALFmF0, Y, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -108,6 +108,64 @@ void TMOP_AddMultPA_C0_2D(const real_t lim_normal,
|
||||
});
|
||||
}
|
||||
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AddMultPA_AdaptLim_2D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<3, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<5, const real_t> &J,
|
||||
const ConstDeviceMatrix &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<4, const real_t> &ALF_grad,
|
||||
const ConstDeviceCube &ALFmF0,
|
||||
DeviceTensor<4> &Y,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// Evaluate ALF and ALF0 at the quad points.
|
||||
kernels::internal::s_regs2d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval2d(D1D, Q1D, smem, sB,
|
||||
alf_dof, alf_quad);
|
||||
|
||||
kernels::internal::v_regs2d_t<2,MQ1> r00, r01;
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, e);
|
||||
const real_t detJtr = kernels::Det<2>(Jtr);
|
||||
const real_t weight = W(qx, qy) * detJtr;
|
||||
|
||||
const real_t coeff = const_coeff ? ALC(0, 0, 0) : ALC(qx, qy, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq *
|
||||
alf_quad(qy, qx);
|
||||
|
||||
r00(0, qy, qx) = factor * ALF_grad(0, qx, qy, e);
|
||||
r00(1, qy, qx) = factor * ALF_grad(1, qx, qy, e);
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
kernels::internal::EvalTranspose2d(D1D, Q1D, smem, sB, r00, r01);
|
||||
kernels::internal::WriteDofs2d(e, D1D, r01, Y);
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultCoefKernels, TMOP_AddMultPA_C0_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultCoefKernels);
|
||||
|
||||
@@ -140,4 +198,48 @@ void TMOP_Integrator::AddMultPA_C0_2D(const Vector &x, Vector &y) const
|
||||
Y, exp_lim, d, q);
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultAdaptLim, TMOP_AddMultPA_AdaptLim_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultAdaptLim);
|
||||
|
||||
void TMOP_Integrator::AddMultPA_AdaptLim_2D([[maybe_unused]] const Vector &x,
|
||||
Vector &y) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 2, 2, q, q, NE);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q);
|
||||
auto Y = Reshape(y.ReadWrite(), d, d, 2, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d;
|
||||
const int nqp_el = q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 2 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 2, q, q, NE);
|
||||
TMOPMultAdaptLim::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J, W,
|
||||
B, ALF_grad, ALFmF0, Y, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -76,7 +76,7 @@ void TMOP_AddMultPA_C0_3D(const real_t lim_normal,
|
||||
r11(1, qz, qy, qx),
|
||||
r11(2, qz, qy, qx)
|
||||
};
|
||||
const real_t coeff0 = const_c0 ? C0(0, 0, 0, 0) : C0(qx, qy, qz, e);
|
||||
const real_t coeff0 = const_c0 ? C0(0,0,0,0) : C0(qx, qy, qz, e);
|
||||
|
||||
real_t d1[3];
|
||||
// Eval_d1 (Quadratic Limiter)
|
||||
@@ -148,4 +148,111 @@ void TMOP_Integrator::AddMultPA_C0_3D(const Vector &x, Vector &y) const
|
||||
X, Y, exp_lim, d, q);
|
||||
}
|
||||
|
||||
// Residual term for AdaptLim limiting (3D)
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_AddMultPA_AdaptLim_3D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<4, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<6, const real_t> &J,
|
||||
const ConstDeviceCube &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<5, const real_t> &ALF_grad,
|
||||
const DeviceTensor<4, const real_t> &ALFmF0,
|
||||
DeviceTensor<5> &Y,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
const real_t normal_inv_delta_sq =
|
||||
2.0 * lim_normal / (adapt_lim_delta_max * adapt_lim_delta_max);
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// Evaluate ALF and ALF0 at the quad points.
|
||||
kernels::internal::s_regs3d_t<MQ1> alf_dof, alf_quad;
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALFmF0, alf_dof);
|
||||
kernels::internal::Eval3d(D1D, Q1D, smem, sB, alf_dof, alf_quad);
|
||||
|
||||
kernels::internal::v_regs3d_t<3, MQ1> r00, r01;
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, qz, e);
|
||||
const real_t detJtr = kernels::Det<3>(Jtr);
|
||||
const real_t weight = W(qx, qy, qz) * detJtr;
|
||||
|
||||
const real_t coeff =
|
||||
const_coeff ? ALC(0, 0, 0, 0) : ALC(qx, qy, qz, e);
|
||||
const real_t factor = weight * coeff * normal_inv_delta_sq *
|
||||
alf_quad(qz, qy, qx);
|
||||
|
||||
r00(0, qz, qy, qx) = factor * ALF_grad(0, qx, qy, qz, e);
|
||||
r00(1, qz, qy, qx) = factor * ALF_grad(1, qx, qy, qz, e);
|
||||
r00(2, qz, qy, qx) = factor * ALF_grad(2, qx, qy, qz, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
MFEM_SYNC_THREAD;
|
||||
|
||||
kernels::internal::EvalTranspose3d(D1D, Q1D, smem, sB, r00, r01);
|
||||
kernels::internal::WriteDofs3d(e, D1D, r01, Y);
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPMultAdaptLim3D, TMOP_AddMultPA_AdaptLim_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPMultAdaptLim3D);
|
||||
|
||||
void TMOP_Integrator::AddMultPA_AdaptLim_3D([[maybe_unused]] const Vector &x,
|
||||
Vector &y) const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 3, 3, q, q, q, NE);
|
||||
const auto *B = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q, q);
|
||||
auto Y = Reshape(y.ReadWrite(), d, d, d, 3, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
const real_t *ALD = PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d * d;
|
||||
const int nqp_el = q * q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
const int ALFG_stride = 3 * nqp_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
const real_t *ALFG_all = PA.ALFG.Read();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = ALD[c];
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, d, NE);
|
||||
const auto ALF_grad = Reshape(ALFG_all + c * ALFG_stride, 3, q, q, q, NE);
|
||||
TMOPMultAdaptLim3D::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J, W,
|
||||
B, ALF_grad, ALFmF0, Y, d, q);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
+179
-3
@@ -46,12 +46,14 @@ void TMOP_Integrator::AssembleGradPA(const Vector &de,
|
||||
{
|
||||
AssembleGradPA_2D(xe);
|
||||
if (lim_coeff) { AssembleGradPA_C0_2D(xe); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleGradPA_AdaptLim_2D(xe); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AssembleGradPA_3D(xe);
|
||||
if (lim_coeff) { AssembleGradPA_C0_3D(xe); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleGradPA_AdaptLim_3D(xe); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,12 +199,17 @@ void TMOP_Integrator::UpdateCoefficientsPA(const Vector &d_loc)
|
||||
add(*x_0, d_loc, x_loc);
|
||||
}
|
||||
|
||||
// Both are constant or not specified.
|
||||
if (PA.MC.Size() == 1 && PA.C0.Size() == 1) { return; }
|
||||
|
||||
// All are constant or not specified.
|
||||
const int nal = PA.nal;
|
||||
const bool alc_is_qvec =
|
||||
(nal > 0) ? (PA.ALC.Size() == nal * PA.nq * PA.ne) : false;
|
||||
if (PA.MC.Size() == 1 && PA.C0.Size() <= 1 && !alc_is_qvec) { return; }
|
||||
|
||||
// Coefficients are always evaluated on the CPU for now.
|
||||
PA.MC.HostWrite();
|
||||
PA.C0.HostWrite();
|
||||
if (alc_is_qvec) { PA.ALC.HostWrite(); }
|
||||
|
||||
const IntegrationRule &ir = *PA.ir;
|
||||
auto T = new IsoparametricTransformation;
|
||||
@@ -226,6 +233,20 @@ void TMOP_Integrator::UpdateCoefficientsPA(const Vector &d_loc)
|
||||
PA.C0(q + e * PA.nq) = lim_coeff->Eval(*T, ir.IntPoint(q));
|
||||
}
|
||||
}
|
||||
|
||||
if (alc_is_qvec)
|
||||
{
|
||||
MFEM_VERIFY(nal == adapt_lim_coeff.Size(), "internal error");
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
real_t *ALC_c = PA.ALC.HostWrite() + c * PA.nq * PA.ne;
|
||||
for (int q = 0; q < PA.nq; ++q)
|
||||
{
|
||||
ALC_c[q + e * PA.nq] =
|
||||
adapt_lim_coeff[c]->Eval(*T, ir.IntPoint(q));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete T;
|
||||
@@ -321,7 +342,140 @@ void TMOP_Integrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
PA.Jtr_debug_grad = false;
|
||||
|
||||
// Limiting: lim_coeff -> PA.C0, lim_nodes0 -> PA.XL, lim_dist -> PA.LD, PA.H0
|
||||
if (lim_coeff) { AssemblePA_Limiting(); }
|
||||
if (lim_coeff) { AssemblePA_Limiting(); }
|
||||
// Adaptive limiting: adapt_lim_coeff -> PA.ALC, adapt_lim_gf -> PA.ALF,
|
||||
// adapt_lim_gf0 -> PA.ALF0, adapt_lim_delta_max -> PA.ALD
|
||||
if (adapt_lim_gf.Size() > 0) { AssemblePA_AdaptLim(); }
|
||||
}
|
||||
|
||||
void TMOP_Integrator::AssemblePA_AdaptLim()
|
||||
{
|
||||
const int nal = adapt_lim_coeff.Size();
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
|
||||
MFEM_VERIFY(adapt_lim_gf.Size() == nal && adapt_lim_gf0.Size() == nal,
|
||||
"internal error");
|
||||
const FiniteElementSpace *alfes = adapt_lim_gf[0]->FESpace();
|
||||
MFEM_VERIFY(alfes && alfes->GetVDim() == 1, "internal error");
|
||||
|
||||
MFEM_VERIFY(strcmp(alfes->FEColl()->Name(), PA.fes->FEColl()->Name()) == 0 &&
|
||||
alfes->FEColl()->GetOrder() == PA.fes->FEColl()->GetOrder(),
|
||||
"The PA code assumes the same FE spaces for mesh and limiting.");
|
||||
|
||||
PA.AL_grads_assembled = false;
|
||||
PA.nal = nal;
|
||||
|
||||
// adapt_lim_coeff -> PA.ALC
|
||||
// Keep the ConstantCoefficient fast-path: when all coefficients are
|
||||
// constant, store one scalar per adaptive-limiting term.
|
||||
bool all_const = true;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
if (!dynamic_cast<ConstantCoefficient *>(adapt_lim_coeff[c]))
|
||||
{
|
||||
all_const = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
PA.ALC.UseDevice(true);
|
||||
if (all_const)
|
||||
{
|
||||
PA.ALC.SetSize(nal, Device::GetMemoryType());
|
||||
real_t *ALC_all = PA.ALC.HostWrite();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
auto *cc = dynamic_cast<ConstantCoefficient *>(adapt_lim_coeff[c]);
|
||||
MFEM_VERIFY(cc, "internal error");
|
||||
ALC_all[c] = cc->constant;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If one Coefficient is not constant, we allocate the full size for
|
||||
// all Coefficients. Could be optimized in the future.
|
||||
PA.ALC.SetSize(nal * PA.nq * PA.ne, Device::GetMemoryType());
|
||||
real_t *ALC_all = PA.ALC.HostWrite();
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
real_t *ALC_c = ALC_all + c * PA.nq * PA.ne;
|
||||
for (int e = 0; e < PA.ne; ++e)
|
||||
{
|
||||
ElementTransformation &T = *PA.fes->GetElementTransformation(e);
|
||||
for (int q = 0; q < PA.ir->GetNPoints(); ++q)
|
||||
{
|
||||
ALC_c[q + e * PA.nq] =
|
||||
adapt_lim_coeff[c]->Eval(T, PA.ir->IntPoint(q));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ElementDofOrdering ordering = ElementDofOrdering::LEXICOGRAPHIC;
|
||||
|
||||
const FiniteElement *fe_n = PA.fes->GetTypicalFE();
|
||||
// GetNodes() for tensor H1 elements with H1_DOF_MAP is stored in NATIVE
|
||||
// order (via dof_map), while DofToQuad::TENSOR assumes LEXICOGRAPHIC
|
||||
// ordering of the integration points.
|
||||
const IntegrationRule &nodes = fe_n->GetNodes();
|
||||
const auto *nfe = dynamic_cast<const NodalFiniteElement *>(fe_n);
|
||||
const Array<int> *lex = (nfe && nfe->GetLexicographicOrdering().Size() > 0)
|
||||
? &nfe->GetLexicographicOrdering() : nullptr;
|
||||
if (!lex)
|
||||
{
|
||||
PA.maps_nodes = &fe_n->GetDofToQuad(nodes, DofToQuad::TENSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationRule lex_nodes(nodes.GetNPoints());
|
||||
MFEM_VERIFY(lex->Size() == nodes.GetNPoints(), "");
|
||||
for (int i = 0; i < nodes.GetNPoints(); i++)
|
||||
{
|
||||
lex_nodes.IntPoint(i) = nodes.IntPoint((*lex)[i]);
|
||||
}
|
||||
PA.maps_nodes = &fe_n->GetDofToQuad(lex_nodes, DofToQuad::TENSOR);
|
||||
}
|
||||
|
||||
// Restrict each adaptive limiting field into separate contiguous E-vectors
|
||||
// (one block per adaptive limiting term).
|
||||
const Operator *alf_R = alfes->GetElementRestriction(ordering);
|
||||
const int ndofs = alfes->GetVSize();
|
||||
|
||||
const int Esize = alf_R->Height();
|
||||
PA.ALF.SetSize(nal * Esize, Device::GetMemoryType());
|
||||
PA.ALF.UseDevice(true);
|
||||
PA.ALFmF0.SetSize(nal * Esize, Device::GetMemoryType());
|
||||
PA.ALFmF0.UseDevice(true);
|
||||
|
||||
Vector ALFc, ALF0c;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
ALFc.MakeRef(PA.ALF, c * Esize, Esize);
|
||||
ALF0c.MakeRef(PA.ALFmF0, c * Esize, Esize);
|
||||
|
||||
MFEM_VERIFY(adapt_lim_gf[c]->Size() == ndofs, "internal error");
|
||||
MFEM_VERIFY(adapt_lim_gf0[c]->Size() == ndofs, "internal error");
|
||||
alf_R->Mult(*adapt_lim_gf[c], ALFc);
|
||||
alf_R->Mult(*adapt_lim_gf0[c], ALF0c);
|
||||
}
|
||||
|
||||
// Build differences in-place: ALFmF0 = ALF - ALF0.
|
||||
PA.ALFmF0 *= -1.0;
|
||||
PA.ALFmF0 += PA.ALF;
|
||||
|
||||
// Per-field delta_max values.
|
||||
MFEM_VERIFY(adapt_lim_delta_max.Size() == nal, "internal error");
|
||||
PA.ALD.SetSize(nal);
|
||||
PA.ALD.HostWrite();
|
||||
for (int c = 0; c < nal; c++) { PA.ALD(c) = adapt_lim_delta_max[c]; }
|
||||
|
||||
// Allocate storage for gradient and Hessian of ALF at quadrature points
|
||||
// These will be filled during AssembleGradPA
|
||||
const int dim = PA.dim;
|
||||
PA.ALFG.UseDevice(true);
|
||||
PA.ALFG.SetSize(nal * dim * PA.nq * PA.ne, Device::GetMemoryType());
|
||||
PA.ALFH.UseDevice(true);
|
||||
PA.ALFH.SetSize(nal * dim * dim * PA.nq * PA.ne, Device::GetMemoryType());
|
||||
|
||||
}
|
||||
|
||||
void TMOP_Integrator::AssembleGradDiagonalPA(Vector &de) const
|
||||
@@ -341,12 +495,14 @@ void TMOP_Integrator::AssembleGradDiagonalPA(Vector &de) const
|
||||
{
|
||||
AssembleDiagonalPA_2D(de);
|
||||
if (lim_coeff) { AssembleDiagonalPA_C0_2D(de); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleDiagonalPA_AdaptLim_2D(de); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AssembleDiagonalPA_3D(de);
|
||||
if (lim_coeff) { AssembleDiagonalPA_C0_3D(de); }
|
||||
if (adapt_lim_gf.Size() > 0) { AssembleDiagonalPA_AdaptLim_3D(de); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,12 +529,26 @@ void TMOP_Integrator::AddMultPA(const Vector &de, Vector &ye) const
|
||||
{
|
||||
AddMultPA_2D(xe, ye);
|
||||
if (lim_coeff) { AddMultPA_C0_2D(xe, ye); }
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{
|
||||
// AddMultPA_AdaptLim_2D uses the precomputed AdaptLim field gradient
|
||||
// at quadrature points (PA.ALFG). Ensure it is up-to-date for the
|
||||
// current mesh configuration.
|
||||
AssembleGradPA_AdaptLim_2D(xe);
|
||||
AddMultPA_AdaptLim_2D(xe, ye);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AddMultPA_3D(xe, ye);
|
||||
if (lim_coeff) { AddMultPA_C0_3D(xe, ye); }
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{
|
||||
AssembleGradPA_AdaptLim_3D(xe);
|
||||
AddMultPA_AdaptLim_3D(xe, ye);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,12 +569,14 @@ void TMOP_Integrator::AddMultGradPA(const Vector &re, Vector &ce) const
|
||||
{
|
||||
AddMultGradPA_2D(re, ce);
|
||||
if (lim_coeff) { AddMultGradPA_C0_2D(re, ce); }
|
||||
if (adapt_lim_gf.Size() > 0) { AddMultGradPA_AdaptLim_2D(re, ce); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AddMultGradPA_3D(re, ce);
|
||||
if (lim_coeff) { AddMultGradPA_C0_3D(re, ce); }
|
||||
if (adapt_lim_gf.Size() > 0) { AddMultGradPA_AdaptLim_3D(re, ce); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,12 +605,16 @@ real_t TMOP_Integrator::GetLocalStateEnergyPA(const Vector &de) const
|
||||
{
|
||||
GetLocalStateEnergyPA_2D(xe, energy);
|
||||
if (lim_coeff) { energy += GetLocalStateEnergyPA_C0_2D(xe); }
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{ energy += GetLocalStateEnergyPA_AdaptLim_2D(); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
GetLocalStateEnergyPA_3D(xe, energy);
|
||||
if (lim_coeff) { energy += GetLocalStateEnergyPA_C0_3D(xe); }
|
||||
if (adapt_lim_gf.Size() > 0)
|
||||
{ energy += GetLocalStateEnergyPA_AdaptLim_3D(); }
|
||||
}
|
||||
|
||||
return energy;
|
||||
|
||||
@@ -92,6 +92,55 @@ void TMOP_EnergyPA_C0_2D(const real_t lim_normal,
|
||||
});
|
||||
}
|
||||
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_EnergyPA_AdaptLim_2D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<3, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<5, const real_t> &J,
|
||||
const ConstDeviceMatrix &W,
|
||||
const real_t *b,
|
||||
const ConstDeviceCube &ALFmF0,
|
||||
DeviceTensor<3> &E,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
|
||||
// Load basis functions for ALF/ALF0.
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// Load ALF and ALF0 (scalar pattern).
|
||||
kernels::internal::s_regs2d_t<MQ1> rtmp, ralf;
|
||||
kernels::internal::LoadDofs2d(e, D1D, ALFmF0, rtmp);
|
||||
kernels::internal::Eval2d(D1D, Q1D, smem, sB, rtmp, ralf);
|
||||
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, e);
|
||||
const real_t detJtr = kernels::Det<2>(Jtr);
|
||||
const real_t weight = W(qx, qy) * detJtr;
|
||||
|
||||
const real_t diff = ralf(qy, qx) / adapt_lim_delta_max;
|
||||
|
||||
const real_t coeff = const_coeff ? ALC(0, 0, 0) : ALC(qx, qy, e);
|
||||
|
||||
// Energy: coeff * lim_normal * diff^2
|
||||
E(qx, qy, e) = weight * coeff * lim_normal * diff * diff;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPEnergyCoef2D, TMOP_EnergyPA_C0_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPEnergyCoef2D);
|
||||
|
||||
@@ -127,4 +176,49 @@ real_t TMOP_Integrator::GetLocalStateEnergyPA_C0_2D(const Vector &x) const
|
||||
return PA.E * PA.O;
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPEnergyAdaptLim2D, TMOP_EnergyPA_AdaptLim_2D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPEnergyAdaptLim2D);
|
||||
|
||||
real_t TMOP_Integrator::GetLocalStateEnergyPA_AdaptLim_2D() const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 2, 2, q, q, NE);
|
||||
const auto *b = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q);
|
||||
auto E = Reshape(PA.E.Write(), q, q, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
MFEM_VERIFY(PA.ALD.Size() == nal, "internal error");
|
||||
PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d;
|
||||
const int nqp_el = q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
real_t energy = 0.0;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = PA.ALD(c);
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, NE);
|
||||
TMOPEnergyAdaptLim2D::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J, W, b,
|
||||
ALFmF0, E, d, q);
|
||||
energy += PA.E * PA.O;
|
||||
}
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -107,6 +107,56 @@ void TMOP_EnergyPA_C0_3D(const real_t lim_normal,
|
||||
});
|
||||
}
|
||||
|
||||
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0>
|
||||
void TMOP_EnergyPA_AdaptLim_3D(const real_t lim_normal,
|
||||
const real_t adapt_lim_delta_max,
|
||||
const bool const_coeff,
|
||||
const DeviceTensor<4, const real_t> &ALC,
|
||||
const int NE,
|
||||
const DeviceTensor<6, const real_t> &J,
|
||||
const ConstDeviceCube &W,
|
||||
const real_t *b,
|
||||
const DeviceTensor<4, const real_t> &ALFmF0,
|
||||
DeviceTensor<4> &E,
|
||||
const int d1d,
|
||||
const int q1d)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
const int Q1D = T_Q1D ? T_Q1D : q1d;
|
||||
|
||||
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e)
|
||||
{
|
||||
MFEM_SHARED real_t smem[MQ1][MQ1];
|
||||
MFEM_SHARED real_t sB[MD1][MQ1];
|
||||
|
||||
// Load basis functions for ALF/ALF0.
|
||||
kernels::internal::LoadMatrix(D1D, Q1D, b, sB);
|
||||
|
||||
// Load ALF and ALF0 (scalar pattern).
|
||||
kernels::internal::s_regs3d_t<MQ1> rtmp, ralf;
|
||||
kernels::internal::LoadDofs3d(e, D1D, ALFmF0, rtmp);
|
||||
kernels::internal::Eval3d(D1D, Q1D, smem, sB, rtmp, ralf);
|
||||
|
||||
for (int qz = 0; qz < Q1D; ++qz)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qy, y, Q1D)
|
||||
{
|
||||
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D)
|
||||
{
|
||||
const real_t *Jtr = &J(0, 0, qx, qy, qz, e);
|
||||
const real_t detJtr = kernels::Det<3>(Jtr);
|
||||
const real_t weight = W(qx, qy, qz) * detJtr;
|
||||
|
||||
const real_t diff = ralf(qz, qy, qx) / adapt_lim_delta_max;
|
||||
|
||||
const real_t coeff = const_coeff ? ALC(0, 0, 0, 0) : ALC(qx, qy, qz, e);
|
||||
E(qx, qy, qz, e) = weight * coeff * lim_normal * diff * diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPEnergyPAC03D, TMOP_EnergyPA_C0_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPEnergyPAC03D);
|
||||
|
||||
@@ -142,4 +192,49 @@ real_t TMOP_Integrator::GetLocalStateEnergyPA_C0_3D(const Vector &x) const
|
||||
return PA.E * PA.O;
|
||||
}
|
||||
|
||||
MFEM_TMOP_MDQ_REGISTER(TMOPEnergyAdaptLim3D, TMOP_EnergyPA_AdaptLim_3D);
|
||||
MFEM_TMOP_MDQ_SPECIALIZE(TMOPEnergyAdaptLim3D);
|
||||
|
||||
real_t TMOP_Integrator::GetLocalStateEnergyPA_AdaptLim_3D() const
|
||||
{
|
||||
const real_t ln = lim_normal;
|
||||
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt;
|
||||
|
||||
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, "");
|
||||
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, "");
|
||||
|
||||
const auto J = Reshape(PA.Jtr.Read(), 3, 3, q, q, q, NE);
|
||||
const auto *b = PA.maps->B.Read();
|
||||
const auto W = Reshape(PA.ir->GetWeights().Read(), q, q, q);
|
||||
auto E = Reshape(PA.E.Write(), q, q, q, NE);
|
||||
|
||||
const int nal = PA.nal;
|
||||
MFEM_VERIFY(nal > 0, "internal error");
|
||||
MFEM_VERIFY(PA.ALD.Size() == nal, "internal error");
|
||||
PA.ALD.HostRead();
|
||||
|
||||
const int ndof_el = d * d * d;
|
||||
const int nqp_el = q * q * q;
|
||||
const int ALF_stride = ndof_el * NE;
|
||||
|
||||
const bool const_coeff = (PA.ALC.Size() == nal);
|
||||
const int ALC_stride = const_coeff ? 1 : (nqp_el * NE);
|
||||
const real_t *ALC_all = PA.ALC.Read();
|
||||
const real_t *ALFmF0_all = PA.ALFmF0.Read();
|
||||
real_t energy = 0.0;
|
||||
for (int c = 0; c < nal; c++)
|
||||
{
|
||||
const real_t delta_max = PA.ALD(c);
|
||||
const auto ALC = const_coeff
|
||||
? Reshape(ALC_all + c, 1, 1, 1, 1)
|
||||
: Reshape(ALC_all + c * ALC_stride, q, q, q, NE);
|
||||
const auto ALFmF0 = Reshape(ALFmF0_all + c * ALF_stride, d, d, d, NE);
|
||||
TMOPEnergyAdaptLim3D::Run(d, q, ln, delta_max, const_coeff, ALC, NE, J, W, b,
|
||||
ALFmF0, E, d, q);
|
||||
energy += PA.E * PA.O;
|
||||
}
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
@@ -759,6 +759,7 @@ void TMOPHRSolver::Update()
|
||||
gridfuncarr[i]->SetTrueVector();
|
||||
gridfuncarr[i]->SetFromTrueVector();
|
||||
}
|
||||
tmopns->UpdateDeterminantBoundGridFunction();
|
||||
|
||||
// Update Discrete Indicator for all the TMOP_Integrators in NonLinearForm
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
@@ -806,6 +807,7 @@ void TMOPHRSolver::ParUpdate()
|
||||
pgridfuncarr[i]->SetTrueVector();
|
||||
pgridfuncarr[i]->SetFromTrueVector();
|
||||
}
|
||||
tmopns->UpdateDeterminantBoundGridFunction();
|
||||
|
||||
// Update Discrete Indicator
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
|
||||
+105
-7
@@ -68,6 +68,9 @@ void AdvectorCG::ComputeAtNewPosition(const Vector &new_mesh_nodes,
|
||||
}
|
||||
}
|
||||
|
||||
// Without this, the next remap would start from the initial mesh, i.e.,
|
||||
// every consecutive remap would be more expensive, as it would have to
|
||||
// transport the solution through bigger displacements.
|
||||
field0 = new_field;
|
||||
nodes0 = new_mesh_nodes;
|
||||
}
|
||||
@@ -305,8 +308,14 @@ void ParAdvectorCGOper::Mult(const Vector &ind, Vector &di_dt) const
|
||||
M.BilinearForm::operator=(0.0);
|
||||
M.Assemble();
|
||||
|
||||
HypreParVector *RHS = rhs.ParallelAssemble();
|
||||
HypreParVector X(K.ParFESpace());
|
||||
Vector RHS;
|
||||
RHS.SetSize(M.ParFESpace()->GetTrueVSize(), ind);
|
||||
RHS.UseDevice(ind.UseDevice());
|
||||
rhs.ParallelAssemble(RHS);
|
||||
|
||||
Vector X;
|
||||
X.SetSize(M.ParFESpace()->GetTrueVSize(), ind);
|
||||
X.UseDevice(ind.UseDevice());
|
||||
X = 0.0;
|
||||
|
||||
OperatorHandle Mop;
|
||||
@@ -335,10 +344,8 @@ void ParAdvectorCGOper::Mult(const Vector &ind, Vector &di_dt) const
|
||||
lin_solver.SetRelTol(rtol); lin_solver.SetAbsTol(0.0);
|
||||
lin_solver.SetMaxIter(100);
|
||||
lin_solver.SetPrintLevel(0);
|
||||
lin_solver.Mult(*RHS, X);
|
||||
lin_solver.Mult(RHS, X);
|
||||
K.ParFESpace()->GetProlongationMatrix()->Mult(X, di_dt);
|
||||
|
||||
delete RHS;
|
||||
delete prec;
|
||||
}
|
||||
#endif
|
||||
@@ -493,7 +500,10 @@ real_t TMOPNewtonSolver::ComputeScalingFactor(const Vector &d_in,
|
||||
|
||||
// Check if the starting mesh (given by x) is inverted. Note that x hasn't
|
||||
// been modified by the Newton update yet.
|
||||
const real_t min_detT_in = ComputeMinDet(d_loc, *fes);
|
||||
const real_t min_detT_in =
|
||||
detJpr_pos_bound ? ComputeDetJptLowerBound(d_loc, *fes)
|
||||
/* */ : ComputeMinDet(d_loc, *fes);
|
||||
|
||||
const bool untangling = (min_detT_in <= 0.0) ? true : false;
|
||||
const real_t untangle_factor = 1.5;
|
||||
if (untangling)
|
||||
@@ -544,7 +554,10 @@ real_t TMOPNewtonSolver::ComputeScalingFactor(const Vector &d_in,
|
||||
#endif
|
||||
|
||||
// Check the changes in detJ.
|
||||
min_detT_out = ComputeMinDet(d_loc, *fes);
|
||||
min_detT_out =
|
||||
detJpr_pos_bound ? ComputeDetJptLowerBound(d_loc, *fes)
|
||||
/* */ : ComputeMinDet(d_loc, *fes);
|
||||
|
||||
if (untangling == false && min_detT_out <= min_detJ_limit)
|
||||
{
|
||||
// No untangling, and detJ got negative (or small) -- no good.
|
||||
@@ -969,6 +982,37 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &dx) const
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPNewtonSolver::EnsurePositiveDeterminantBound(
|
||||
Mesh &mesh, int ref_factor, int max_recursion_depth)
|
||||
{
|
||||
#ifdef MFEM_USE_MPI
|
||||
if (ParMesh *pmesh = dynamic_cast<ParMesh *>(&mesh))
|
||||
{
|
||||
det_gf = pmesh->GetJacobianDeterminantGF();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
det_gf = mesh.GetJacobianDeterminantGF();
|
||||
}
|
||||
|
||||
// setup the PLBound object for estimating the minima.
|
||||
// note: this must be updated if the mesh is p-refined.
|
||||
int max_order = det_gf->FESpace()->GetMaxElementOrder();
|
||||
det_plb = std::make_unique<PLBound>(det_gf->FESpace(),
|
||||
ref_factor*(max_order+1));
|
||||
plb_rec_depth = max_recursion_depth;
|
||||
detJpr_pos_bound = true;
|
||||
}
|
||||
|
||||
void TMOPNewtonSolver::UpdateDeterminantBoundGridFunction()
|
||||
{
|
||||
if (!det_gf) { return; }
|
||||
|
||||
det_gf->FESpace()->Update();
|
||||
det_gf->Update();
|
||||
}
|
||||
|
||||
real_t TMOPNewtonSolver::ComputeMinDet(const Vector &d_loc,
|
||||
const FiniteElementSpace &fes) const
|
||||
{
|
||||
@@ -1028,6 +1072,60 @@ real_t TMOPNewtonSolver::ComputeMinDet(const Vector &d_loc,
|
||||
return min_detJ;
|
||||
}
|
||||
|
||||
real_t TMOPNewtonSolver::ComputeDetJptLowerBound(const Vector &d_loc,
|
||||
const FiniteElementSpace &fes) const
|
||||
{
|
||||
MFEM_VERIFY(det_gf != nullptr && det_plb != nullptr,
|
||||
"Determinant bounding has not been setup.");
|
||||
FiniteElementSpace *det_fes = det_gf->FESpace();
|
||||
MFEM_VERIFY(!det_fes->IsVariableOrder() && UsesTensorBasis(*det_fes),
|
||||
"Determinant lower bounds require a fixed-order tensor-product "
|
||||
"determinant space.");
|
||||
Array<int> dofs, xdofs;
|
||||
DenseMatrix dshape, Jpr, pos;
|
||||
Vector d_loc_el, detvals;
|
||||
|
||||
for (int e = 0; e < fes.GetNE(); e++)
|
||||
{
|
||||
const FiniteElement *fe = fes.GetFE(e);
|
||||
const int dof = fe->GetDof(), dim = fe->GetDim();
|
||||
dshape.SetSize(dof, dim);
|
||||
Jpr.SetSize(dim);
|
||||
pos.SetSize(dof, dim);
|
||||
Vector posV(pos.Data(), dof * dim);
|
||||
|
||||
x_0.GetElementDofValues(e, posV);
|
||||
if (periodic)
|
||||
{
|
||||
auto n_el = dynamic_cast<const NodalFiniteElement *>(fe);
|
||||
n_el->ReorderLexToNative(dim, posV);
|
||||
}
|
||||
|
||||
fes.GetElementVDofs(e, xdofs);
|
||||
d_loc.GetSubVector(xdofs, d_loc_el);
|
||||
posV += d_loc_el;
|
||||
|
||||
const IntegrationRule &irule = det_fes->GetFE(e)->GetNodes();
|
||||
const int nsp = irule.GetNPoints();
|
||||
detvals.SetSize(nsp);
|
||||
det_fes->GetElementDofs(e, dofs);
|
||||
for (int q = 0; q < nsp; q++)
|
||||
{
|
||||
fe->CalcDShape(irule.IntPoint(q), dshape);
|
||||
MultAtB(pos, dshape, Jpr);
|
||||
detvals(q) = Jpr.Det();
|
||||
}
|
||||
det_gf->SetSubVector(dofs, detvals);
|
||||
}
|
||||
|
||||
auto minbounds = det_gf->EstimateFunctionMinimum(0, *det_plb,
|
||||
plb_rec_depth, 1e-5);
|
||||
|
||||
const DenseMatrix &Wideal =
|
||||
Geometries.GetGeomToPerfGeomJac(fes.GetMesh()->GetTypicalElementGeometry());
|
||||
return minbounds.first/Wideal.Det();
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
// Metric values are visualized by creating an L2 finite element functions and
|
||||
// computing the metric values at the nodes.
|
||||
|
||||
@@ -204,6 +204,11 @@ protected:
|
||||
// These fields are relevant for mixed meshes.
|
||||
IntegrationRules *IntegRules;
|
||||
int integ_order;
|
||||
// Determinant lower-bound data used by the line search.
|
||||
bool detJpr_pos_bound = false;
|
||||
std::unique_ptr<GridFunction> det_gf;
|
||||
std::unique_ptr<PLBound> det_plb;
|
||||
int plb_rec_depth = 0;
|
||||
|
||||
MemoryType temp_mt = MemoryType::DEFAULT;
|
||||
|
||||
@@ -216,9 +221,16 @@ protected:
|
||||
return ir;
|
||||
}
|
||||
|
||||
/// Compute the minimum det(Jpt) of the trial mesh at quadrature points
|
||||
/// (computes det(Jpr) and scales by the det of ideal target element).
|
||||
real_t ComputeMinDet(const Vector &d_loc,
|
||||
const FiniteElementSpace &fes) const;
|
||||
|
||||
/// Compute a lower bound for det(Jpt) of the trial mesh,
|
||||
/// (computes det(Jpr) and scales by the det of ideal target element).
|
||||
real_t ComputeDetJptLowerBound(const Vector &d_loc,
|
||||
const FiniteElementSpace &fes) const;
|
||||
|
||||
real_t MinDetJpr_2D(const FiniteElementSpace *, const Vector &) const;
|
||||
real_t MinDetJpr_3D(const FiniteElementSpace *, const Vector &) const;
|
||||
|
||||
@@ -261,6 +273,26 @@ public:
|
||||
|
||||
void SetMinDetPtr(real_t *md_ptr) { min_det_ptr = md_ptr; }
|
||||
|
||||
/** @brief Ensure a positive lower bound for the Jacobian determinant in
|
||||
tensor-product elements during line-search.
|
||||
@note The solver creates and updates its own determinant GridFunction
|
||||
from @a mesh while testing trial mesh positions. When @a mesh is a
|
||||
ParMesh, the internal determinant field is a ParGridFunction. The
|
||||
@a ref_factor controls the number of control points used by the PLBound
|
||||
object, and @a max_recursion_depth controls the depth used by the
|
||||
minimum-value estimator.
|
||||
|
||||
The determinant is represented by a high-order GridFunction computed
|
||||
at the mesh nodes. The order is chosen s.t. interpolating the det at
|
||||
some quad point would be equivalent to computing the det directly at the
|
||||
same quad point using the mesh positions.
|
||||
*/
|
||||
void EnsurePositiveDeterminantBound(Mesh &mesh, int ref_factor,
|
||||
int max_recursion_depth = 0);
|
||||
|
||||
/// Update internal determinant GridFunction after a mesh topology change.
|
||||
void UpdateDeterminantBoundGridFunction();
|
||||
|
||||
/// Set the memory type for temporary memory allocations.
|
||||
void SetTempMemoryType(MemoryType mt) { temp_mt = mt; }
|
||||
|
||||
|
||||
+501
-95
@@ -1030,12 +1030,42 @@ void L2ProjectionGridTransfer::L2ProjectionL2Space::EAProlongateTranspose(
|
||||
BatchedLinAlg::MultTranspose(P_dt, x, y);
|
||||
}
|
||||
|
||||
L2ProjectionGridTransfer::L2ProjectionH1Space::H1ConsistentMassOperator::
|
||||
H1ConsistentMassOperator(const Operator &M_LH_, const Solver &M_L_solver_)
|
||||
: Operator(M_LH_.Height(), M_LH_.Width()),
|
||||
M_LH(M_LH_),
|
||||
M_L_solver(M_L_solver_)
|
||||
{
|
||||
MFEM_VERIFY(M_LH.Height() == M_L_solver.Height() &&
|
||||
M_LH.Height() == M_L_solver.Width(),
|
||||
"incompatible consistent mass operator dimensions");
|
||||
}
|
||||
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::H1ConsistentMassOperator::
|
||||
Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
Vector tmp(M_LH.Height());
|
||||
M_LH.Mult(x, tmp);
|
||||
M_L_solver.Mult(tmp, y);
|
||||
}
|
||||
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::H1ConsistentMassOperator::
|
||||
MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
Vector tmp(M_LH.Height());
|
||||
M_L_solver.Mult(x, tmp);
|
||||
M_LH.MultTranspose(tmp, y);
|
||||
}
|
||||
|
||||
L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
const FiniteElementSpace& fes_ho_, const FiniteElementSpace& fes_lor_,
|
||||
const bool use_ea_, MemoryType d_mt_)
|
||||
const bool use_ea_, const bool use_consistent_mass_, MemoryType d_mt_)
|
||||
: L2Projection(fes_ho_, fes_lor_, d_mt_),
|
||||
use_ea(use_ea_)
|
||||
use_ea(use_ea_),
|
||||
use_consistent_mass(use_consistent_mass_)
|
||||
{
|
||||
MFEM_VERIFY(!(use_ea && use_consistent_mass),
|
||||
"consistent mass is not supported with element assembly");
|
||||
|
||||
// need scalar to keep dimensions matching (operators are built to apply
|
||||
// individually on each vdim)
|
||||
@@ -1053,7 +1083,7 @@ L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
|
||||
std::unique_ptr<SparseMatrix> R_mat, M_LH_mat;
|
||||
|
||||
std::tie(R_mat, M_LH_mat) = ComputeSparseRAndM_LH();
|
||||
std::tie(R_mat, M_LH_mat) = ComputeSparseRAndM_LH(!use_consistent_mass);
|
||||
|
||||
const SparseMatrix *P_ho = fes_ho_scalar->GetConformingProlongation();
|
||||
const SparseMatrix *P_lor = fes_lor_scalar->GetConformingProlongation();
|
||||
@@ -1062,40 +1092,71 @@ L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
{
|
||||
if (P_ho && P_lor)
|
||||
{
|
||||
R_mat.reset(RAP(*P_lor, *R_mat, *P_ho));
|
||||
if (R_mat) { R_mat.reset(RAP(*P_lor, *R_mat, *P_ho)); }
|
||||
M_LH_mat.reset(RAP(*P_lor, *M_LH_mat, *P_ho));
|
||||
}
|
||||
else if (P_ho)
|
||||
{
|
||||
R_mat.reset(mfem::Mult(*R_mat, *P_ho));
|
||||
if (R_mat) { R_mat.reset(mfem::Mult(*R_mat, *P_ho)); }
|
||||
M_LH_mat.reset(mfem::Mult(*M_LH_mat, *P_ho));
|
||||
}
|
||||
else // P_lor != nullptr
|
||||
{
|
||||
R_mat.reset(mfem::Mult(*P_lor, *R_mat));
|
||||
if (R_mat) { R_mat.reset(mfem::Mult(*P_lor, *R_mat)); }
|
||||
M_LH_mat.reset(mfem::Mult(*P_lor, *M_LH_mat));
|
||||
}
|
||||
}
|
||||
|
||||
SparseMatrix *RTxM_LH_mat = TransposeMult(*R_mat, *M_LH_mat);
|
||||
precon.reset(new DSmoother(*RTxM_LH_mat));
|
||||
if (use_consistent_mass)
|
||||
{
|
||||
BilinearForm M_lor(fes_lor_scalar.get());
|
||||
M_lor.AddDomainIntegrator(new MassIntegrator);
|
||||
M_lor.Assemble();
|
||||
M_lor.Finalize();
|
||||
SparseMatrix *M_L_mat = M_lor.LoseMat();
|
||||
|
||||
// Set ownership
|
||||
RTxM_LH.reset(RTxM_LH_mat);
|
||||
R = std::move(R_mat);
|
||||
M_LH = std::move(M_LH_mat);
|
||||
ML_precon.reset(new DSmoother(*M_L_mat));
|
||||
ML_pcg.SetPrintLevel(0);
|
||||
ML_pcg.SetMaxIter(1000);
|
||||
ML_pcg.SetRelTol(1e-13);
|
||||
ML_pcg.SetAbsTol(1e-13);
|
||||
ML_pcg.SetPreconditioner(*ML_precon);
|
||||
ML_pcg.SetOperator(*M_L_mat);
|
||||
// Start each solve from zero so repeated Operator::Mult() calls do not
|
||||
// depend on the output vector contents supplied by the caller.
|
||||
ML_pcg.iterative_mode = false;
|
||||
|
||||
SetupPCG();
|
||||
M_L.reset(M_L_mat);
|
||||
M_LH = std::move(M_LH_mat);
|
||||
R.reset(new H1ConsistentMassOperator(*M_LH, ML_pcg));
|
||||
}
|
||||
else
|
||||
{
|
||||
SparseMatrix *RTxM_LH_mat = TransposeMult(*R_mat, *M_LH_mat);
|
||||
precon.reset(new DSmoother(*RTxM_LH_mat));
|
||||
|
||||
// Set ownership
|
||||
RTxM_LH.reset(RTxM_LH_mat);
|
||||
R = std::move(R_mat);
|
||||
M_LH = std::move(M_LH_mat);
|
||||
|
||||
SetupPCG();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
const ParFiniteElementSpace& pfes_ho, const ParFiniteElementSpace& pfes_lor,
|
||||
const bool use_ea_, MemoryType d_mt_)
|
||||
const bool use_ea_, const bool use_consistent_mass_, MemoryType d_mt_)
|
||||
: L2Projection(pfes_ho, pfes_lor, d_mt_),
|
||||
use_ea(use_ea_), pcg(pfes_ho.GetComm())
|
||||
use_ea(use_ea_),
|
||||
use_consistent_mass(use_consistent_mass_),
|
||||
ML_pcg(pfes_ho.GetComm()),
|
||||
pcg(pfes_ho.GetComm())
|
||||
{
|
||||
MFEM_VERIFY(!(use_ea && use_consistent_mass),
|
||||
"consistent mass is not supported with element assembly");
|
||||
|
||||
// need scalar to keep dimensions matching (operators are built to apply
|
||||
// individually on each vdim)
|
||||
@@ -1111,8 +1172,42 @@ L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
return;
|
||||
}
|
||||
|
||||
std::tie(R, M_LH) = ComputeSparseRAndM_LH();
|
||||
std::tie(R, M_LH) = ComputeSparseRAndM_LH(!use_consistent_mass);
|
||||
|
||||
HypreParMatrix M_LH_local = HypreParMatrix(pfes_ho.GetComm(),
|
||||
pfes_lor_scalar->GlobalVSize(),
|
||||
pfes_ho_scalar->GlobalVSize(),
|
||||
pfes_lor_scalar->GetDofOffsets(),
|
||||
pfes_ho_scalar->GetDofOffsets(),
|
||||
static_cast<SparseMatrix*>(M_LH.get()));
|
||||
HypreParMatrix *M_LH_mat = RAP(pfes_lor_scalar->Dof_TrueDof_Matrix(),
|
||||
&M_LH_local, pfes_ho_scalar->Dof_TrueDof_Matrix());
|
||||
|
||||
if (use_consistent_mass)
|
||||
{
|
||||
ParBilinearForm M_lor(pfes_lor_scalar.get());
|
||||
M_lor.AddDomainIntegrator(new MassIntegrator);
|
||||
M_lor.Assemble();
|
||||
M_lor.Finalize();
|
||||
HypreParMatrix *M_L_mat = M_lor.ParallelAssemble();
|
||||
|
||||
M_L.reset(M_L_mat);
|
||||
M_LH.reset(M_LH_mat);
|
||||
HypreDiagScale *ML_hypre_precon = new HypreDiagScale(*M_L_mat);
|
||||
HyprePCG *ML_hypre_pcg = new HyprePCG(*M_L_mat);
|
||||
ML_hypre_pcg->SetPrintLevel(0);
|
||||
ML_hypre_pcg->SetMaxIter(1000);
|
||||
ML_hypre_pcg->SetTol(1e-13);
|
||||
ML_hypre_pcg->SetAbsTol(1e-13);
|
||||
ML_hypre_pcg->SetPreconditioner(*ML_hypre_precon);
|
||||
// Start each solve from zero so repeated Operator::Mult() calls do not
|
||||
// depend on the output vector contents supplied by the caller.
|
||||
ML_hypre_pcg->SetZeroInitialIterate();
|
||||
ML_precon.reset(ML_hypre_precon);
|
||||
ML_solver.reset(ML_hypre_pcg);
|
||||
R.reset(new H1ConsistentMassOperator(*M_LH, *ML_solver));
|
||||
return;
|
||||
}
|
||||
|
||||
HypreParMatrix R_local = HypreParMatrix(pfes_ho.GetComm(),
|
||||
pfes_lor_scalar->GlobalVSize(),
|
||||
@@ -1120,17 +1215,9 @@ L2ProjectionGridTransfer::L2ProjectionH1Space::L2ProjectionH1Space(
|
||||
pfes_lor_scalar->GetDofOffsets(),
|
||||
pfes_ho_scalar->GetDofOffsets(),
|
||||
static_cast<SparseMatrix*>(R.get()));
|
||||
HypreParMatrix M_LH_local = HypreParMatrix(pfes_ho.GetComm(),
|
||||
pfes_lor_scalar->GlobalVSize(),
|
||||
pfes_ho_scalar->GlobalVSize(),
|
||||
pfes_lor_scalar->GetDofOffsets(),
|
||||
pfes_ho_scalar->GetDofOffsets(),
|
||||
static_cast<SparseMatrix*>(M_LH.get()));
|
||||
|
||||
HypreParMatrix *R_mat = RAP(pfes_lor_scalar->Dof_TrueDof_Matrix(),
|
||||
&R_local, pfes_ho_scalar->Dof_TrueDof_Matrix());
|
||||
HypreParMatrix *M_LH_mat = RAP(pfes_lor_scalar->Dof_TrueDof_Matrix(),
|
||||
&M_LH_local, pfes_ho_scalar->Dof_TrueDof_Matrix());
|
||||
|
||||
std::unique_ptr<HypreParMatrix> R_T(R_mat->Transpose());
|
||||
HypreParMatrix *RTxM_LH_mat = ParMult(R_T.get(), M_LH_mat, true);
|
||||
@@ -1438,6 +1525,8 @@ void L2ProjectionGridTransfer::L2ProjectionH1Space::MultTranspose(
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::Prolongate(
|
||||
const Vector& x, Vector& y) const
|
||||
{
|
||||
MFEM_VERIFY(!use_consistent_mass,
|
||||
"BackwardOperator is not supported with consistent mass");
|
||||
|
||||
Vector X(fes_lor.GetTrueVSize());
|
||||
Vector X_dim(M_LH->Height());
|
||||
@@ -1469,6 +1558,9 @@ void L2ProjectionGridTransfer::L2ProjectionH1Space::Prolongate(
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::ProlongateTranspose(
|
||||
const Vector& x, Vector& y) const
|
||||
{
|
||||
MFEM_VERIFY(!use_consistent_mass,
|
||||
"BackwardOperator is not supported with consistent mass");
|
||||
|
||||
Vector X(fes_ho.GetTrueVSize());
|
||||
Vector X_dim(pcg.Width());
|
||||
Vector Xbar(pcg.Height());
|
||||
@@ -1499,17 +1591,34 @@ void L2ProjectionGridTransfer::L2ProjectionH1Space::ProlongateTranspose(
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::SetRelTol(real_t p_rtol_)
|
||||
{
|
||||
pcg.SetRelTol(p_rtol_);
|
||||
ML_pcg.SetRelTol(p_rtol_);
|
||||
#ifdef MFEM_USE_MPI
|
||||
if (ML_solver)
|
||||
{
|
||||
HyprePCG *hypre_pcg = dynamic_cast<HyprePCG*>(ML_solver.get());
|
||||
if (hypre_pcg) { hypre_pcg->SetTol(p_rtol_); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void L2ProjectionGridTransfer::L2ProjectionH1Space::SetAbsTol(real_t p_atol_)
|
||||
{
|
||||
pcg.SetAbsTol(p_atol_);
|
||||
ML_pcg.SetAbsTol(p_atol_);
|
||||
#ifdef MFEM_USE_MPI
|
||||
if (ML_solver)
|
||||
{
|
||||
HyprePCG *hypre_pcg = dynamic_cast<HyprePCG*>(ML_solver.get());
|
||||
if (hypre_pcg) { hypre_pcg->SetAbsTol(p_atol_); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::pair<
|
||||
std::unique_ptr<SparseMatrix>,
|
||||
std::unique_ptr<SparseMatrix>>
|
||||
L2ProjectionGridTransfer::L2ProjectionH1Space::ComputeSparseRAndM_LH()
|
||||
L2ProjectionGridTransfer::L2ProjectionH1Space::ComputeSparseRAndM_LH(
|
||||
bool build_R)
|
||||
{
|
||||
std::pair<std::unique_ptr<SparseMatrix>,
|
||||
std::unique_ptr<SparseMatrix>> r_and_mlh;
|
||||
@@ -1523,10 +1632,10 @@ std::unique_ptr<SparseMatrix>>
|
||||
// If the local mesh is empty, skip all computations
|
||||
if (nel_ho == 0)
|
||||
{
|
||||
return std::make_pair(
|
||||
std::unique_ptr<SparseMatrix>(new SparseMatrix),
|
||||
std::unique_ptr<SparseMatrix>(new SparseMatrix)
|
||||
);
|
||||
std::unique_ptr<SparseMatrix> R_empty;
|
||||
if (build_R) { R_empty.reset(new SparseMatrix); }
|
||||
std::unique_ptr<SparseMatrix> M_LH_empty(new SparseMatrix);
|
||||
return std::make_pair(std::move(R_empty), std::move(M_LH_empty));
|
||||
}
|
||||
|
||||
const CoarseFineTransformations& cf_tr = mesh_lor->GetRefinementTransforms();
|
||||
@@ -1542,69 +1651,76 @@ std::unique_ptr<SparseMatrix>>
|
||||
|
||||
BuildHo2Lor(nel_ho, nel_lor, cf_tr);
|
||||
|
||||
// ML_inv contains the inverse lumped (row sum) mass matrix. Note that the
|
||||
// method will also work with a full (consistent) mass matrix, though this is
|
||||
// not implemented here. L refers to the low-order refined mesh
|
||||
Vector ML_inv(ndof_lor);
|
||||
ML_inv = 0.0;
|
||||
|
||||
// Compute ML_inv
|
||||
for (int iho = 0; iho < nel_ho; ++iho)
|
||||
if (build_R)
|
||||
{
|
||||
Array<int> lor_els;
|
||||
ho2lor.GetRow(iho, lor_els);
|
||||
int nref = ho2lor.RowSize(iho);
|
||||
// ML_inv contains the inverse lumped (row sum) mass matrix. L refers to
|
||||
// the low-order refined mesh.
|
||||
ML_inv = 0.0;
|
||||
|
||||
Geometry::Type geom = mesh_ho->GetElementBaseGeometry(iho);
|
||||
const FiniteElement& fe_lor = *fes_lor.GetFE(lor_els[0]);
|
||||
int nedof_lor = fe_lor.GetDof();
|
||||
|
||||
// Instead of using a MassIntegrator, manually loop over integration
|
||||
// points so we can row sum and store the diagonal as a Vector.
|
||||
Vector ML_el(nedof_lor);
|
||||
Vector shape_lor(nedof_lor);
|
||||
Array<int> dofs_lor(nedof_lor);
|
||||
|
||||
for (int iref = 0; iref < nref; ++iref)
|
||||
// Compute ML_inv
|
||||
for (int iho = 0; iho < nel_ho; ++iho)
|
||||
{
|
||||
int ilor = lor_els[iref];
|
||||
ElementTransformation* el_tr = fes_lor.GetElementTransformation(ilor);
|
||||
Array<int> lor_els;
|
||||
ho2lor.GetRow(iho, lor_els);
|
||||
int nref = ho2lor.RowSize(iho);
|
||||
|
||||
int order = 2 * fe_lor.GetOrder() + el_tr->OrderW();
|
||||
const IntegrationRule* ir = &IntRules.Get(geom, order);
|
||||
ML_el = 0.0;
|
||||
for (int i = 0; i < ir->GetNPoints(); ++i)
|
||||
Geometry::Type geom = mesh_ho->GetElementBaseGeometry(iho);
|
||||
const FiniteElement& fe_lor = *fes_lor.GetFE(lor_els[0]);
|
||||
int nedof_lor = fe_lor.GetDof();
|
||||
|
||||
// Instead of using a MassIntegrator, manually loop over integration
|
||||
// points so we can row sum and store the diagonal as a Vector.
|
||||
Vector ML_el(nedof_lor);
|
||||
Vector shape_lor(nedof_lor);
|
||||
Array<int> dofs_lor(nedof_lor);
|
||||
|
||||
for (int iref = 0; iref < nref; ++iref)
|
||||
{
|
||||
const IntegrationPoint& ip_lor = ir->IntPoint(i);
|
||||
fe_lor.CalcShape(ip_lor, shape_lor);
|
||||
el_tr->SetIntPoint(&ip_lor);
|
||||
ML_el += (shape_lor *= (el_tr->Weight() * ip_lor.weight));
|
||||
int ilor = lor_els[iref];
|
||||
ElementTransformation* el_tr = fes_lor.GetElementTransformation(ilor);
|
||||
|
||||
int order = 2 * fe_lor.GetOrder() + el_tr->OrderW();
|
||||
const IntegrationRule* ir = &IntRules.Get(geom, order);
|
||||
ML_el = 0.0;
|
||||
for (int i = 0; i < ir->GetNPoints(); ++i)
|
||||
{
|
||||
const IntegrationPoint& ip_lor = ir->IntPoint(i);
|
||||
fe_lor.CalcShape(ip_lor, shape_lor);
|
||||
el_tr->SetIntPoint(&ip_lor);
|
||||
ML_el += (shape_lor *= (el_tr->Weight() * ip_lor.weight));
|
||||
}
|
||||
fes_lor.GetElementDofs(ilor, dofs_lor);
|
||||
ML_inv.AddElementVector(dofs_lor, ML_el);
|
||||
}
|
||||
fes_lor.GetElementDofs(ilor, dofs_lor);
|
||||
ML_inv.AddElementVector(dofs_lor, ML_el);
|
||||
}
|
||||
// DOF by DOF inverse of non-zero entries
|
||||
LumpedMassInverse(ML_inv);
|
||||
}
|
||||
// DOF by DOF inverse of non-zero entries
|
||||
LumpedMassInverse(ML_inv);
|
||||
|
||||
// Compute sparsity pattern for R = M_L^(-1) M_LH and allocate
|
||||
r_and_mlh.first = AllocR();
|
||||
std::unique_ptr<SparseMatrix> pattern = AllocR();
|
||||
if (build_R)
|
||||
{
|
||||
r_and_mlh.first = std::move(pattern);
|
||||
}
|
||||
// Allocate M_LH (same sparsity pattern as R)
|
||||
// L refers to the low-order refined mesh (DOFs correspond to rows)
|
||||
// H refers to the higher-order mesh (DOFs correspond to columns)
|
||||
Memory<int> I(r_and_mlh.first->Height() + 1);
|
||||
for (int icol = 0; icol < r_and_mlh.first->Height() + 1; ++icol)
|
||||
SparseMatrix &pattern_mat = build_R ? *r_and_mlh.first : *pattern;
|
||||
Memory<int> I(pattern_mat.Height() + 1);
|
||||
for (int icol = 0; icol < pattern_mat.Height() + 1; ++icol)
|
||||
{
|
||||
I[icol] = r_and_mlh.first->GetI()[icol];
|
||||
I[icol] = pattern_mat.GetI()[icol];
|
||||
}
|
||||
Memory<int> J(r_and_mlh.first->NumNonZeroElems());
|
||||
for (int jcol = 0; jcol < r_and_mlh.first->NumNonZeroElems(); ++jcol)
|
||||
Memory<int> J(pattern_mat.NumNonZeroElems());
|
||||
for (int jcol = 0; jcol < pattern_mat.NumNonZeroElems(); ++jcol)
|
||||
{
|
||||
J[jcol] = r_and_mlh.first->GetJ()[jcol];
|
||||
J[jcol] = pattern_mat.GetJ()[jcol];
|
||||
}
|
||||
r_and_mlh.second = std::unique_ptr<SparseMatrix>(
|
||||
new SparseMatrix(I, J, NULL, r_and_mlh.first->Height(),
|
||||
r_and_mlh.first->Width(), true, true, true));
|
||||
new SparseMatrix(I, J, NULL, pattern_mat.Height(),
|
||||
pattern_mat.Width(), true, true, true));
|
||||
|
||||
IntegrationPointTransformation ip_tr;
|
||||
IsoparametricTransformation& emb_tr = ip_tr.Transf;
|
||||
@@ -1647,15 +1763,21 @@ std::unique_ptr<SparseMatrix>>
|
||||
Array<int> dofs_lor(nedof_lor);
|
||||
fes_lor.GetElementDofs(ilor, dofs_lor);
|
||||
Vector R_row;
|
||||
for (int i = 0; i < nedof_lor; ++i)
|
||||
if (build_R)
|
||||
{
|
||||
M_LH_el.GetRow(i, R_row);
|
||||
R_el.SetRow(i, R_row.Set(ML_inv[dofs_lor[i]], R_row));
|
||||
for (int i = 0; i < nedof_lor; ++i)
|
||||
{
|
||||
M_LH_el.GetRow(i, R_row);
|
||||
R_el.SetRow(i, R_row.Set(ML_inv[dofs_lor[i]], R_row));
|
||||
}
|
||||
}
|
||||
Array<int> dofs_ho(nedof_ho);
|
||||
fes_ho.GetElementDofs(iho, dofs_ho);
|
||||
r_and_mlh.second->AddSubMatrix(dofs_lor, dofs_ho, M_LH_el);
|
||||
r_and_mlh.first->AddSubMatrix(dofs_lor, dofs_ho, R_el);
|
||||
if (build_R)
|
||||
{
|
||||
r_and_mlh.first->AddSubMatrix(dofs_lor, dofs_ho, R_el);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2009,6 +2131,8 @@ const Operator &L2ProjectionGridTransfer::ForwardOperator()
|
||||
|
||||
const Operator &L2ProjectionGridTransfer::BackwardOperator()
|
||||
{
|
||||
MFEM_VERIFY(!UsesH1ConsistentMass(),
|
||||
"BackwardOperator is not supported with consistent mass");
|
||||
if (!B)
|
||||
{
|
||||
if (!F) { BuildF(); }
|
||||
@@ -2017,15 +2141,30 @@ const Operator &L2ProjectionGridTransfer::BackwardOperator()
|
||||
return *B;
|
||||
}
|
||||
|
||||
void L2ProjectionGridTransfer::UseConsistentMass(bool use_consistent_mass_)
|
||||
{
|
||||
MFEM_VERIFY(!F && !B,
|
||||
"UseConsistentMass must be called before constructing operators");
|
||||
use_consistent_mass = use_consistent_mass_;
|
||||
}
|
||||
|
||||
bool L2ProjectionGridTransfer::UsesH1ConsistentMass() const
|
||||
{
|
||||
return use_consistent_mass && !force_l2_space &&
|
||||
dom_fes.FEColl()->GetContType() == FiniteElementCollection::CONTINUOUS;
|
||||
}
|
||||
|
||||
void L2ProjectionGridTransfer::BuildF()
|
||||
{
|
||||
if (!force_l2_space &&
|
||||
dom_fes.FEColl()->GetContType() == FiniteElementCollection::CONTINUOUS)
|
||||
{
|
||||
MFEM_VERIFY(!(use_ea && use_consistent_mass),
|
||||
"consistent mass is not supported with element assembly");
|
||||
if (!Parallel())
|
||||
{
|
||||
F = new L2ProjectionH1Space(dom_fes, ran_fes,
|
||||
use_ea, d_mt);
|
||||
use_ea, use_consistent_mass, d_mt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2035,7 +2174,7 @@ void L2ProjectionGridTransfer::BuildF()
|
||||
const mfem::ParFiniteElementSpace& ran_pfes =
|
||||
static_cast<mfem::ParFiniteElementSpace&>(ran_fes);
|
||||
F = new L2ProjectionH1Space(dom_pfes, ran_pfes,
|
||||
use_ea, d_mt);
|
||||
use_ea, use_consistent_mass, d_mt);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2048,6 +2187,7 @@ void L2ProjectionGridTransfer::BuildF()
|
||||
|
||||
bool L2ProjectionGridTransfer::SupportsBackwardsOperator() const
|
||||
{
|
||||
if (UsesH1ConsistentMass()) { return false; }
|
||||
return ran_fes.GetTrueVSize() >= dom_fes.GetTrueVSize();
|
||||
}
|
||||
|
||||
@@ -2057,6 +2197,10 @@ TransferOperator::TransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
: Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize())
|
||||
{
|
||||
bool isvar_order = lFESpace_.IsVariableOrder() || hFESpace_.IsVariableOrder();
|
||||
bool is_trace_space =
|
||||
(dynamic_cast<const H1_Trace_FECollection*>(lFESpace_.FEColl()) ||
|
||||
dynamic_cast<const ND_Trace_FECollection*>(lFESpace_.FEColl()) ||
|
||||
dynamic_cast<const RT_Trace_FECollection*>(lFESpace_.FEColl()));
|
||||
if (lFESpace_.FEColl() == hFESpace_.FEColl() && !isvar_order)
|
||||
{
|
||||
OperatorPtr P(Operator::ANY_TYPE);
|
||||
@@ -2066,6 +2210,7 @@ TransferOperator::TransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
}
|
||||
else if (lFESpace_.GetVDim() == 1
|
||||
&& hFESpace_.GetVDim() == 1
|
||||
&& !is_trace_space
|
||||
&& dynamic_cast<const TensorBasisElement*>(lFESpace_.GetTypicalFE())
|
||||
&& dynamic_cast<const TensorBasisElement*>(hFESpace_.GetTypicalFE())
|
||||
&& !isvar_order
|
||||
@@ -2096,15 +2241,245 @@ void TransferOperator::MultTranspose(const Vector& x, Vector& y) const
|
||||
|
||||
|
||||
PRefinementTransferOperator::PRefinementTransferOperator(
|
||||
const FiniteElementSpace& lFESpace_, const FiniteElementSpace& hFESpace_)
|
||||
const FiniteElementSpace& lFESpace_, const FiniteElementSpace& hFESpace_,
|
||||
bool assemble_matrix)
|
||||
: Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize()), lFESpace(lFESpace_),
|
||||
hFESpace(hFESpace_)
|
||||
{
|
||||
isvar_order = lFESpace_.IsVariableOrder() || hFESpace_.IsVariableOrder();
|
||||
|
||||
MFEM_VERIFY(lFESpace.FEColl()->GetContType() ==
|
||||
hFESpace.FEColl()->GetContType(),
|
||||
"Incompatible finite element space continuity types.");
|
||||
|
||||
is_trace_space =
|
||||
(dynamic_cast<const H1_Trace_FECollection*>(lFESpace.FEColl()) ||
|
||||
dynamic_cast<const ND_Trace_FECollection*>(lFESpace.FEColl()) ||
|
||||
dynamic_cast<const RT_Trace_FECollection*>(lFESpace.FEColl()));
|
||||
|
||||
if (assemble_matrix) { AssembleMatrix(); }
|
||||
|
||||
}
|
||||
|
||||
void PRefinementTransferOperator::AssembleMatrix()
|
||||
{
|
||||
Mesh* mesh = hFESpace.GetMesh();
|
||||
const int nL = lFESpace.GetVSize();
|
||||
const int nH = hFESpace.GetVSize();
|
||||
|
||||
P.reset(new SparseMatrix(nH, nL));
|
||||
Array<int> l_dofs, h_dofs, l_vdofs, h_vdofs;
|
||||
DenseMatrix loc_prol;
|
||||
|
||||
Geometry::Type cached_geom = Geometry::INVALID;
|
||||
const FiniteElement* h_fe = nullptr;
|
||||
const FiniteElement* l_fe = nullptr;
|
||||
IsoparametricTransformation T;
|
||||
|
||||
int vdim = lFESpace.GetVDim();
|
||||
|
||||
const int iend = (is_trace_space) ? mesh->GetNumFaces() : mesh->GetNE();
|
||||
DofTransformation doftrans_h, doftrans_l;
|
||||
Vector w(nH); w = 0.0;
|
||||
|
||||
for (int i = 0; i < iend; i++)
|
||||
{
|
||||
if (is_trace_space)
|
||||
{
|
||||
hFESpace.GetFaceDofs(i, h_dofs);
|
||||
lFESpace.GetFaceDofs(i, l_dofs);
|
||||
}
|
||||
else
|
||||
{
|
||||
hFESpace.GetElementDofs(i, h_dofs, doftrans_h);
|
||||
lFESpace.GetElementDofs(i, l_dofs, doftrans_l);
|
||||
}
|
||||
|
||||
const Geometry::Type geom = (is_trace_space) ? mesh->GetFaceGeometry(i)
|
||||
: mesh->GetElementBaseGeometry(i);
|
||||
|
||||
if (geom != cached_geom || isvar_order)
|
||||
{
|
||||
h_fe = (is_trace_space) ? hFESpace.GetFaceElement(i) : hFESpace.GetFE(i);
|
||||
l_fe = (is_trace_space) ? lFESpace.GetFaceElement(i) : lFESpace.GetFE(i);
|
||||
T.SetIdentityTransformation(h_fe->GetGeomType());
|
||||
h_fe->GetTransferMatrix(*l_fe, T, loc_prol);
|
||||
cached_geom = geom;
|
||||
}
|
||||
|
||||
DenseMatrix Aeff(loc_prol);
|
||||
TransformPrimal(doftrans_h, doftrans_l, Aeff);
|
||||
for (int vd = 0; vd < vdim; vd++)
|
||||
{
|
||||
DenseMatrix temp_Aeff(Aeff);
|
||||
|
||||
l_dofs.Copy(l_vdofs);
|
||||
lFESpace.DofsToVDofs(vd, l_vdofs);
|
||||
|
||||
h_dofs.Copy(h_vdofs);
|
||||
hFESpace.DofsToVDofs(vd, h_vdofs);
|
||||
|
||||
temp_Aeff.AdjustDofDirection(h_vdofs, l_vdofs);
|
||||
|
||||
P->AddSubMatrix(h_vdofs, l_vdofs, temp_Aeff);
|
||||
|
||||
for (int rr = 0; rr < h_vdofs.Size(); rr++)
|
||||
{
|
||||
w(h_vdofs[rr]) += 1.0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
P->Finalize();
|
||||
|
||||
Vector inv_w(nH);
|
||||
for (int i = 0; i < nH; i++)
|
||||
{
|
||||
inv_w(i) = (w(i) > 0.0) ? (1.0 / w(i)) : 1.0;
|
||||
}
|
||||
|
||||
P->ScaleRows(inv_w);
|
||||
|
||||
assembled = true;
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<SparseMatrix>
|
||||
PRefinementTransferOperator::BuildConformingTransferMatrix() const
|
||||
{
|
||||
MFEM_VERIFY(assembled && P, "Matrix path requires assembled P.");
|
||||
|
||||
const SparseMatrix *Pl = lFESpace.GetConformingProlongation();
|
||||
const SparseMatrix *Rh = hFESpace.GetRestrictionMatrix();
|
||||
|
||||
if (Pl && Rh)
|
||||
{
|
||||
SparseMatrix *RhP = mfem::Mult(*Rh, *P);
|
||||
SparseMatrix *RhPPl = mfem::Mult(*RhP, *Pl);
|
||||
delete RhP;
|
||||
return std::unique_ptr<SparseMatrix>(RhPPl);
|
||||
}
|
||||
else if (Pl)
|
||||
{
|
||||
return std::unique_ptr<SparseMatrix>(mfem::Mult(*P, *Pl));
|
||||
}
|
||||
else if (Rh)
|
||||
{
|
||||
return std::unique_ptr<SparseMatrix>(mfem::Mult(*Rh, *P));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_unique<SparseMatrix>(*P);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Operator>
|
||||
PRefinementTransferOperator::BuildConformingTransferOperator() const
|
||||
{
|
||||
const Operator *Pl = lFESpace.GetProlongationMatrix();
|
||||
const Operator *Rh = hFESpace.GetRestrictionOperator();
|
||||
|
||||
if (Pl && Rh)
|
||||
{
|
||||
return std::make_unique<TripleProductOperator>(Rh,
|
||||
const_cast<PRefinementTransferOperator*>(this), Pl,
|
||||
false, false, false);
|
||||
}
|
||||
else if (Pl)
|
||||
{
|
||||
return std::make_unique<ProductOperator>
|
||||
(const_cast<PRefinementTransferOperator*>(this), Pl,
|
||||
false, false);
|
||||
}
|
||||
else if (Rh)
|
||||
{
|
||||
return std::make_unique<ProductOperator>(Rh,
|
||||
const_cast<PRefinementTransferOperator*>(this),
|
||||
false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// return nullptr to mean "identity/no-op wrapper", i.e. use `this`
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Operator *
|
||||
PRefinementTransferOperator::GetTrueTransferOperator()
|
||||
{
|
||||
if (tP) { return tP.get(); }
|
||||
#ifdef MFEM_USE_MPI
|
||||
const ParFiniteElementSpace* lpfes = dynamic_cast<const ParFiniteElementSpace*>
|
||||
(&lFESpace);
|
||||
const ParFiniteElementSpace* hpfes = dynamic_cast<const ParFiniteElementSpace*>
|
||||
(&hFESpace);
|
||||
bool parallel = (lpfes) && (hpfes);
|
||||
|
||||
if (parallel)
|
||||
{
|
||||
if (assembled)
|
||||
{
|
||||
HypreParMatrix * Pl = lpfes->Dof_TrueDof_Matrix();
|
||||
const SparseMatrix * Rh = hpfes->GetRestrictionMatrix();
|
||||
// Rh * P
|
||||
SparseMatrix * RhP = mfem::Mult(*Rh, *P);
|
||||
HypreParMatrix * RhPh = new HypreParMatrix(hpfes->GetComm(),
|
||||
hpfes->GlobalTrueVSize(), lpfes->GlobalVSize(),
|
||||
hpfes->GetTrueDofOffsets(), lpfes->GetDofOffsets(), RhP);
|
||||
HypreStealOwnership(*RhPh, *RhP);
|
||||
delete RhP;
|
||||
HypreParMatrix * tmp = ParMult(RhPh, Pl, true);
|
||||
delete RhPh;
|
||||
tP.reset(tmp);
|
||||
return tP.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto Pl = lpfes->GetProlongationMatrix();
|
||||
auto Rh = hpfes->GetRestrictionOperator();
|
||||
tP = std::make_unique<TripleProductOperator>(Rh, this, Pl, false, false, false);
|
||||
return tP.get();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (assembled)
|
||||
{
|
||||
auto M = BuildConformingTransferMatrix();
|
||||
tP.reset(M.release());
|
||||
return tP.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
tP = BuildConformingTransferOperator();
|
||||
return tP ? tP.get() : this;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
if (assembled)
|
||||
{
|
||||
auto M = BuildConformingTransferMatrix();
|
||||
tP.reset(M.release());
|
||||
return tP.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
tP = BuildConformingTransferOperator();
|
||||
return tP ? tP.get() : this;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PRefinementTransferOperator::Mult(const Vector& x, Vector& y) const
|
||||
{
|
||||
y = 0.0;
|
||||
|
||||
if (assembled) { P->Mult(x, y); return; }
|
||||
|
||||
Mesh* mesh = hFESpace.GetMesh();
|
||||
Array<int> l_dofs, h_dofs, l_vdofs, h_vdofs;
|
||||
DenseMatrix loc_prol;
|
||||
@@ -2117,19 +2492,31 @@ void PRefinementTransferOperator::Mult(const Vector& x, Vector& y) const
|
||||
|
||||
int vdim = lFESpace.GetVDim();
|
||||
|
||||
y = 0.0;
|
||||
|
||||
DofTransformation doftrans_h, doftrans_l;
|
||||
for (int i = 0; i < mesh->GetNE(); i++)
|
||||
{
|
||||
hFESpace.GetElementDofs(i, h_dofs, doftrans_h);
|
||||
lFESpace.GetElementDofs(i, l_dofs, doftrans_l);
|
||||
|
||||
const Geometry::Type geom = mesh->GetElementBaseGeometry(i);
|
||||
const int iend = (is_trace_space) ? mesh->GetNumFaces() : mesh->GetNE();
|
||||
|
||||
for (int i = 0; i < iend; i++)
|
||||
{
|
||||
if (is_trace_space)
|
||||
{
|
||||
hFESpace.GetFaceDofs(i, h_dofs);
|
||||
lFESpace.GetFaceDofs(i, l_dofs);
|
||||
}
|
||||
else
|
||||
{
|
||||
hFESpace.GetElementDofs(i, h_dofs, doftrans_h);
|
||||
lFESpace.GetElementDofs(i, l_dofs, doftrans_l);
|
||||
}
|
||||
|
||||
const Geometry::Type geom = (is_trace_space) ? mesh->GetFaceGeometry(i)
|
||||
: mesh->GetElementBaseGeometry(i);
|
||||
|
||||
if (geom != cached_geom || isvar_order)
|
||||
{
|
||||
h_fe = hFESpace.GetFE(i);
|
||||
l_fe = lFESpace.GetFE(i);
|
||||
h_fe = (is_trace_space) ? hFESpace.GetFaceElement(i) : hFESpace.GetFE(i);
|
||||
l_fe = (is_trace_space) ? lFESpace.GetFaceElement(i) : lFESpace.GetFE(i);
|
||||
T.SetIdentityTransformation(h_fe->GetGeomType());
|
||||
h_fe->GetTransferMatrix(*l_fe, T, loc_prol);
|
||||
subY.SetSize(loc_prol.Height());
|
||||
@@ -2144,6 +2531,7 @@ void PRefinementTransferOperator::Mult(const Vector& x, Vector& y) const
|
||||
hFESpace.DofsToVDofs(vd, h_vdofs);
|
||||
x.GetSubVector(l_vdofs, subX);
|
||||
doftrans_l.InvTransformPrimal(subX);
|
||||
|
||||
loc_prol.Mult(subX, subY);
|
||||
doftrans_h.TransformPrimal(subY);
|
||||
y.SetSubVector(h_vdofs, subY);
|
||||
@@ -2156,6 +2544,12 @@ void PRefinementTransferOperator::MultTranspose(const Vector& x,
|
||||
{
|
||||
y = 0.0;
|
||||
|
||||
if (assembled)
|
||||
{
|
||||
P->MultTranspose(x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
Mesh* mesh = hFESpace.GetMesh();
|
||||
Array<int> l_dofs, h_dofs, l_vdofs, h_vdofs;
|
||||
DenseMatrix loc_prol;
|
||||
@@ -2173,16 +2567,28 @@ void PRefinementTransferOperator::MultTranspose(const Vector& x,
|
||||
|
||||
DofTransformation doftrans_h, doftrans_l;
|
||||
|
||||
for (int i = 0; i < mesh->GetNE(); i++)
|
||||
{
|
||||
hFESpace.GetElementDofs(i, h_dofs, doftrans_h);
|
||||
lFESpace.GetElementDofs(i, l_dofs, doftrans_l);
|
||||
int iend = (is_trace_space) ? mesh->GetNumFaces() : mesh->GetNE();
|
||||
|
||||
for (int i = 0; i < iend; i++)
|
||||
{
|
||||
if (is_trace_space)
|
||||
{
|
||||
hFESpace.GetFaceDofs(i, h_dofs);
|
||||
lFESpace.GetFaceDofs(i, l_dofs);
|
||||
}
|
||||
else
|
||||
{
|
||||
hFESpace.GetElementDofs(i, h_dofs, doftrans_h);
|
||||
lFESpace.GetElementDofs(i, l_dofs, doftrans_l);
|
||||
}
|
||||
|
||||
const Geometry::Type geom = (is_trace_space) ? mesh->GetFaceGeometry(i)
|
||||
: mesh->GetElementBaseGeometry(i);
|
||||
|
||||
const Geometry::Type geom = mesh->GetElementBaseGeometry(i);
|
||||
if (geom != cached_geom || isvar_order)
|
||||
{
|
||||
h_fe = hFESpace.GetFE(i);
|
||||
l_fe = lFESpace.GetFE(i);
|
||||
h_fe = (is_trace_space) ? hFESpace.GetFaceElement(i) : hFESpace.GetFE(i);
|
||||
l_fe = (is_trace_space) ? lFESpace.GetFaceElement(i) : lFESpace.GetFE(i);
|
||||
T.SetIdentityTransformation(h_fe->GetGeomType());
|
||||
h_fe->GetTransferMatrix(*l_fe, T, loc_prol);
|
||||
loc_prol.Transpose();
|
||||
|
||||
+92
-20
@@ -169,10 +169,12 @@ public:
|
||||
is the forward transfer matrix, and M_f is the mass matrix on the coarse
|
||||
element. For L2 spaces, M_f is the mass matrix on the union of all fine
|
||||
elements comprising the coarse element. For H1 spaces, M_f is a diagonal
|
||||
(lumped) mass matrix computed through row-summation. Note that the backward
|
||||
transfer operator, B, is a left inverse of the forward transfer operator, F,
|
||||
i.e. B F = I. Both F and B are defined in physical space and, generally for
|
||||
L2 spaces, vary between different mesh elements.
|
||||
(lumped) mass matrix computed through row-summation, unless
|
||||
UseConsistentMass() is enabled for the forward H1 operator. When the
|
||||
backward transfer operator, B, is supported, it is a left inverse of the
|
||||
forward transfer operator, F, i.e. B F = I. Both F and B are defined in
|
||||
physical space and, generally for L2 spaces, vary between different mesh
|
||||
elements.
|
||||
|
||||
This class supports H1 and L2 finite element spaces. Fine meshes are a
|
||||
uniform refinement of the coarse mesh, usually created through
|
||||
@@ -352,16 +354,21 @@ public:
|
||||
class L2ProjectionH1Space : public L2Projection
|
||||
{
|
||||
const bool use_ea;
|
||||
/// Use the consistent low-order mass matrix in non-EA H1 Mult() and
|
||||
/// MultTranspose().
|
||||
const bool use_consistent_mass;
|
||||
|
||||
public:
|
||||
L2ProjectionH1Space(const FiniteElementSpace &fes_ho_,
|
||||
const FiniteElementSpace &fes_lor_,
|
||||
const bool use_ea_,
|
||||
const bool use_consistent_mass_,
|
||||
MemoryType d_mt_ = Device::GetHostMemoryType());
|
||||
#ifdef MFEM_USE_MPI
|
||||
L2ProjectionH1Space(const ParFiniteElementSpace &pfes_ho_,
|
||||
const ParFiniteElementSpace &pfes_lor_,
|
||||
const bool use_ea_,
|
||||
const bool use_consistent_mass_,
|
||||
MemoryType d_mt_ = Device::GetHostMemoryType());
|
||||
#endif
|
||||
/// Same as above but assembles action of R through 4 parts:
|
||||
@@ -417,13 +424,33 @@ public:
|
||||
void SetAbsTol(real_t p_atol_) override;
|
||||
|
||||
protected:
|
||||
/// Applies the H1 transfer R = M_L^{-1} M_LH and its transpose, where
|
||||
/// M_L is the consistent low-order mass matrix.
|
||||
class H1ConsistentMassOperator : public Operator
|
||||
{
|
||||
private:
|
||||
const Operator &M_LH;
|
||||
const Solver &M_L_solver;
|
||||
|
||||
public:
|
||||
H1ConsistentMassOperator(const Operator &M_LH_,
|
||||
const Solver &M_L_solver_);
|
||||
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
void MultTranspose(const Vector &x, Vector &y) const override;
|
||||
};
|
||||
|
||||
/// Sets up the PCG solver (sets parameters, operator, and preconditioner)
|
||||
void SetupPCG();
|
||||
|
||||
/// @brief Computes on-rank R and M_LH matrices. If true, computes mixed mass and/or
|
||||
/// inverse lumped mass matrix error when compared to device implementation.
|
||||
/** @brief Computes on-rank R and M_LH matrices.
|
||||
|
||||
If build_R is true, the returned pair contains both R and M_LH. If
|
||||
build_R is false, the first pointer is null and only M_LH is built. */
|
||||
std::pair<std::unique_ptr<SparseMatrix>,
|
||||
std::unique_ptr<SparseMatrix>> ComputeSparseRAndM_LH();
|
||||
std::unique_ptr<SparseMatrix>> ComputeSparseRAndM_LH(
|
||||
bool build_R = true);
|
||||
|
||||
/// @brief Recovers vector of tdofs given a vector of dofs and a finite
|
||||
/// element space
|
||||
@@ -453,20 +480,30 @@ public:
|
||||
/// elements and refined LOR elements.
|
||||
std::unique_ptr<SparseMatrix> AllocR();
|
||||
|
||||
CGSolver pcg;
|
||||
std::unique_ptr<Solver> precon;
|
||||
/// Consistent low-order mass matrix used when use_consistent_mass is true.
|
||||
std::unique_ptr<Operator> M_L;
|
||||
// Used to compute P = (RT*M_LH)^(-1) M_LH^T
|
||||
std::unique_ptr<Operator> M_LH;
|
||||
// Lumped M_L inverse operator built via EA. Wrapped with restriction maps
|
||||
// to multiply with scalar TDof LOR vectors.
|
||||
std::unique_ptr<Operator> ML_inv_vea;
|
||||
/// Preconditioner for applying the inverse consistent low-order mass
|
||||
/// matrix.
|
||||
std::unique_ptr<Solver> ML_precon;
|
||||
/// Serial PCG solver for applying the inverse consistent low-order mass
|
||||
/// matrix in H1 Mult() and MultTranspose().
|
||||
CGSolver ML_pcg;
|
||||
/// Solver used by H1ConsistentMassOperator to apply M_L^{-1}.
|
||||
std::unique_ptr<Solver> ML_solver;
|
||||
// The restriction operator is represented as an Operator R. The
|
||||
// prolongation operator is a dense matrix computed as the inverse of (R^T
|
||||
// M_L R), and hence, is not stored.
|
||||
// If element assembly is enabled
|
||||
std::unique_ptr<Operator> R;
|
||||
// Used to compute P = (RT*M_LH)^(-1) M_LH^T
|
||||
std::unique_ptr<Operator> M_LH;
|
||||
// Inverted operator in P = (RT*M_LH)^(-1) M_LH^T. Used to compute P via PCG.
|
||||
std::unique_ptr<Operator> RTxM_LH;
|
||||
// Lumped M_L inverse operator built via EA. Wrapped with restriction maps
|
||||
// to multiply with scalar TDof LOR vectors.
|
||||
std::unique_ptr<Operator> ML_inv_vea;
|
||||
std::unique_ptr<Solver> precon;
|
||||
CGSolver pcg;
|
||||
// LDof Mixed mass operator built via EA. Wrapped with restriction maps to send
|
||||
// scalar LDof HO vectors to LDof LOR vectors.
|
||||
Operator *M_LH_local_op;
|
||||
@@ -478,7 +515,6 @@ public:
|
||||
Vector M_LH_ea;
|
||||
// Element Assembled lumped M_L inverse built via EA. Stores diagonal as a Ldof vector.
|
||||
Vector ML_inv_ea;
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
std::unique_ptr<ParFiniteElementSpace> pfes_ho_scalar;
|
||||
std::unique_ptr<ParFiniteElementSpace> pfes_lor_scalar;
|
||||
@@ -511,6 +547,9 @@ public:
|
||||
L2Projection *F; ///< Forward, coarse-to-fine, operator
|
||||
L2Prolongation *B; ///< Backward, fine-to-coarse, operator
|
||||
bool force_l2_space;
|
||||
/// Use the consistent low-order mass matrix for non-EA H1 Mult() and
|
||||
/// MultTranspose().
|
||||
bool use_consistent_mass;
|
||||
|
||||
public:
|
||||
L2ProjectionGridTransfer(FiniteElementSpace &coarse_fes_,
|
||||
@@ -518,16 +557,26 @@ public:
|
||||
bool force_l2_space_ = false,
|
||||
MemoryType d_mt_ = Device::GetHostMemoryType()) // move to method
|
||||
: GridTransfer(coarse_fes_, fine_fes_),
|
||||
F(NULL), B(NULL), force_l2_space(force_l2_space_)
|
||||
F(NULL), B(NULL), force_l2_space(force_l2_space_),
|
||||
use_consistent_mass(false)
|
||||
{ }
|
||||
virtual ~L2ProjectionGridTransfer();
|
||||
|
||||
/** @brief Use the consistent low-order mass matrix in H1 non-EA Mult() and
|
||||
MultTranspose().
|
||||
|
||||
This option must be set before constructing the transfer operators. It
|
||||
only affects H1 transfer, is not supported with element assembly, and
|
||||
disables BackwardOperator(). */
|
||||
void UseConsistentMass(bool use_consistent_mass_ = true);
|
||||
|
||||
const Operator &ForwardOperator() override;
|
||||
|
||||
const Operator &BackwardOperator() override;
|
||||
|
||||
bool SupportsBackwardsOperator() const override;
|
||||
private:
|
||||
bool UsesH1ConsistentMass() const;
|
||||
void BuildF();
|
||||
};
|
||||
|
||||
@@ -569,15 +618,38 @@ private:
|
||||
const FiniteElementSpace& lFESpace;
|
||||
const FiniteElementSpace& hFESpace;
|
||||
bool isvar_order;
|
||||
bool is_trace_space;
|
||||
bool assembled = false;
|
||||
std::unique_ptr<SparseMatrix> P;
|
||||
std::unique_ptr<Operator> tP;
|
||||
|
||||
std::unique_ptr<SparseMatrix> BuildConformingTransferMatrix() const;
|
||||
std::unique_ptr<Operator> BuildConformingTransferOperator() const;
|
||||
|
||||
void AssembleMatrix();
|
||||
|
||||
public:
|
||||
/// @brief Constructs a transfer operator from \p lFESpace to \p hFESpace
|
||||
/// which have different FE collections.
|
||||
/** No matrices are assembled, only the action to a vector is being computed.
|
||||
The underlying finite elements need to implement the GetTransferMatrix
|
||||
methods. */
|
||||
/** By default no matrices are assembled, only the action to a vector is
|
||||
being computed. The underlying finite elements need to implement
|
||||
the GetTransferMatrix methods. */
|
||||
PRefinementTransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
const FiniteElementSpace& hFESpace_);
|
||||
const FiniteElementSpace& hFESpace_,
|
||||
bool assemble_matrix = false);
|
||||
|
||||
/** @brief Return the true-dof transfer operator.
|
||||
|
||||
The returned pointer is non-owning; the operator is either this object
|
||||
or a cached operator owned by this PRefinementTransferOperator. The
|
||||
pointer remains valid until this PRefinementTransferOperator is
|
||||
destroyed and must not be deleted by the caller. */
|
||||
Operator * GetTrueTransferOperator();
|
||||
const Operator * GetTrueTransferOperator() const
|
||||
{
|
||||
return const_cast<PRefinementTransferOperator*>(this)
|
||||
->GetTrueTransferOperator();
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~PRefinementTransferOperator() { }
|
||||
|
||||
+21
-4
@@ -111,6 +111,25 @@ void Array<T>::PartialSum()
|
||||
}
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
MFEM_HOST_DEVICE inline U abs_signed(U v) { return (v < U(0)) ? -v : v; }
|
||||
|
||||
template <typename U>
|
||||
void AbsImpl(std::true_type /*signed*/, U* y, int N, bool useDevice)
|
||||
{
|
||||
mfem::forall_switch(useDevice, N, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
y[i] = abs_signed(y[i]);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
void AbsImpl(std::false_type /*unsigned*/, U* /*y*/, int /*N*/,
|
||||
bool /*useDevice*/)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Array<T>::Abs()
|
||||
{
|
||||
@@ -118,10 +137,7 @@ void Array<T>::Abs()
|
||||
const bool useDevice = UseDevice();
|
||||
const int N = size;
|
||||
auto y = ReadWrite(useDevice);
|
||||
mfem::forall_switch(useDevice, N, [=] MFEM_HOST_DEVICE (int i)
|
||||
{
|
||||
y[i] = std::abs(y[i]);
|
||||
});
|
||||
AbsImpl<T>(std::is_signed<T> {}, y, N, useDevice);
|
||||
}
|
||||
|
||||
// Sum
|
||||
@@ -207,6 +223,7 @@ void Array2D<T>::Print(std::ostream &os, int width_)
|
||||
template class Array<char>;
|
||||
template class Array<int>;
|
||||
template class Array<long long>;
|
||||
template class Array<unsigned int>;
|
||||
template class Array<real_t>;
|
||||
template class Array2D<int>;
|
||||
template class Array2D<real_t>;
|
||||
|
||||
@@ -37,6 +37,16 @@
|
||||
// removed in a future release).
|
||||
#define CUB_IGNORE_DEPRECATED_CPP_DIALECT
|
||||
#define THRUST_IGNORE_DEPRECATED_CPP_DIALECT
|
||||
|
||||
// MFEM only supports using RAJA/CAMP backends in default stream mode because
|
||||
// memory calls are performed outside of the RAJA ecosystem
|
||||
#ifndef CAMP_USE_PLATFORM_DEFAULT_STREAM
|
||||
#define CAMP_USE_PLATFORM_DEFAULT_STREAM 1
|
||||
#else
|
||||
#if !CAMP_USE_PLATFORM_DEFAULT_STREAM
|
||||
#error "MFEM only supports RAJA/CAMP with the default platform stream."
|
||||
#endif
|
||||
#endif
|
||||
#include "RAJA/RAJA.hpp"
|
||||
#if defined(RAJA_ENABLE_CUDA) && !defined(MFEM_USE_CUDA)
|
||||
#error When RAJA is built with CUDA, MFEM_USE_CUDA=YES is required
|
||||
|
||||
@@ -25,6 +25,13 @@ namespace mfem
|
||||
namespace bin_io
|
||||
{
|
||||
|
||||
/// Enum to specify if values should be read in binary or ASCII format.
|
||||
enum BinaryOrASCII : bool
|
||||
{
|
||||
ASCII = false,
|
||||
BINARY = true
|
||||
};
|
||||
|
||||
/// Write 'value' to stream.
|
||||
template<typename T>
|
||||
inline void write(std::ostream& os, T value)
|
||||
@@ -73,6 +80,38 @@ void DecodeBase64(const char *src, size_t len, std::vector<char> &buf);
|
||||
/// This is equal to 4*nbytes/3, rounded up to the nearest multiple of 4.
|
||||
size_t NumBase64Chars(size_t nbytes);
|
||||
|
||||
/// @brief Read and return a value of type @a T from the input stream, in either
|
||||
/// binary or ASCII format, depending on the value of @a binary.
|
||||
template <typename T>
|
||||
T ReadBinaryOrASCII(std::istream &input, BinaryOrASCII binary)
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
return read<T>(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
T val;
|
||||
input >> val;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Skip @a num values of type @a T from the input stream, in either
|
||||
/// binary or ASCII format, depending on the value of @a binary.
|
||||
template <typename T>
|
||||
void Skip(std::istream &input, int num, BinaryOrASCII binary)
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
input.ignore(sizeof(T) * num);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < num; ++i) { ReadBinaryOrASCII<T>(input, ASCII); }
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mfem::bin_io
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
+168
-12
@@ -46,6 +46,8 @@ struct DofQuadLimits_CUDA
|
||||
{
|
||||
static constexpr int MAX_D1D = 14;
|
||||
static constexpr int MAX_Q1D = 14;
|
||||
static constexpr int MAX_D1D_SIMPLEX = 14;
|
||||
static constexpr int MAX_Q1D_SIMPLEX = 14;
|
||||
static constexpr int MAX_T1D = 32;
|
||||
static constexpr int HCURL_MAX_D1D = 5;
|
||||
static constexpr int HCURL_MAX_Q1D = 6;
|
||||
@@ -59,6 +61,8 @@ struct DofQuadLimits_HIP
|
||||
{
|
||||
static constexpr int MAX_D1D = 10;
|
||||
static constexpr int MAX_Q1D = 10;
|
||||
static constexpr int MAX_D1D_SIMPLEX = 9;
|
||||
static constexpr int MAX_Q1D_SIMPLEX = 9;
|
||||
static constexpr int MAX_T1D = 32;
|
||||
static constexpr int HCURL_MAX_D1D = 5;
|
||||
static constexpr int HCURL_MAX_Q1D = 5;
|
||||
@@ -73,9 +77,13 @@ struct DofQuadLimits_CPU
|
||||
#ifndef _WIN32
|
||||
static constexpr int MAX_D1D = 24;
|
||||
static constexpr int MAX_Q1D = 24;
|
||||
static constexpr int MAX_D1D_SIMPLEX = 24;
|
||||
static constexpr int MAX_Q1D_SIMPLEX = 24;
|
||||
#else
|
||||
static constexpr int MAX_D1D = 14;
|
||||
static constexpr int MAX_Q1D = 14;
|
||||
static constexpr int MAX_D1D_SIMPLEX = 14;
|
||||
static constexpr int MAX_Q1D_SIMPLEX = 14;
|
||||
#endif
|
||||
static constexpr int MAX_T1D = 32;
|
||||
static constexpr int HCURL_MAX_D1D = 10;
|
||||
@@ -117,6 +125,8 @@ struct DeviceDofQuadLimits
|
||||
{
|
||||
int MAX_D1D; ///< Maximum number of 1D nodal points.
|
||||
int MAX_Q1D; ///< Maximum number of 1D quadrature points.
|
||||
int MAX_D1D_SIMPLEX; ///< Maximum number of 1D nodal points for simplices.
|
||||
int MAX_Q1D_SIMPLEX; ///< Maximum number of 1D quadrature points for simplices.
|
||||
int HCURL_MAX_D1D; ///< Maximum number of 1D nodal points for H(curl).
|
||||
int HCURL_MAX_Q1D; ///< Maximum number of 1D quadrature points for H(curl).
|
||||
int HDIV_MAX_D1D; ///< Maximum number of 1D nodal points for H(div).
|
||||
@@ -148,6 +158,8 @@ private:
|
||||
{
|
||||
MAX_D1D = T::MAX_D1D;
|
||||
MAX_Q1D = T::MAX_Q1D;
|
||||
MAX_D1D_SIMPLEX = T::MAX_D1D_SIMPLEX;
|
||||
MAX_Q1D_SIMPLEX = T::MAX_Q1D_SIMPLEX;
|
||||
HCURL_MAX_D1D = T::HCURL_MAX_D1D;
|
||||
HCURL_MAX_Q1D = T::HCURL_MAX_Q1D;
|
||||
HDIV_MAX_D1D = T::HDIV_MAX_D1D;
|
||||
@@ -277,6 +289,9 @@ void OmpWrap3D(const int Nx, const int Ny, const int Nz, HBODY &&h_body)
|
||||
|
||||
/// RAJA Cuda and Hip backends
|
||||
#if defined(MFEM_USE_RAJA) && defined(RAJA_ENABLE_CUDA) && defined(__CUDACC__)
|
||||
template <int LB>
|
||||
using cuda_launch_bounds_policy =
|
||||
RAJA::LaunchPolicy<RAJA::cuda_launch_t<true, LB>>;
|
||||
using cuda_launch_policy =
|
||||
RAJA::LaunchPolicy<RAJA::cuda_launch_t<true>>;
|
||||
using cuda_teams_x =
|
||||
@@ -288,6 +303,9 @@ using cuda_threads_z =
|
||||
#if defined(MFEM_USE_RAJA) && defined(RAJA_ENABLE_HIP) && defined(__HIP__)
|
||||
using hip_launch_policy =
|
||||
RAJA::LaunchPolicy<RAJA::hip_launch_t<true>>;
|
||||
template <int LB>
|
||||
using hip_launch_bounds_policy =
|
||||
RAJA::LaunchPolicy<RAJA::hip_launch_t<true, LB>>;
|
||||
using hip_teams_x =
|
||||
RAJA::LoopPolicy<RAJA::hip_block_x_direct>;
|
||||
using hip_threads_z =
|
||||
@@ -337,6 +355,33 @@ void RajaCuWrap2D(const int N, DBODY &&d_body,
|
||||
MFEM_GPU_CHECK(cudaGetLastError());
|
||||
}
|
||||
|
||||
template <int LB, typename DBODY>
|
||||
void RajaCuWrap2DLaunchBounds(const int N, DBODY &&d_body, const int X,
|
||||
const int Y, const int BZ)
|
||||
{
|
||||
MFEM_VERIFY(BZ>0, "");
|
||||
const int G = (N+BZ-1)/BZ;
|
||||
|
||||
using namespace RAJA;
|
||||
using RAJA::RangeSegment;
|
||||
|
||||
launch<cuda_launch_bounds_policy<LB> >
|
||||
(LaunchParams(Teams(G), Threads(X, Y, BZ)),
|
||||
[=] RAJA_DEVICE(LaunchContext ctx)
|
||||
{
|
||||
loop<cuda_teams_x>(ctx, RangeSegment(0, G), [&] (const int n)
|
||||
{
|
||||
loop<cuda_threads_z>(ctx, RangeSegment(0, BZ), [&] (const int tz)
|
||||
{
|
||||
const int k = n*BZ + tz;
|
||||
if (k >= N) { return; }
|
||||
d_body(k);
|
||||
});
|
||||
});
|
||||
});
|
||||
MFEM_GPU_CHECK(cudaGetLastError());
|
||||
}
|
||||
|
||||
template <typename DBODY>
|
||||
void RajaCuWrap3D(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
@@ -357,11 +402,28 @@ void RajaCuWrap3D(const int N, DBODY &&d_body,
|
||||
MFEM_GPU_CHECK(cudaGetLastError());
|
||||
}
|
||||
|
||||
template <int Dim>
|
||||
template <int LB, typename DBODY>
|
||||
void RajaCuWrap3DLaunchBounds(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
{
|
||||
const int GRID = G == 0 ? N : G;
|
||||
using namespace RAJA;
|
||||
using RAJA::RangeSegment;
|
||||
|
||||
launch<cuda_launch_bounds_policy<LB> >
|
||||
(LaunchParams(Teams(GRID), Threads(X, Y, Z)),
|
||||
[=] RAJA_DEVICE(LaunchContext ctx)
|
||||
{
|
||||
loop<cuda_teams_x>(ctx, RangeSegment(0, N), d_body);
|
||||
});
|
||||
MFEM_GPU_CHECK(cudaGetLastError());
|
||||
}
|
||||
|
||||
template <int Dim, int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaCuWrap;
|
||||
|
||||
template <>
|
||||
struct RajaCuWrap<1>
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaCuWrap<1, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -372,7 +434,7 @@ struct RajaCuWrap<1>
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RajaCuWrap<2>
|
||||
struct RajaCuWrap<2, 0>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -382,8 +444,19 @@ struct RajaCuWrap<2>
|
||||
}
|
||||
};
|
||||
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaCuWrap<2, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
{
|
||||
RajaCuWrap2DLaunchBounds<MAX_THREADS_PER_BLOCK>(N, d_body, X, Y, Z);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RajaCuWrap<3>
|
||||
struct RajaCuWrap<3, 0>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -393,6 +466,17 @@ struct RajaCuWrap<3>
|
||||
}
|
||||
};
|
||||
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaCuWrap<3, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
{
|
||||
RajaCuWrap3DLaunchBounds<MAX_THREADS_PER_BLOCK>(N, d_body, X, Y, Z, G);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(MFEM_USE_RAJA) && defined(RAJA_ENABLE_HIP) && defined(__HIP__)
|
||||
@@ -438,6 +522,33 @@ void RajaHipWrap2D(const int N, DBODY &&d_body,
|
||||
MFEM_GPU_CHECK(hipGetLastError());
|
||||
}
|
||||
|
||||
template <int LB, typename DBODY>
|
||||
void RajaHipWrap2DLaunchBounds(const int N, DBODY &&d_body, const int X,
|
||||
const int Y, const int BZ)
|
||||
{
|
||||
MFEM_VERIFY(BZ>0, "");
|
||||
const int G = (N+BZ-1)/BZ;
|
||||
|
||||
using namespace RAJA;
|
||||
using RAJA::RangeSegment;
|
||||
|
||||
launch<hip_launch_bounds_policy<LB> >
|
||||
(LaunchParams(Teams(G), Threads(X, Y, BZ)),
|
||||
[=] RAJA_DEVICE(LaunchContext ctx)
|
||||
{
|
||||
loop<hip_teams_x>(ctx, RangeSegment(0, G), [&] (const int n)
|
||||
{
|
||||
loop<hip_threads_z>(ctx, RangeSegment(0, BZ), [&] (const int tz)
|
||||
{
|
||||
const int k = n*BZ + tz;
|
||||
if (k >= N) { return; }
|
||||
d_body(k);
|
||||
});
|
||||
});
|
||||
});
|
||||
MFEM_GPU_CHECK(hipGetLastError());
|
||||
}
|
||||
|
||||
template <typename DBODY>
|
||||
void RajaHipWrap3D(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
@@ -458,11 +569,28 @@ void RajaHipWrap3D(const int N, DBODY &&d_body,
|
||||
MFEM_GPU_CHECK(hipGetLastError());
|
||||
}
|
||||
|
||||
template <int Dim>
|
||||
template <int LB, typename DBODY>
|
||||
void RajaHipWrap3DLaunchBounds(const int N, DBODY &&d_body, const int X,
|
||||
const int Y, const int Z, const int G)
|
||||
{
|
||||
const int GRID = G == 0 ? N : G;
|
||||
using namespace RAJA;
|
||||
using RAJA::RangeSegment;
|
||||
|
||||
launch<hip_launch_bounds_policy<LB> >
|
||||
(LaunchParams(Teams(GRID), Threads(X, Y, Z)),
|
||||
[=] RAJA_DEVICE(LaunchContext ctx)
|
||||
{
|
||||
loop<hip_teams_x>(ctx, RangeSegment(0, N), d_body);
|
||||
});
|
||||
MFEM_GPU_CHECK(hipGetLastError());
|
||||
}
|
||||
|
||||
template <int Dim, int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaHipWrap;
|
||||
|
||||
template <>
|
||||
struct RajaHipWrap<1>
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaHipWrap<1, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -473,7 +601,7 @@ struct RajaHipWrap<1>
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RajaHipWrap<2>
|
||||
struct RajaHipWrap<2, 0>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -483,8 +611,19 @@ struct RajaHipWrap<2>
|
||||
}
|
||||
};
|
||||
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaHipWrap<2, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
{
|
||||
RajaHipWrap2DLaunchBounds<MAX_THREADS_PER_BLOCK>(N, d_body, X, Y, Z);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RajaHipWrap<3>
|
||||
struct RajaHipWrap<3, 0>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
@@ -494,6 +633,17 @@ struct RajaHipWrap<3>
|
||||
}
|
||||
};
|
||||
|
||||
template <int MAX_THREADS_PER_BLOCK>
|
||||
struct RajaHipWrap<3, MAX_THREADS_PER_BLOCK>
|
||||
{
|
||||
template <typename DBODY>
|
||||
static void run(const int N, DBODY &&d_body,
|
||||
const int X, const int Y, const int Z, const int G)
|
||||
{
|
||||
RajaHipWrap3DLaunchBounds<MAX_THREADS_PER_BLOCK>(N, d_body, X, Y, Z, G);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// RAJA OpenMP backend
|
||||
@@ -913,7 +1063,7 @@ inline void ForallWrap(const bool use_dev, const int N,
|
||||
// If Backend::RAJA_CUDA is allowed, use it
|
||||
if (Device::Allows(Backend::RAJA_CUDA))
|
||||
{
|
||||
return RajaCuWrap<DIM>::run(N, d_body, X, Y, Z, G);
|
||||
return RajaCuWrap<DIM, MAX_THREADS_PER_BLOCK>::run(N, d_body, X, Y, Z, G);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -921,7 +1071,7 @@ inline void ForallWrap(const bool use_dev, const int N,
|
||||
// If Backend::RAJA_HIP is allowed, use it
|
||||
if (Device::Allows(Backend::RAJA_HIP))
|
||||
{
|
||||
return RajaHipWrap<DIM>::run(N, d_body, X, Y, Z, G);
|
||||
return RajaHipWrap<DIM, MAX_THREADS_PER_BLOCK>::run(N, d_body, X, Y, Z, G);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1090,6 +1240,12 @@ inline void forall_2D_batch(int N, int X, int Y, int BZ, lambda &&body)
|
||||
ForallWrap<2>(true, N, body, X, Y, BZ);
|
||||
}
|
||||
|
||||
template<int MAX_THREADS_PER_BLOCK, typename lambda>
|
||||
inline void forall_2D_batch(int N, int X, int Y, int BZ, lambda &&body)
|
||||
{
|
||||
ForallWrap<2, MAX_THREADS_PER_BLOCK>(true, N, body, X, Y, BZ);
|
||||
}
|
||||
|
||||
template<typename lambda>
|
||||
inline void forall_3D(int N, int X, int Y, int Z, lambda &&body)
|
||||
{
|
||||
|
||||
@@ -148,6 +148,12 @@ if (MFEM_USE_MKL_PARDISO)
|
||||
list(APPEND HDRS pardiso.hpp)
|
||||
endif()
|
||||
|
||||
# cudss solver
|
||||
if (MFEM_USE_CUDSS)
|
||||
list(APPEND SRCS cudss.cpp)
|
||||
list(APPEND HDRS cudss.hpp)
|
||||
endif()
|
||||
|
||||
convert_filenames_to_full_paths(SRCS)
|
||||
convert_filenames_to_full_paths(HDRS)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "blockvector.hpp"
|
||||
#include "blockoperator.hpp"
|
||||
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
@@ -129,6 +130,33 @@ void BlockOperator::MultTranspose(const Vector &x, Vector &y) const
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
HypreParMatrix * BlockOperator::GetMonolithicHypreParMatrix() const
|
||||
{
|
||||
Array2D<const HypreParMatrix*> blocks(nRowBlocks, nColBlocks);
|
||||
for (int i = 0; i < nRowBlocks; ++i)
|
||||
{
|
||||
for (int j = 0; j < nColBlocks; ++j)
|
||||
{
|
||||
if (IsZeroBlock(i, j))
|
||||
{
|
||||
blocks(i, j) = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto mat = dynamic_cast<const HypreParMatrix*>(&GetBlock(i, j));
|
||||
MFEM_VERIFY(mat,"BlockOperator block (" << i << "," << j
|
||||
<< ") is not a HypreParMatrix.");
|
||||
blocks(i, j) = mat;
|
||||
}
|
||||
}
|
||||
}
|
||||
Array2D<real_t> coef_mut = coef; // make a non-const copy
|
||||
return HypreParMatrixFromBlocks(blocks, &coef_mut);
|
||||
}
|
||||
#endif
|
||||
|
||||
BlockOperator::~BlockOperator()
|
||||
{
|
||||
if (owns_blocks)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user