Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8501138bc | ||
|
|
c679c99b35 | ||
|
|
3f9a3658a6 | ||
|
|
6e149b75e5 | ||
|
|
90d6afb814 | ||
|
|
8f25a46d5c | ||
|
|
1682ade22e | ||
|
|
be9fc95d6f | ||
|
|
5dd706208a | ||
|
|
7735de95d2 | ||
|
|
2f023c6e53 | ||
|
|
4cf47eca13 | ||
|
|
883a5843cd | ||
|
|
ef5dbd0bf6 | ||
|
|
b02eaf34a1 | ||
|
|
f26765afa1 | ||
|
|
f81a681203 | ||
|
|
5705de1507 | ||
|
|
1958f8de19 | ||
|
|
aacc159390 | ||
|
|
3b26d08793 | ||
|
|
13892eed2b | ||
|
|
50907081fd | ||
|
|
9409b7ab3b | ||
|
|
86747dd076 | ||
|
|
9d6a7fe30b | ||
|
|
e717f619e7 | ||
|
|
2f2534be10 | ||
|
|
3b8c4323fb | ||
|
|
e786ad65eb | ||
|
|
c528f79c9f | ||
|
|
cb0e7a5068 | ||
|
|
9d8043b9e7 | ||
|
|
6f493e7bbe | ||
|
|
2ae031628b | ||
|
|
12b49070f1 | ||
|
|
ee7ff65076 | ||
|
|
e649539e1e | ||
|
|
9fc3eca376 | ||
|
|
53566a529f | ||
|
|
cbd8f1f478 | ||
|
|
378b658fbe | ||
|
|
dc3e6d533a | ||
|
|
0faaba06a9 | ||
|
|
0a07332084 | ||
|
|
4851228aeb | ||
|
|
56ea2a63cd | ||
|
|
97cee99618 | ||
|
|
00e2f309a2 | ||
|
|
c03d3d3b01 | ||
|
|
b50db02828 | ||
|
|
f783cec935 | ||
|
|
8c6feba024 | ||
|
|
2804c9594e | ||
|
|
0eca8d9517 | ||
|
|
cdacbca3d4 | ||
|
|
0e6935e5e7 | ||
|
|
483cb581b9 | ||
|
|
39d0bb2cf3 | ||
|
|
e85f93cb78 | ||
|
|
be1ea0d208 | ||
|
|
f778fcaccb | ||
|
|
dc1f69589b | ||
|
|
7e18e0daab | ||
|
|
d481c5d5a6 | ||
|
|
2a501266ba | ||
|
|
c91e0a7378 | ||
|
|
ecacadacf2 | ||
|
|
98a6ae7baa | ||
|
|
8f28244cab | ||
|
|
8dd6b3d2b7 | ||
|
|
ee5efb4e36 | ||
|
|
26e67ee06c | ||
|
|
050471c674 | ||
|
|
1fc23a24bd | ||
|
|
de662f5042 | ||
|
|
44ecca4b8a | ||
|
|
c754730ed4 | ||
|
|
f05ef4e164 | ||
|
|
f39cf60559 | ||
|
|
61c38c4afc | ||
|
|
de0d1f454b | ||
|
|
ff3d70a70c | ||
|
|
7b26fe1dc8 | ||
|
|
81b7c820bf | ||
|
|
2b9f9343a5 | ||
|
|
649a1438bb | ||
|
|
fee3e0f5d0 | ||
|
|
defc916e45 | ||
|
|
810ecc6a9f | ||
|
|
d664901731 | ||
|
|
fd32871f36 | ||
|
|
2237e0f089 | ||
|
|
a7cba43e12 | ||
|
|
a310feeea0 | ||
|
|
7d64b1315f | ||
|
|
9e077ffe59 | ||
|
|
3f40c5796f | ||
|
|
2667d3935d | ||
|
|
80d2a5692b | ||
|
|
3ce96b71c0 | ||
|
|
9148a1d942 | ||
|
|
7859c93931 | ||
|
|
55573cbe4e | ||
|
|
ae1445e9ca | ||
|
|
0c68ab8e06 | ||
|
|
18ce336b68 | ||
|
|
335e6c2469 | ||
|
|
22f385cff3 | ||
|
|
4a40cec3b1 | ||
|
|
c72784cc61 | ||
|
|
ea77ae541c | ||
|
|
85a79aabaa | ||
|
|
e654f4c607 | ||
|
|
6e0595c055 | ||
|
|
6abe607689 | ||
|
|
b4dcec859b | ||
|
|
e83b35d460 | ||
|
|
cf4573a985 | ||
|
|
18695e6d2a | ||
|
|
802ca3d01f | ||
|
|
08941bcbe3 | ||
|
|
cc9fda7d8f | ||
|
|
c7b36fb0f2 | ||
|
|
ec845d006c | ||
|
|
ea8be0b691 | ||
|
|
0e4dff7f58 | ||
|
|
6d83ac94c9 | ||
|
|
3297173552 | ||
|
|
85a41e61a3 | ||
|
|
82461f6443 | ||
|
|
15465cf610 | ||
|
|
ccb0feb4a4 | ||
|
|
b877eee42a | ||
|
|
b2b8407f50 | ||
|
|
d19734afbd | ||
|
|
7756b62a35 | ||
|
|
58a304ebda | ||
|
|
a3d9280b26 | ||
|
|
e74104e4de | ||
|
|
b7ee8ff1f8 | ||
|
|
dc4f153261 | ||
|
|
b356865de2 | ||
|
|
57807f5c00 | ||
|
|
64aba43d18 | ||
|
|
07a54a2c88 | ||
|
|
935dd857c4 | ||
|
|
474cb731d3 | ||
|
|
0d4d554cae | ||
|
|
af395dae9e | ||
|
|
26c2dd70f9 | ||
|
|
81366c926c | ||
|
|
d4a6ac6507 | ||
|
|
df85b42772 | ||
|
|
166411b8d1 | ||
|
|
09f7a26108 | ||
|
|
b623a913b8 | ||
|
|
7e92c0cf1b | ||
|
|
6e7f6cd573 | ||
|
|
a9d4da4a9e | ||
|
|
bbf9842cda | ||
|
|
1c6fb69607 | ||
|
|
eb0dae7eb3 | ||
|
|
136d166e88 | ||
|
|
1043180bc9 | ||
|
|
e0a65be94b | ||
|
|
602c2c84e7 | ||
|
|
12c272df5f | ||
|
|
25140c79dd | ||
|
|
72fcd82618 | ||
|
|
ad24e6f68e | ||
|
|
e5eaa22359 | ||
|
|
989d08c923 | ||
|
|
1203240e3f | ||
|
|
c6488455d6 | ||
|
|
41d4fd9cfb | ||
|
|
f73314c3fb | ||
|
|
b460af2b69 | ||
|
|
3da49cf3fc | ||
|
|
46e55a3c18 | ||
|
|
8cbbd20007 | ||
|
|
135964b3ba | ||
|
|
928bdddbb1 | ||
|
|
c798b87922 | ||
|
|
ac9e93485c | ||
|
|
7809f1b5a1 | ||
|
|
e08a9971fb | ||
|
|
6ab84c49ea | ||
|
|
0e6e19c2cf | ||
|
|
20afb83c41 | ||
|
|
418a787006 | ||
|
|
fe60d34610 | ||
|
|
1c4f0fac5e | ||
|
|
6bad77ca14 | ||
|
|
93f266a664 | ||
|
|
80c175c8a0 | ||
|
|
7cc2119269 | ||
|
|
7c8d0946a6 | ||
|
|
e74e3cc584 | ||
|
|
4622753efb | ||
|
|
2595f8944d | ||
|
|
b1461d87bd | ||
|
|
4d32c82fed | ||
|
|
b7ab371c80 | ||
|
|
446e5b60b1 | ||
|
|
c5c1637e22 | ||
|
|
9296211b1d | ||
|
|
10d67636a2 | ||
|
|
921df7f15c | ||
|
|
0594d4e35d | ||
|
|
1d6e5c1612 | ||
|
|
d12318ae0b | ||
|
|
616519083d | ||
|
|
a0beaf7852 | ||
|
|
3f007851ee | ||
|
|
74ea4dd642 | ||
|
|
9c829ad1c8 | ||
|
|
5712978fa1 | ||
|
|
a7d2cc8773 | ||
|
|
e97f9051ce | ||
|
|
7327553765 | ||
|
|
0d43ed7019 | ||
|
|
ac86c3829e | ||
|
|
41bb2bdb94 | ||
|
|
bb5d5be92c | ||
|
|
c7f8bc3866 | ||
|
|
7664837d1a | ||
|
|
4b22256c8e | ||
|
|
8ca6247b3e | ||
|
|
db3350fd07 | ||
|
|
417d1bbb0e | ||
|
|
393c0fe56a | ||
|
|
9c60c6ee11 | ||
|
|
5f0dc64cf6 | ||
|
|
9b02c27243 | ||
|
|
ab9f9dd580 | ||
|
|
78a215d167 | ||
|
|
cff8ab4b1e | ||
|
|
b1ec2936e1 | ||
|
|
99a03d1778 | ||
|
|
41668f5111 | ||
|
|
be74ba7553 | ||
|
|
d6cef6f3c5 | ||
|
|
46356181a1 | ||
|
|
80f7bab173 | ||
|
|
e34e551f5e | ||
|
|
b7b057e337 | ||
|
|
eff701b676 | ||
|
|
0fe20e640b | ||
|
|
549e25393c | ||
|
|
11dd7794f7 | ||
|
|
ce484c0133 | ||
|
|
ba9d41ae04 | ||
|
|
1bc624479b | ||
|
|
e04ad1f564 | ||
|
|
4a0fd1525e | ||
|
|
72b58b0ad7 | ||
|
|
d36cf7858f | ||
|
|
f162e36168 | ||
|
|
34c3de05cd | ||
|
|
9afefcdf52 | ||
|
|
d4b7c3ca11 | ||
|
|
e974f12ddb | ||
|
|
b836e0ca6b | ||
|
|
6543546dc0 | ||
|
|
addb6529ce | ||
|
|
d57eeb99b0 | ||
|
|
6a12b440bf | ||
|
|
7b2633066f | ||
|
|
3115e2cfa1 | ||
|
|
01a0e88422 | ||
|
|
a588dd33e8 | ||
|
|
38ada18a0e | ||
|
|
4e49041d72 | ||
|
|
a3235c4029 | ||
|
|
95b1bf73f9 | ||
|
|
2d5818daa0 | ||
|
|
ea2f3933da | ||
|
|
7ac7fcf8b5 | ||
|
|
c13cd26c00 | ||
|
|
ec938eb680 | ||
|
|
5e76ebfe31 | ||
|
|
55f5eadd7a | ||
|
|
c82ce807d0 | ||
|
|
8e059432ab | ||
|
|
898964a6b7 | ||
|
|
823424efa5 | ||
|
|
8b9ea3e926 | ||
|
|
10ad5519b5 | ||
|
|
931e6f3d81 | ||
|
|
3c2c874047 | ||
|
|
f9ee8f555e | ||
|
|
2cd83469be | ||
|
|
1c1a45b1f9 | ||
|
|
9a99eeded5 | ||
|
|
345ca6f214 | ||
|
|
8a76a96dd7 | ||
|
|
6665a69afb | ||
|
|
30ea12a346 | ||
|
|
7775461309 | ||
|
|
1cd2536423 | ||
|
|
d2763f0d56 | ||
|
|
359cae98e5 | ||
|
|
05e6ad9369 | ||
|
|
a3c1a26fd7 | ||
|
|
19e124f23e | ||
|
|
5e758741b0 | ||
|
|
5c59c03954 | ||
|
|
6d5b2e6c3c | ||
|
|
98f539201a | ||
|
|
06179179e1 | ||
|
|
dc11b5bfc6 | ||
|
|
8058c215c0 | ||
|
|
ff6cf57da9 | ||
|
|
bbc2d3e33c | ||
|
|
fd7c4f9510 | ||
|
|
6517b6066c | ||
|
|
d189391502 | ||
|
|
417704d567 | ||
|
|
1ceb4c83ca | ||
|
|
6a262b4b08 | ||
|
|
6119c28d3c | ||
|
|
62891ad220 | ||
|
|
23d3d45547 | ||
|
|
1065023a8b | ||
|
|
3a497d4698 | ||
|
|
46c7045d79 | ||
|
|
4b9a1920b3 | ||
|
|
96a94f3987 | ||
|
|
e4b7044f95 | ||
|
|
720e894b0f | ||
|
|
5f87783f6b | ||
|
|
999aff80c9 | ||
|
|
6872ad10b2 | ||
|
|
6708ff1b73 | ||
|
|
fa018b60f8 | ||
|
|
84ec1055cf | ||
|
|
716fa4007a | ||
|
|
15e5c24edf | ||
|
|
72168baf12 | ||
|
|
200ce9429e | ||
|
|
9c023e977b | ||
|
|
6084d3ea7a | ||
|
|
8827ee12b6 | ||
|
|
49b89dd899 | ||
|
|
953534e08e | ||
|
|
473c300284 | ||
|
|
7a8cff948b | ||
|
|
f9cc175911 | ||
|
|
a7f602fb8f | ||
|
|
6c59e99ea6 | ||
|
|
8f4901c841 | ||
|
|
becf642a99 | ||
|
|
0a3c5a81e9 | ||
|
|
509a94ad33 | ||
|
|
b381b41c65 | ||
|
|
2d25fda0fa | ||
|
|
eb2fa948b5 | ||
|
|
376424035e | ||
|
|
5bd2da8d65 | ||
|
|
b9fc33f98c | ||
|
|
0a1c1fe415 | ||
|
|
c5a6f654db | ||
|
|
dd6f7dcad6 | ||
|
|
fd5742e3f0 | ||
|
|
a1ba70e6a8 | ||
|
|
4da7b73965 | ||
|
|
01bf7d6e9e | ||
|
|
0c06ad86fd |
@@ -252,6 +252,7 @@ miniapps/shifted/ParaViewDistance
|
||||
miniapps/shifted/diffusion
|
||||
miniapps/shifted/diffusion.mesh
|
||||
miniapps/shifted/diffusion.gf
|
||||
miniapps/shifted/ParaViewDiffusion
|
||||
|
||||
miniapps/tools/display-basis
|
||||
miniapps/tools/load-dc
|
||||
@@ -296,6 +297,7 @@ tests/unit/psedov_tests_*
|
||||
tests/unit/tmop_pa_tests_*
|
||||
tests/unit/ptmop_pa_tests_*
|
||||
tests/unit/ceed_tests
|
||||
tests/unit/debug_device_tests
|
||||
|
||||
# Test script output
|
||||
tests/scripts/*.err
|
||||
|
||||
+8
-8
@@ -51,9 +51,9 @@ variables:
|
||||
MFEM_DATA_REPO: https://github.com/mfem/data.git
|
||||
ARTIFACTS_DIR: artifacts
|
||||
|
||||
# The pipeline is divided into stages. Usually, these are also synchronization
|
||||
# points, however, we use "needs" keyword to express the DAG of jobs for more
|
||||
# efficiency.
|
||||
# The pipeline is divided into stages. Usually, jobs in a given stage wait for
|
||||
# the preceding stages to complete before to start. However, we sometimes use
|
||||
# the "needs" keyword and express the DAG of jobs for more efficiency.
|
||||
# - We use setup and setup_baseline phases to download content outside of mfem
|
||||
# directory.
|
||||
# - Allocate/Release is where quartz resources are allocated/released once for all.
|
||||
@@ -87,7 +87,6 @@ setup:
|
||||
script:
|
||||
- mkdir -p ${BUILD_ROOT} && cd ${BUILD_ROOT}
|
||||
- if [ ! -d data ]; then git clone ${MFEM_DATA_REPO}; fi
|
||||
needs: []
|
||||
|
||||
# The setup_baseline job in setup stage_baseline doesn't rely on MFEM git repo.
|
||||
# It prepares a pipeline-wide working directory downloading/updating external
|
||||
@@ -95,6 +94,7 @@ setup:
|
||||
# are now using unique directories so repo are never shared with another
|
||||
# pipeline. This is not memory efficient (we keep a lot of data), hence this
|
||||
# reminder.
|
||||
# Note: This job can start immediately.
|
||||
setup_baseline:
|
||||
tags:
|
||||
- shell
|
||||
@@ -125,10 +125,10 @@ setup_baseline:
|
||||
script:
|
||||
- srun -p mi60 -t 15 -N 1 tests/gitlab/build_and_test
|
||||
|
||||
# Lassen uses a different job scheduler (spectrum lsf) that does not
|
||||
# allow pre-allocation the same way slurm does.
|
||||
# We use pdebug queue on lassen to speed-up the allocation.
|
||||
# However this would not be scalable to multiple builds.
|
||||
# Lassen uses a different job scheduler (spectrum lsf) that does not allow
|
||||
# pre-allocation the same way slurm does. We use pdebug queue on lassen to
|
||||
# speed-up the allocation. However this would not be scalable to multiple
|
||||
# builds.
|
||||
.build_blueos_3_ppc64le_ib_script:
|
||||
script:
|
||||
- lalloc 1 -W 30 -q pdebug tests/gitlab/build_and_test
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@
|
||||
|
||||
# Spack helped builds
|
||||
# Generic lassen build job, extending build script
|
||||
# Note: Lassen jobs can start as soon as the setup job is complete.
|
||||
.build_and_test_on_lassen:
|
||||
extends: [.build_blueos_3_ppc64le_ib_script, .on_lassen]
|
||||
stage: l_build_and_test
|
||||
@@ -29,5 +30,5 @@
|
||||
|
||||
opt_mpi_cuda_xl_16_1_1_8:
|
||||
variables:
|
||||
SPEC: "%xl@16.1.1.8 +mpi +cuda cuda_arch=sm_70"
|
||||
SPEC: "%xl@16.1.1.8 +mpi +cuda cuda_arch=70"
|
||||
extends: .build_and_test_on_lassen
|
||||
|
||||
+29
-11
@@ -16,13 +16,13 @@
|
||||
- shell
|
||||
- quartz
|
||||
rules:
|
||||
# Don’t run quartz jobs if...
|
||||
# Don't run quartz jobs if...
|
||||
- if: '$CI_COMMIT_BRANCH =~ /_qnone/ || $ON_QUARTZ == "OFF"'
|
||||
when: never
|
||||
# Don’t run autotest update if...
|
||||
# Don't run autotest update if...
|
||||
- if: '$CI_JOB_NAME =~ /update_autotest/ && $AUTOTEST != "YES"'
|
||||
when: never
|
||||
# Don’t run autotest update if...
|
||||
# Don't run autotest update if...
|
||||
- if: '$CI_JOB_NAME =~ /q_report/ && $AUTOTEST != "YES"'
|
||||
when: never
|
||||
# Report success on success status
|
||||
@@ -37,6 +37,18 @@
|
||||
# Default is to run if previous stage succeeded
|
||||
- when: on_success
|
||||
|
||||
# This is a yaml anchor, it can be used to avoid duplication like here.
|
||||
# The code below will simply be pasted wherever the anchor is placed.
|
||||
.safe_create_rundir: &safe_create_rundir |
|
||||
if ! mkdir ${rundir}; then
|
||||
n=1
|
||||
while ! mkdir ${rundir}_${n}
|
||||
do
|
||||
n=$((n+1))
|
||||
done
|
||||
rundir=${rundir}_${n}
|
||||
fi
|
||||
|
||||
# Allocate
|
||||
q_allocate_resources:
|
||||
variables:
|
||||
@@ -65,10 +77,11 @@ q_report_success:
|
||||
stage: q_release_resources
|
||||
script:
|
||||
- echo "Can only run if all the quartz jobs passed"
|
||||
- rundir="gitlab/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- cd ${AUTOTEST_ROOT}/autotest && git pull
|
||||
- mkdir -p ${rundir}
|
||||
- rundir="gitlab/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- *safe_create_rundir
|
||||
- echo "The Quartz jobs were successful" > ${rundir}/gitlab.out
|
||||
- echo "See the pipeline here -> $CI_PIPELINE_URL" >> ${rundir}/gitlab.err
|
||||
- git add ${rundir}
|
||||
- git commit -am "Gitlab CI log for baseline on quartz with intel ($(date +%Y-%m-%d))"
|
||||
- git push origin master
|
||||
@@ -80,10 +93,11 @@ q_report_failure:
|
||||
stage: q_release_resources
|
||||
script:
|
||||
- echo "Runs if there was at least one failure on quartz"
|
||||
- rundir="gitlab/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- cd ${AUTOTEST_ROOT}/autotest && git pull
|
||||
- mkdir -p ${rundir}
|
||||
- rundir="gitlab/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- *safe_create_rundir
|
||||
- echo "There was an error while running CI on Quartz" > ${rundir}/gitlab.err
|
||||
- echo "See the pipeline here -> $CI_PIPELINE_URL" >> ${rundir}/gitlab.err
|
||||
- cp ${rundir}/gitlab.err ${rundir}/autotest-email.html
|
||||
- git add ${rundir}
|
||||
- git commit -am "Gitlab CI log for baseline on quartz with intel ($(date +%Y-%m-%d))"
|
||||
@@ -94,7 +108,6 @@ q_report_failure:
|
||||
.build_and_test_on_quartz:
|
||||
extends: [.build_toss_3_x86_64_ib_script, .on_quartz]
|
||||
stage: q_build_and_test
|
||||
needs: [setup]
|
||||
|
||||
# Build MFEM
|
||||
debug_ser_gcc_4_9_3:
|
||||
@@ -137,7 +150,11 @@ opt_par_gcc_6_1_0_pumi:
|
||||
SPEC: "%gcc@6.1.0 +pumi"
|
||||
extends: .build_and_test_on_quartz
|
||||
|
||||
# Baseline
|
||||
# Baseline jobs form an independent set of jobs. We use `needs:[]` to specify
|
||||
# that "setup-baseline" can start immediately. Then, we have to use needs for
|
||||
# each one of the baseline jobs, otherwise they will wait for the rest of the
|
||||
# pipeline.
|
||||
|
||||
baselinecheck_mfem_intel_quartz:
|
||||
extends: [.baselinecheck_mfem, .on_quartz]
|
||||
needs: [setup_baseline]
|
||||
@@ -147,14 +164,15 @@ update_autotest:
|
||||
needs: [baselinecheck_mfem_intel_quartz]
|
||||
stage: baseline_to_autotest
|
||||
script:
|
||||
- rundir="quartz/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- cd ${AUTOTEST_ROOT}/autotest && git pull
|
||||
- mkdir -p ${rundir}
|
||||
- rundir="quartz/$(date +%Y-%m-%d)-github-${CI_COMMIT_REF_SLUG}"
|
||||
- *safe_create_rundir
|
||||
- cp ${CI_PROJECT_DIR}/${ARTIFACTS_DIR}/* ${rundir}
|
||||
# We create an autotest-email.html file, because that's how we signal that there was a diff (temporary).
|
||||
- |
|
||||
if [[ -f ${rundir}/*.err ]]
|
||||
then
|
||||
echo "See the pipeline here -> $CI_PIPELINE_URL" >> ${rundir}/*.err
|
||||
cp ${rundir}/*.err ${rundir}/autotest-email.html
|
||||
fi
|
||||
- git add ${rundir}
|
||||
|
||||
@@ -8,40 +8,72 @@
|
||||
https://mfem.org
|
||||
|
||||
|
||||
Version 4.2.1 (development)
|
||||
Version 4.3.1 (development)
|
||||
===========================
|
||||
- Added initial support for GPU-accelerated versions of PETSc that works with
|
||||
MFEM_USE_CUDA if PETSc has been configured with CUDA support. Examples 1 and 9
|
||||
in the examples/petsc directory have been modified to work with --device cuda.
|
||||
Examples with GAMG (ex1p) and SLEPc (ex11p) are also provided.
|
||||
- Added support for hr-adaptivity using TMOP-based error estimator.
|
||||
|
||||
- Memory management:
|
||||
* Added method Device::SetMemoryTypes that can be used to change the default
|
||||
host and device MemoryTypes before Device setup.
|
||||
* In class MemoryManager, added methods GetDualMemoryType and
|
||||
SetDualMemoryType; dual MemoryTypes are used to determine the second
|
||||
MemoryType (host or device) when only one MemoryType is specified in methods
|
||||
of class Memory.
|
||||
* Added Memory constructor for setting both the host and device MemoryTypes.
|
||||
* Switched the default behavior of device memory allocations so that they
|
||||
are deferred until the device pointer is needed.
|
||||
* Added a second Umpire device MemoryType, DEVICE_UMPIRE_2, with
|
||||
corresponding allocator that can be set with the method
|
||||
MemoryManager::SetUmpireDevice2AllocatorName.
|
||||
* Added HOST_PINNED MemoryType and a pinned host allocator for CUDA and HIP.
|
||||
|
||||
- Added support for Caliper: a library to integrate performance profiling
|
||||
capabilities into applications. See examples/caliper for more details.
|
||||
Version 4.3, released on July 29, 2021
|
||||
======================================
|
||||
|
||||
- Added support for explicit vectorization in the high-performance templated
|
||||
code for Fujitsu's A64FX ARM microprocessor architecture.
|
||||
Discretization improvements
|
||||
---------------------------
|
||||
- Variable order spaces, p- and hp-refinement. This is the initial (serial)
|
||||
support for variable-order FiniteElementCollection and FiniteElementSpace.
|
||||
The new method FiniteElementSpace::SetElementOrder can be called to set an
|
||||
arbitrary order for each mesh element. The conforming interpolation matrix
|
||||
will now automatically constrain p- and hp- interfaces, enabling general
|
||||
hp-refinement in both 2D and 3D, on uniform or mixed NC meshes. Support for
|
||||
parallel variable-order spaces will follow shortly.
|
||||
|
||||
- Added AlgebraicCeedSolver that does matrix-free algebraic p-multigrid for
|
||||
diffusion problems with the Ceed backend.
|
||||
- Extended the support for field transfer between high-order and low-order
|
||||
refined finite element spaces to include: dual fields and H1 fields (both
|
||||
primary and dual). These are illustrated in the lor-transfer miniapp.
|
||||
|
||||
- Introduced new options for the mesh-explorer miniapp to visualize the actual
|
||||
element attributes in parallel meshes while retaining the visualization of
|
||||
the domain decomposition.
|
||||
- Improved libCEED integration, including support for VectorCoefficient,
|
||||
ConvectionIntegrator, and VectorConvectionNLFIntegrator with libCEED backends.
|
||||
|
||||
- Extending support for L2 basis functions using MapTypes VALUE and INTEGRAL in
|
||||
linear interpolators and GridFunction "GetValue" methods.
|
||||
|
||||
- Changed the interface for the error estimator and implemented the Kelly error
|
||||
indicator for scalar-valued problems, supported in serial and parallel builds.
|
||||
|
||||
- Added support for the "BR2" discontinuous Galerkin discretization for
|
||||
diffusion via DGDiffusionBR2Integrator (see Example 14/14p).
|
||||
|
||||
- Added convective and skew-symmetric integrators for the nonlinear term in the
|
||||
Navier-Stokes equations.
|
||||
|
||||
- Added new classes DenseSymmetricMatrix and SymmetricMatrixCoefficient for
|
||||
efficient evaluation of symmetric matrix coefficients. This replaces the now
|
||||
deprecated EvalSymmetric in MatrixCoefficient. Added DiagonalMatrixCoefficient
|
||||
for clarity, which is a typedef of VectorCoefficient.
|
||||
|
||||
- Added support for nonscalar coefficient with VectorDiffusionIntegrator.
|
||||
|
||||
Linear and nonlinear solvers
|
||||
----------------------------
|
||||
- Added support for AMG preconditioners on GPUs based on the hypre library
|
||||
(version 2.22.0 or later). These include BoomerAMG, AMS and ADS and most
|
||||
MFEM examples that use hypre have been ported to support this functionality.
|
||||
The GPU preconditioners require that both hypre and MFEM are built with CUDA
|
||||
support. Hypre builds with CUDA and unified memory are also supported and
|
||||
can be used with `-d cuda:uvm` as a command-line option.
|
||||
|
||||
- Added support for AMG preconditioners for non-symmetric systems (e.g.
|
||||
advection-dominated problems) using hypre's approximate ideal restriction
|
||||
(AIR) AMG. Requires hypre version 2.14.0 or newer. Usage is illustrated in
|
||||
example 9/9p.
|
||||
|
||||
- Added new functionality for constructing low-order refined discretizations and
|
||||
solvers, see the LORDiscretization and LORSolver classes. A new basis type for
|
||||
H(curl) and H(div) spaces is introduced to give spectral equivalence. This
|
||||
functionality is illustrated in the LOR solvers miniapp in miniapps/solvers.
|
||||
|
||||
- Generalized the Multigrid class to support non-geometric multigrid. Previous
|
||||
functionality, based on FiniteElementSpaceHierarchy, is now available in the
|
||||
derived class GeometricMultigrid.
|
||||
|
||||
- Introduced solver interface for linear problems with constraints, a few
|
||||
concrete solvers that implement the interface, and a demonstration of their
|
||||
@@ -52,19 +84,18 @@ Version 4.2.1 (development)
|
||||
as described in Barker and Kolev 2020 (https://doi.org/10.1002/nla.2348). See
|
||||
Example 3p and linalg/auxiliary.?pp.
|
||||
|
||||
- Added a new miniapp block-solvers that compares the performance of various
|
||||
solvers for mixed finite element discretization of the second order scalar
|
||||
elliptic equations. Currently available solvers in the miniapp include a
|
||||
block-diagonal preconditioner that is based on approximate Schur complement
|
||||
(implemented in ex5p), and a newly implemented solver DivFreeSolver, which
|
||||
exploits a multilevel decomposition of the Raviart-Thomas space and its
|
||||
divergence-free subspace. See the miniapps/solvers directory for more details.
|
||||
- Improved interface for using the Ginkgo library, including: support for matrix-
|
||||
free operators in Ginkgo solvers, new wrappers for Ginkgo preconditioners, HIP
|
||||
support, and reduction of unnecessary data copies.
|
||||
|
||||
- Added a new miniapp for computing (signed) distance functions to a point
|
||||
source or zero level set. See miniapps/shifted/distance.cpp.
|
||||
- Added initial support for hypre's mixed integer (mixedint) capability, which
|
||||
uses different data types for local and global indices in order to save memory
|
||||
in large problems. This capability requires that hypre was configured with the
|
||||
--enable-mixedint option. Note that this option is currently tested only in
|
||||
ex1p, ex3p, and ex4p, and may not work in more general settings.
|
||||
|
||||
- Added matrix-free GPU-enabled implementations of GradientInterpolator and
|
||||
IdentityInterpolator.
|
||||
- Added AlgebraicCeedSolver that does matrix-free algebraic p-multigrid for
|
||||
diffusion problems with the Ceed backend.
|
||||
|
||||
- Added interface to MUMPS direct solver. Its usage is demonstrated in ex25p.
|
||||
See http://mumps.enseeiht.fr/ for more details. Supported versions >= 5.1.1.
|
||||
@@ -72,6 +103,17 @@ Version 4.2.1 (development)
|
||||
- Added three ESDIRK time integrators: implicit trapezoid rule, L-stable
|
||||
ESDIRK-32, and A-stable ESDIRK-33.
|
||||
|
||||
- Implemented a variable step-size IMEX (VSSIMEX) method for the Navier miniapp.
|
||||
|
||||
- Implemented an adaptive linear solver tolerance option for NewtonSolver based
|
||||
on the algorithm of Eisenstat and Walker.
|
||||
|
||||
Meshing improvements
|
||||
--------------------
|
||||
- Added support for reading high-order Lagrange meshes in VTK format. Arbitrary-
|
||||
orders and all element types are supported. See the VTK blog for more info:
|
||||
https://blog.kitware.com/wp-content/uploads/2018/09/Source_Issue_43.pdf.
|
||||
|
||||
- Introduced a new non-conforming mesh format that fixes known inconsistencies
|
||||
of legacy "MFEM mesh v1.1" NC format and works consistently in both serial and
|
||||
parallel. ParMesh::ParPrint can now print non-conforming AMR meshes that can
|
||||
@@ -80,113 +122,26 @@ Version 4.2.1 (development)
|
||||
NC data files are compatible with serial code, e.g., can be viewed with serial
|
||||
GLVis. Loading of legacy NC mesh files is still supported.
|
||||
|
||||
- Added support for 1D non-conforming meshes (which can be useful for parallel
|
||||
load balancing and derefinement).
|
||||
|
||||
- Added a "scaled Jacobian" visualization option in the Mesh Explorer miniapp to
|
||||
help identify elements with poor mesh quality.
|
||||
|
||||
- Added support for the "BR2" discontinuous Galerkin discretization for
|
||||
diffusion via DGDiffusionBR2Integrator (see Example 14/14p).
|
||||
|
||||
- Generalized the Multigrid class to support non-geometric multigrid. The
|
||||
previous functionality, based on FiniteElementSpaceHierarchy, is now available
|
||||
in the derived class GeometricMultigrid.
|
||||
|
||||
- Upgraded the Catch unit test framework from version 2.13.0 to version 2.13.2.
|
||||
|
||||
- The TMOP mesh optimization algorithms were extended to GPU:
|
||||
- QualityMetric #1, #2, #7 and #77 are available in 2D, #302, #303, #315
|
||||
and #321 in 3D
|
||||
- Both AnalyticAdaptTC and DiscreteAdaptTC TargetConstructor are available
|
||||
- Kernels for normalization and limiting have been added
|
||||
- The AdvectorCG now also supports AssemblyLevel::PARTIAL
|
||||
|
||||
- Added a new command line boolean option (`--all`) to the unit tests to launch
|
||||
*all* non-regression tests.
|
||||
|
||||
- Added support for different modes of QuadratureInterpolator on GPU.
|
||||
The layout (QVectorLayout::byNODES|byVDIM) and the tensor products modes can
|
||||
be enabled before calling the Mult, Values, Derivatives, PhysDerivatives and
|
||||
Determinants methods.
|
||||
|
||||
- Implemented a filter method for the Navier miniapp to stabilize highly
|
||||
turbulent flows in direct numerical simulation.
|
||||
|
||||
- Added HIP support to the CMake build system.
|
||||
|
||||
- Added support for reading high-order Lagrange meshes in VTK format. Arbitrary-
|
||||
orders and all element types are supported. See the VTK blog for more info:
|
||||
https://blog.kitware.com/wp-content/uploads/2018/09/Source_Issue_43.pdf.
|
||||
|
||||
- Added support for reading VTK meshes in XML format.
|
||||
|
||||
- Added partial assembly and device support to Example 25/25p, with diagonal
|
||||
preconditioning.
|
||||
|
||||
- Implemented a variable step-size IMEX (VSSIMEX) method for the Navier miniapp.
|
||||
- Added FMS support (https://github.com/CEED/FMS) to mfem. FMS can represent
|
||||
unstructured high-order meshes with general high-order finite element fields
|
||||
on them. When enabled, mfem can convert data collections to/from FMS data
|
||||
collections in memory. In addition, an FMS data collection class was added so
|
||||
the convert-dc miniapp can read and generate data files in FMS format.
|
||||
|
||||
- Added new mesh quality metrics and improved the untangling capabilities of the
|
||||
TMOP-based mesh optimization algorithms.
|
||||
|
||||
- Added convective and skew-symmetric integrators for the nonlinear term in the
|
||||
Navier-Stokes equations.
|
||||
|
||||
- Added new miniapp directory mtop/ with optimization-oriented block parametric
|
||||
non-linear form and abstract integrators. Two new miniapps, ParHeat and
|
||||
SeqHeat, demonstrate parallel and sequential implementation of gradients
|
||||
evaluation for linear diffusion with discrete density.
|
||||
|
||||
- Changed the interface for the error estimator.
|
||||
|
||||
- Implemented the Kelly error indicator for scalar-valued problems, supported
|
||||
in serial and parallel builds.
|
||||
|
||||
- Added new classes DenseSymmetricMatrix and SymmetricMatrixCoefficient for
|
||||
efficient evaluation of symmetric matrix coefficients. This replaces the now
|
||||
deprecated EvalSymmetric in MatrixCoefficient. Added DiagonalMatrixCoefficient
|
||||
for clarity, which is a typedef of VectorCoefficient.
|
||||
|
||||
- Added support for AMG preconditioners for non-symmetric systems (e.g.
|
||||
advection-dominated problems) using hypre's approximate ideal restriction
|
||||
(AIR) AMG. Requires hypre version 2.14.0 or newer. Usage is illustrated in
|
||||
example 9/9p.
|
||||
|
||||
- Implemented an adaptive linear solver tolerance option for NewtonSolver based
|
||||
on the algorithm of Eisenstat and Walker.
|
||||
|
||||
- Added support for nonscalar coefficient with VectorDiffusionIntegrator.
|
||||
|
||||
- Extending support for L2 basis functions using MapTypes VALUE and INTEGRAL in
|
||||
linear interpolators and GridFunction "GetValue" methods.
|
||||
|
||||
- Variable order spaces, p- and hp-refinement. This is the initial (serial)
|
||||
support for variable-order FiniteElementCollection and FiniteElementSpace.
|
||||
The new method FiniteElementSpace::SetElementOrder can be called to set an
|
||||
arbitrary order for each mesh element. The conforming interpolation matrix
|
||||
will now automatically constrain p- and hp- interfaces, enabling general
|
||||
hp-refinement in both 2D and 3D, on uniform or mixed NC meshes. Support for
|
||||
parallel variable-order spaces will follow shortly.
|
||||
- The TMOP mesh optimization algorithms were extended to GPU:
|
||||
* QualityMetric 1, 2, 7, 77 are available in 2D, 302, 303, 315, 321 in 3D
|
||||
* Both AnalyticAdaptTC and DiscreteAdaptTC TargetConstructor are available
|
||||
* Kernels for normalization and limiting have been added
|
||||
* The AdvectorCG now also supports AssemblyLevel::PARTIAL
|
||||
|
||||
- Added support for creating refined meshes for all element types (e.g. by
|
||||
splitting high-order elements into low-order refined elements), including
|
||||
mixed meshes. The LOR Transfer miniapp (miniapps/tools/lor-transfer.cpp) now
|
||||
supports meshes with any element geometry.
|
||||
|
||||
- Testing improvements:
|
||||
* Transitioned from Travis to GitHub Action for testing/CI on GitHub.
|
||||
* Effectively remove Travis from CI.
|
||||
* Use Spack (and Uberenv) to automate TPL building in LLNL GitLab tests.
|
||||
* Added a set of suggested git hooks for developers in config/githooks.
|
||||
|
||||
- Added new miniapps demonstrating: 1) the use of GSLIB for overlapping grids,
|
||||
see gslib/schwarz_ex1, and 2) coupling different physics in different domains,
|
||||
see navier/cht. Note that gslib v1.0.7 is require (see INSTALL for details).
|
||||
|
||||
- Added a new, very simple example (ex0 and parallel version ex0p). This
|
||||
example solves a simple Poisson problem using H1 elements (the same problem as
|
||||
ex1), but is intended to be extremely simple and approachable for new users.
|
||||
|
||||
- Meshes consisting of any type of elements (including mixed meshes) can be
|
||||
converted to all-simplex meshes using Mesh::MakeSimplicial.
|
||||
|
||||
@@ -199,42 +154,133 @@ Version 4.2.1 (development)
|
||||
requisite periodic vertex mappings can be created with
|
||||
Mesh::CreatePeriodicVertexMapping.
|
||||
|
||||
- Added support for transferring dual fields between high-order and low-order
|
||||
refined finite element spaces using the transposed versions of the
|
||||
L2ProjectionGridTransfer operators. This functionality is illustrated in the
|
||||
lor-transfer miniapp.
|
||||
|
||||
- Improved interface for using the Ginkgo library, including: support for matrix-
|
||||
free operators in Ginkgo solvers, new wrappers for Ginkgo preconditioners, HIP
|
||||
support, and reduction of unnecessary data copies.
|
||||
|
||||
- Added initial support for hypre's mixed integer (mixedint) capability, which
|
||||
uses different data types for local and global indices in order to save memory
|
||||
in large problems. This capability requires that hypre was configured with the
|
||||
--enable-mixedint option. Note that this option is currently tested only in
|
||||
ex1p and may not work in more general settings.
|
||||
|
||||
- Added support for transferring fields (primary and dual) between high-order
|
||||
and low-order refined H1 finite element spaces using the
|
||||
L2ProjectionH1GridTransfer operators. This functionality is demonstrated
|
||||
through the lor-transfer miniapp when run with the -h1 option.
|
||||
|
||||
- Added new functionality for constructing low-order refined discretizations and
|
||||
solvers, see the LORDiscretization and LORSolver classes. A new basis type for
|
||||
H(curl) and H(div) spaces is introduced to give spectral equivalence. This
|
||||
functionality is illustrated in the LOR solvers miniapp in miniapps/solvers.
|
||||
- Added support for 1D non-conforming meshes (which can be useful for parallel
|
||||
load balancing and derefinement).
|
||||
|
||||
- Added sample meshes in the `data` subdirectory showing the reference elements
|
||||
of the six currently supported element types; ref-segment.mesh,
|
||||
ref-triangle.mesh, ref-square.mesh, ref-tetrahedron.mesh, ref-cube.mesh, and
|
||||
ref-prism.mesh.
|
||||
|
||||
High-performance computing
|
||||
--------------------------
|
||||
- Added initial support for GPU-accelerated versions of PETSc that works with
|
||||
MFEM_USE_CUDA if PETSc has been configured with CUDA support. Examples 1 and 9
|
||||
in the examples/petsc directory have been modified to work with --device cuda.
|
||||
Examples with GAMG (ex1p) and SLEPc (ex11p) are also provided.
|
||||
|
||||
- Added support for explicit vectorization in the high-performance templated
|
||||
code for Fujitsu's A64FX ARM microprocessor architecture.
|
||||
|
||||
- Added support for different modes of QuadratureInterpolator on GPU.
|
||||
The layout (QVectorLayout::byNODES|byVDIM) and the tensor products modes can
|
||||
be enabled before calling the Mult, Values, Derivatives, PhysDerivatives and
|
||||
Determinants methods.
|
||||
|
||||
- Added method Device::SetMemoryTypes that can be used to change the default
|
||||
host and device MemoryTypes before Device setup.
|
||||
|
||||
- In class MemoryManager, added methods GetDualMemoryType and SetDualMemoryType;
|
||||
dual MemoryTypes are used to determine the second MemoryType (host or device)
|
||||
when only one MemoryType is specified in methods of class Memory.
|
||||
|
||||
- Added Memory constructor for setting both the host and device MemoryTypes.
|
||||
|
||||
- Switched the default behavior of device memory allocations so that they are
|
||||
deferred until the device pointer is needed.
|
||||
|
||||
- Added a second Umpire device MemoryType, DEVICE_UMPIRE_2, with corresponding
|
||||
allocator that can be set with the method SetUmpireDevice2AllocatorName.
|
||||
|
||||
- Added HOST_PINNED MemoryType and a pinned host allocator for CUDA and HIP.
|
||||
|
||||
- Added matrix-free GPU-enabled implementations of GradientInterpolator and
|
||||
IdentityInterpolator.
|
||||
|
||||
New and updated examples and miniapps
|
||||
-------------------------------------
|
||||
- Added a new, very simple example (ex0 and parallel version ex0p). This example
|
||||
solves a simple Poisson problem using H1 elements (the same problem as ex1),
|
||||
but is intended to be extremely simple and approachable for new users.
|
||||
|
||||
- Added new miniapps demonstrating: 1) the use of GSLIB for overlapping grids,
|
||||
see gslib/schwarz_ex1, and 2) coupling different physics in different domains,
|
||||
see navier/cht. Note that gslib v1.0.7 is require (see INSTALL for details).
|
||||
|
||||
- Added a new miniapp for computing (signed) distance functions to a point
|
||||
source or zero level set. See miniapps/shifted/distance.cpp.
|
||||
|
||||
- Added a high-order extension of the shifted boundary method to solve PDEs on
|
||||
non body-fitted meshes. This is illustrated in the new Shifted Diffusion
|
||||
miniapp, see miniapps/shifted/diffusion.cpp.
|
||||
|
||||
- Added new miniapp directory mtop/ with optimization-oriented block parametric
|
||||
non-linear form and abstract integrators. Two new miniapps, ParHeat and
|
||||
SeqHeat, demonstrate parallel and sequential implementation of gradients
|
||||
evaluation for linear diffusion with discrete density.
|
||||
|
||||
- Added a new miniapp block-solvers that compares the performance of various
|
||||
solvers for mixed finite element discretization of the second order scalar
|
||||
elliptic equations. Currently available solvers in the miniapp include a
|
||||
block-diagonal preconditioner that is based on approximate Schur complement
|
||||
(implemented in ex5p), and a newly implemented solver DivFreeSolver, which
|
||||
exploits a multilevel decomposition of the Raviart-Thomas space and its
|
||||
divergence-free subspace. See the miniapps/solvers directory for more details.
|
||||
|
||||
- Introduced new options for the mesh-explorer miniapp to visualize the actual
|
||||
element attributes in parallel meshes while retaining the visualization of the
|
||||
domain decomposition.
|
||||
|
||||
- Added partial assembly and device support to Example 25/25p, with diagonal
|
||||
preconditioning.
|
||||
|
||||
- Implemented a filter method for the Navier miniapp to stabilize highly
|
||||
turbulent flows in direct numerical simulation.
|
||||
|
||||
Improved testing
|
||||
----------------
|
||||
- Transitioned from Travis to GitHub Action for testing/CI on GitHub.
|
||||
|
||||
- Use Spack (and Uberenv) to automate TPL building in LLNL GitLab tests.
|
||||
|
||||
- Extended `make test` to include GPU tests when MFEM is built with CUDA or HIP
|
||||
support.
|
||||
|
||||
- Added a set of suggested git hooks for developers in config/githooks.
|
||||
|
||||
- Added support for Caliper: a library to integrate performance profiling
|
||||
capabilities into applications. See examples/caliper for more details.
|
||||
|
||||
- Added a new command line boolean option (`--all`) to the unit tests to launch
|
||||
*all* non-regression tests.
|
||||
|
||||
- Upgraded the Catch unit test framework from version 2.13.0 to version 2.13.2.
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
- The following integrations have updated minimum version requirements:
|
||||
* CUDA >= 10.1.168
|
||||
* Ginkgo >= 1.4.0
|
||||
* GSLIB >= 1.0.7
|
||||
* HIOP >= 0.4
|
||||
* HYPRE >= 2.20.0 for mixedint support
|
||||
* HYPRE >= 2.22.0 for CUDA support
|
||||
* libCEED >= 0.8
|
||||
* PETSc >= 3.15.0 for CUDA support
|
||||
* RAJA >= 0.13.0
|
||||
see INSTALL for more details.
|
||||
|
||||
- Added a "scaled Jacobian" visualization option in the Mesh Explorer miniapp to
|
||||
help identify elements with poor mesh quality.
|
||||
|
||||
- Added support for reading VTK meshes in XML format.
|
||||
|
||||
- Added makefile rule to generate TAGS table for vi or Emacs users.
|
||||
|
||||
- Added HIP support to the CMake build system.
|
||||
|
||||
- Various other simplifications, extensions, and bugfixes in the code.
|
||||
|
||||
API changes
|
||||
-----------
|
||||
- Added an abstract interface `mfem::FaceRestriction` for `H1FaceRestriction`
|
||||
@@ -244,20 +290,11 @@ API changes
|
||||
`mfem::FaceRestriction::AddMultTranspose` should replace previous calls to
|
||||
`mfem::FaceRestriction::MultTranspose`.
|
||||
|
||||
libCEED integration improvements
|
||||
--------------------------------
|
||||
- Refactor the libCEED integration
|
||||
|
||||
- Add support for VectorCoefficient with libCEED backends.
|
||||
|
||||
- Add support for ConvectionIntegrator, and VectorConvectionNLFIntegrator with
|
||||
libCEED backends.
|
||||
|
||||
|
||||
Version 4.2, released on October 30, 2020
|
||||
=========================================
|
||||
|
||||
High-Performance Computing
|
||||
High-performance computing
|
||||
--------------------------
|
||||
- Added support for explicit vectorization in the high-performance templated
|
||||
code, which can now take advantage of specific classes on the following
|
||||
@@ -339,9 +376,6 @@ Linear and nonlinear solvers
|
||||
matrix with the function HypreParMatrixFromBlocks. This could be useful for
|
||||
solving block systems with parallel direct solvers such as STRUMPACK.
|
||||
|
||||
- Added CUDA support for SUNDIALS ODE integrators. See the updated SUNDIALS
|
||||
modification of Example 9/9p.
|
||||
|
||||
- Added wrappers for hypre's flexible GMRES solver and the new parallel ILU
|
||||
preconditioner. The latter requires hypre version 2.19.0 or later.
|
||||
|
||||
@@ -452,7 +486,7 @@ New and updated examples and miniapps
|
||||
L2, with partial assembly support in Example 24/24p.
|
||||
* Weak Dirichlet boundary conditions (Nitsche) to the NURBS miniapp.
|
||||
|
||||
Data management and Visualization
|
||||
Data management and visualization
|
||||
---------------------------------
|
||||
- Added support for ADIOS2 for parallel I/O with ParaView visualization. See
|
||||
Examples 5, 9, 12, 16. The classes adios2stream and ADIOS2DataCollection
|
||||
|
||||
+13
-4
@@ -16,7 +16,7 @@ set(USER_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/config/user.cmake" CACHE PATH
|
||||
|
||||
# Require C++11 and disable compiler-specific extensions
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
if (MFEM_USE_GINKGO)
|
||||
if (MFEM_USE_GINKGO)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -54,7 +54,7 @@ project(mfem NONE)
|
||||
# Current version of MFEM, see also `makefile`.
|
||||
# mfem_VERSION = (string)
|
||||
# MFEM_VERSION = (int) [automatically derived from mfem_VERSION]
|
||||
set(${PROJECT_NAME}_VERSION 4.2.1)
|
||||
set(${PROJECT_NAME}_VERSION 4.3.1)
|
||||
|
||||
# Prohibit in-source build
|
||||
if (${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
|
||||
@@ -102,7 +102,7 @@ if (MFEM_USE_CUDA)
|
||||
endif()
|
||||
enable_language(CUDA)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
if (MFEM_USE_GINKGO)
|
||||
if (MFEM_USE_GINKGO)
|
||||
set(CMAKE_CUDA_STANDARD 14)
|
||||
endif()
|
||||
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
||||
@@ -246,6 +246,7 @@ if (MFEM_USE_OPENMP OR MFEM_USE_LEGACY_OPENMP)
|
||||
message(FATAL_ERROR " *** MFEM_USE_LEGACY_OPENMP requires MFEM_THREAD_SAFE=ON.")
|
||||
endif()
|
||||
find_package(OpenMP REQUIRED)
|
||||
set(OPENMP_LIBRARIES ${OpenMP_CXX_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# SuiteSparse (before SUNDIALS which may depend on KLU)
|
||||
@@ -330,6 +331,10 @@ if (MFEM_USE_CONDUIT)
|
||||
find_package(Conduit REQUIRED conduit relay blueprint )
|
||||
endif()
|
||||
|
||||
if (MFEM_USE_FMS)
|
||||
find_package(FMS REQUIRED fms )
|
||||
endif()
|
||||
|
||||
# Axom/Sidre
|
||||
if (MFEM_USE_SIDRE)
|
||||
find_package(Axom REQUIRED Axom)
|
||||
@@ -424,9 +429,10 @@ endif()
|
||||
# integers, the METIS header (with 32-bit indices, as used by mfem) needs to
|
||||
# be before SuiteSparse.
|
||||
set(MFEM_TPLS MPI_CXX OPENMP HYPRE BLAS LAPACK SuperLUDist METIS SuiteSparse SUNDIALS PETSC
|
||||
SLEPC MESQUITE MUMPS STRUMPACK AXOM CONDUIT Ginkgo GNUTLS GSLIB NETCDF
|
||||
SLEPC MESQUITE MUMPS STRUMPACK AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB NETCDF
|
||||
MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE ADIOS2
|
||||
CUSPARSE MKL_CPARDISO AMGX CALIPER)
|
||||
|
||||
# Add all *_FOUND libraries in the variable TPL_LIBRARIES.
|
||||
set(TPL_LIBRARIES "")
|
||||
set(TPL_INCLUDE_DIRS "")
|
||||
@@ -445,6 +451,9 @@ include_directories(${TPL_INCLUDE_DIRS})
|
||||
if (OPENMP_FOUND)
|
||||
message(STATUS "MFEM: using package OpenMP")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
if (MFEM_USE_CUDA)
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "MFEM build type: CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
+1
-2
@@ -97,7 +97,6 @@ The MFEM source code has the following structure:
|
||||
.
|
||||
├── config
|
||||
│ ├── cmake
|
||||
│ │ └── ...
|
||||
│ └── githooks
|
||||
├── data
|
||||
├── doc
|
||||
@@ -135,10 +134,10 @@ The MFEM source code has the following structure:
|
||||
└── tests
|
||||
├── convergence
|
||||
├── gitlab
|
||||
├── mem_manager
|
||||
├── par-mesh-format
|
||||
├── scripts
|
||||
└── unit
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### Main directories and classes
|
||||
|
||||
@@ -474,7 +474,7 @@ MFEM_USE_HIP = YES/NO
|
||||
Enables support for AMD devices in MFEM. HIP is a heterogeneous-compute
|
||||
interface for portability developed by AMD that can target both AMD and
|
||||
NVIDIA GPUs. The variable HIP_ARCH is used to specify the AMD GPU processor
|
||||
used during compilation (by default, HIP_ARCH=gfx900). When enabled, this
|
||||
used during compilation (by default, HIP_ARCH=gfx900). When enabled, this
|
||||
option uses the HIP_* build options, see below.
|
||||
|
||||
MFEM_USE_RAJA = YES/NO
|
||||
@@ -516,6 +516,13 @@ MFEM_USE_CALIPER = YES/NO
|
||||
profiling at runtime with Caliper's configuration API. Alternatively, one
|
||||
can configure Caliper through environment variables or config files.
|
||||
|
||||
MFEM_USE_FMS = YES/NO
|
||||
Enables support for the FMS library which consists of the DataCollection
|
||||
sub-class mfem::FMSDataCollection for I/O in FMS formats, see the header file
|
||||
fem/fmsdatacollection.hpp. In addition, this option enables in-memory
|
||||
convetion routines between FMS's FmsDataCollection structure and MFEM's
|
||||
DataCollection class, see the header file fem/fmsconvert.hpp.
|
||||
|
||||
MFEM_BUILD_TAG = (any value)
|
||||
An optional tag to characterize the build. Exported to config/config.mk.
|
||||
Can be used to identify the MFEM build from other makefiles.
|
||||
@@ -540,8 +547,9 @@ The specific libraries and their options are:
|
||||
See also the "Specific options for hypre" section at the end of this file.
|
||||
URL: https://github.com/hypre-space/hypre and https://www.llnl.gov/casc/hypre
|
||||
Options: HYPRE_OPT, HYPRE_LIB.
|
||||
Versions: HYPRE >= 2.10.0b,
|
||||
HYPRE >= 2.20.0 for '--enable-mixedint' support.
|
||||
Versions: HYPRE >= 2.10.0b (HYPRE built without CUDA)
|
||||
HYPRE >= 2.20.0 (HYPRE built with '--enable-mixedint')
|
||||
HYPRE >= 2.22.0 (HYPRE built with CUDA)
|
||||
|
||||
- METIS, used when MFEM_USE_METIS = YES. If using METIS 5, set
|
||||
MFEM_USE_METIS_5 = YES (default is to use METIS 4).
|
||||
@@ -615,7 +623,7 @@ The specific libraries and their options are:
|
||||
and dependencies of specific modules, see the Ginkgo webpage below.
|
||||
URL: https://ginkgo-project.github.io
|
||||
Options: GINKGO_OPT, GINKGO_LIB, GINKGO_DIR, GINKGO_BUILD_TYPE (Release or Debug).
|
||||
Versions: Ginkgo >= 1.4.0.
|
||||
Versions: Ginkgo >= 1.4.0.
|
||||
|
||||
- AmgX (optional), used when MFEM_USE_AMGX = YES.
|
||||
URL: https://github.com/NVIDIA/AMGX
|
||||
@@ -753,6 +761,11 @@ The specific libraries and their options are:
|
||||
URL: https://zlib.net
|
||||
Options: ZLIB_OPT, ZLIB_LIB.
|
||||
|
||||
- FMS (optional), used when MFEM_USE_FMS = YES.
|
||||
URL: https://github.com/CEED/FMS
|
||||
Options: FMS_OPT, FMS_LIB.
|
||||
Versions: FMS >= 0.2.
|
||||
|
||||
Building with CMake
|
||||
===================
|
||||
The MFEM build system consists of two steps: configuration and compilation.
|
||||
@@ -884,6 +897,7 @@ MFEM_USE_RAJA
|
||||
MFEM_USE_UMPIRE
|
||||
MFEM_USE_SIDRE
|
||||
MFEM_USE_CALIPER
|
||||
MFEM_USE_FMS
|
||||
|
||||
The following options are CMake specific:
|
||||
|
||||
@@ -938,6 +952,7 @@ The CMake build system adds auto-detection for the following packages/libraries:
|
||||
- UMPIRE
|
||||
- AXOM - Used when MFEM_USE_SIDRE is enabled
|
||||
- CALIPER
|
||||
- FMS
|
||||
|
||||
The following built-in CMake packages are also used:
|
||||
|
||||
@@ -955,7 +970,7 @@ config/config.hpp.in:
|
||||
|
||||
cp config/config.hpp.in config/_config.hpp
|
||||
|
||||
The file config/_config.hpp can then be edited to enable desired options. The
|
||||
The file config/_config.hpp can then be edited to enable desired options. The
|
||||
MFEM library is simply a combination of all object files obtained by compiling
|
||||
the .cpp source files in the source directories: general, linalg, mesh, and fem.
|
||||
|
||||
@@ -963,7 +978,7 @@ the .cpp source files in the source directories: general, linalg, mesh, and fem.
|
||||
Specifying an MPI job launcher
|
||||
==============================
|
||||
By default, MFEM will use 'mpirun -np #' to launch any of its parallel tests or
|
||||
miniapps, where # is the number of MPI tasks. An alternate MPI launcher can be
|
||||
miniapps, where # is the number of MPI tasks. An alternate MPI launcher can be
|
||||
provided by setting the MFEM_MPIEXEC and MFEM_MPIEXEC_NP config variables.
|
||||
|
||||
MFEM will expect the launcher command, plus the command line option to allow it
|
||||
|
||||
@@ -256,6 +256,10 @@ IF (DEFINED TPL_ENABLE_SIDRE)
|
||||
SET(MFEM_USE_SIDRE ${TPL_ENABLE_SIDRE} CACHE BOOL "Enable Axom/Sidre usage" FORCE)
|
||||
ENDIF()
|
||||
|
||||
IF (DEFINED TPL_ENABLE_FMS)
|
||||
SET(MFEM_USE_FMS ${TPL_ENABLE_FMS} CACHE BOOL "Enable FMS usage" FORCE)
|
||||
ENDIF()
|
||||
|
||||
IF (DEFINED TPL_ENABLE_CONDUIT)
|
||||
SET(MFEM_USE_CONDUIT ${TPL_ENABLE_CONDUIT} CACHE BOOL "Enable Conduit usage" FORCE)
|
||||
ENDIF()
|
||||
|
||||
@@ -44,6 +44,7 @@ set(MFEM_USE_PETSC @MFEM_USE_PETSC@)
|
||||
set(MFEM_USE_SLEPC @MFEM_USE_SLEPC@)
|
||||
set(MFEM_USE_MPFR @MFEM_USE_MPFR@)
|
||||
set(MFEM_USE_SIDRE @MFEM_USE_SIDRE@)
|
||||
set(MFEM_USE_FMS @MFEM_USE_FMS@)
|
||||
set(MFEM_USE_CONDUIT @MFEM_USE_CONDUIT@)
|
||||
set(MFEM_USE_PUMI @MFEM_USE_PUMI@)
|
||||
set(MFEM_USE_CUDA @MFEM_USE_CUDA@)
|
||||
|
||||
@@ -119,6 +119,9 @@
|
||||
// Enable the use of SIMD in the high performance templated classes
|
||||
#cmakedefine MFEM_USE_SIMD
|
||||
|
||||
// Enable MFEM functionality based on the FMS library
|
||||
#cmakedefine MFEM_USE_FMS
|
||||
|
||||
// Enable MFEM functionality based on Conduit
|
||||
#cmakedefine MFEM_USE_CONDUIT
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2010-2021, 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.
|
||||
|
||||
# Defines the following variables:
|
||||
# - FMS_FOUND
|
||||
# - FMS_LIBRARIES
|
||||
# - FMS_INCLUDE_DIRS
|
||||
|
||||
include(MfemCmakeUtilities)
|
||||
mfem_find_package(FMS FMS FMS_DIR
|
||||
"include" fms.h "lib" fms
|
||||
"Paths to headers required by FMS." "Libraries required by FMS.")
|
||||
@@ -117,6 +117,9 @@
|
||||
// Enable the use of SIMD in the high performance templated classes
|
||||
// #define MFEM_USE_SIMD
|
||||
|
||||
// Enable FMS support
|
||||
// #define MFEM_USE_FMS
|
||||
|
||||
// Enable Conduit support
|
||||
// #define MFEM_USE_CONDUIT
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ MFEM_USE_PETSC = @MFEM_USE_PETSC@
|
||||
MFEM_USE_SLEPC = @MFEM_USE_SLEPC@
|
||||
MFEM_USE_MPFR = @MFEM_USE_MPFR@
|
||||
MFEM_USE_SIDRE = @MFEM_USE_SIDRE@
|
||||
MFEM_USE_FMS = @MFEM_USE_FMS@
|
||||
MFEM_USE_CONDUIT = @MFEM_USE_CONDUIT@
|
||||
MFEM_USE_PUMI = @MFEM_USE_PUMI@
|
||||
MFEM_USE_HIOP = @MFEM_USE_HIOP@
|
||||
|
||||
+14
-2
@@ -45,6 +45,7 @@ option(MFEM_USE_PETSC "Enable PETSc support." OFF)
|
||||
option(MFEM_USE_SLEPC "Enable SLEPc support." OFF)
|
||||
option(MFEM_USE_MPFR "Enable MPFR usage." OFF)
|
||||
option(MFEM_USE_SIDRE "Enable Axom/Sidre usage" OFF)
|
||||
option(MFEM_USE_FMS "Enable FMS usage" OFF)
|
||||
option(MFEM_USE_CONDUIT "Enable Conduit usage" OFF)
|
||||
option(MFEM_USE_PUMI "Enable PUMI" OFF)
|
||||
option(MFEM_USE_HIOP "Enable HiOp" OFF)
|
||||
@@ -96,6 +97,11 @@ set(HYPRE_DIR "${MFEM_DIR}/../hypre/src/hypre" CACHE PATH
|
||||
# If hypre was compiled to depend on BLAS and LAPACK:
|
||||
# set(HYPRE_REQUIRED_PACKAGES "BLAS" "LAPACK" CACHE STRING
|
||||
# "Packages that HYPRE depends on.")
|
||||
if (MFEM_USE_CUDA)
|
||||
# This is only necessary when hypre is built with cuda:
|
||||
set(HYPRE_REQUIRED_LIBRARIES "-lcusparse" "-lcurand" CACHE STRING
|
||||
"Libraries that HYPRE depends on.")
|
||||
endif()
|
||||
|
||||
set(METIS_DIR "${MFEM_DIR}/../metis-4.0" CACHE PATH "Path to the METIS library.")
|
||||
|
||||
@@ -132,10 +138,10 @@ set(MUMPS_DIR "${MFEM_DIR}/../MUMPS_5.2.0" CACHE PATH
|
||||
"Path to the MUMPS library.")
|
||||
# Packages required by MUMPS, depending on how it was compiled.
|
||||
set(MUMPS_REQUIRED_PACKAGES "MPI" "BLAS" "METIS" "ScaLAPACK" CACHE STRING
|
||||
"Additional packages required by MUMPS.")
|
||||
"Additional packages required by MUMPS.")
|
||||
# If the MPI package does not find all required Fortran libraries:
|
||||
# set(MUMPS_REQUIRED_LIBRARIES "gfortran" "mpi_mpifh" CACHE STRING
|
||||
# "Additional libraries required by MUMPS.")
|
||||
# "Additional libraries required by MUMPS.")
|
||||
|
||||
set(STRUMPACK_DIR "${MFEM_DIR}/../STRUMPACK-build" CACHE PATH
|
||||
"Path to the STRUMPACK library.")
|
||||
@@ -187,6 +193,12 @@ set(SLEPC_ARCH "arch-linux2-c-debug" CACHE STRING "SLEPC build architecture.")
|
||||
|
||||
set(MPFR_DIR "" CACHE PATH "Path to the MPFR library.")
|
||||
|
||||
set(FMS_DIR "${MFEM_DIR}/../fms" CACHE PATH
|
||||
"Path to the FMS library.")
|
||||
# If FMS is built with Conduit:
|
||||
# set(FMS_REQUIRED_PACKAGES "Conduit/relay" CACHE STRING
|
||||
# "Additional packages required by FMS.")
|
||||
|
||||
set(CONDUIT_DIR "${MFEM_DIR}/../conduit" CACHE PATH
|
||||
"Path to the Conduit library.")
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ MFEM_USE_PETSC = NO
|
||||
MFEM_USE_SLEPC = NO
|
||||
MFEM_USE_MPFR = NO
|
||||
MFEM_USE_SIDRE = NO
|
||||
MFEM_USE_FMS = NO
|
||||
MFEM_USE_CONDUIT = NO
|
||||
MFEM_USE_PUMI = NO
|
||||
MFEM_USE_HIOP = NO
|
||||
@@ -174,6 +175,10 @@ LIBUNWIND_LIB = $(if $(NOTMAC),-lunwind -ldl,)
|
||||
HYPRE_DIR = @MFEM_DIR@/../hypre/src/hypre
|
||||
HYPRE_OPT = -I$(HYPRE_DIR)/include
|
||||
HYPRE_LIB = -L$(HYPRE_DIR)/lib -lHYPRE
|
||||
ifeq (YES,$(MFEM_USE_CUDA))
|
||||
# This is only necessary when hypre is built with cuda:
|
||||
HYPRE_LIB += -lcusparse -lcurand
|
||||
endif
|
||||
|
||||
# METIS library configuration
|
||||
ifeq ($(MFEM_USE_SUPERLU)$(MFEM_USE_STRUMPACK)$(MFEM_USE_MUMPS),NONONO)
|
||||
@@ -357,6 +362,11 @@ endif
|
||||
MPFR_OPT =
|
||||
MPFR_LIB = -lmpfr
|
||||
|
||||
# FMS and required libraries configuration
|
||||
FMS_DIR = $(MFEM_DIR)/../fms
|
||||
FMS_OPT = -I$(FMS_DIR)/include
|
||||
FMS_LIB = -Wl,-rpath,$(FMS_DIR)/lib -L$(FMS_DIR)/lib -lfms
|
||||
|
||||
# Conduit and required libraries configuration
|
||||
CONDUIT_DIR = @MFEM_DIR@/../conduit
|
||||
CONDUIT_OPT = -I$(CONDUIT_DIR)/include/conduit
|
||||
|
||||
+31
-6
@@ -57,22 +57,27 @@ TIMECMD := $(word 1,$(TIMECMD))
|
||||
ifneq (,$(filter test%,$(MAKECMDGOALS)))
|
||||
MAKEFLAGS += -k
|
||||
endif
|
||||
# Test runs of the examples/miniapps with parameters - check exit code
|
||||
# Test runs of the examples/miniapps with parameters - check exit code:
|
||||
# 0 means success, 255 means the test was skipped, anything else means error
|
||||
mfem-test = \
|
||||
printf " $(3) [$(2) $(1) ... ]: "; \
|
||||
$(call $(TIMEFUN),$(TIMECMD),$(2) ./$(1) $(if $(5),,-no-vis )$(4) \
|
||||
> $(1).stderr 2>&1); \
|
||||
if [ "$$3" = 0 ]; \
|
||||
then $(PRINT_OK); else $(PRINT_FAILED); cat $(1).stderr; fi; \
|
||||
rm -f $(1).stderr; exit $$3
|
||||
err="$$3"; \
|
||||
if [ "$$3" = 0 ]; then $(PRINT_OK); \
|
||||
else if [ "$$3" = 255 ]; then $(PRINT_SKIP); err=0; \
|
||||
else $(PRINT_FAILED); cat $(1).stderr; fi; fi; \
|
||||
rm -f $(1).stderr; exit $$err
|
||||
|
||||
# Test runs of the examples/miniapps - check exit code and if a file exists
|
||||
# See mfem-test for the interpretation of the error code
|
||||
mfem-test-file = \
|
||||
printf " $(3) [$(2) $(1) ... ]: "; \
|
||||
$(call $(TIMEFUN),$(TIMECMD),$(2) ./$(1) -no-vis > $(1).stderr 2>&1); \
|
||||
err="$$3"; \
|
||||
if [ "$$3" = 0 ] && [ -e $(4) ]; \
|
||||
then $(PRINT_OK); else $(PRINT_FAILED); cat $(1).stderr; err=64; fi; \
|
||||
if [ "$$3" = 0 ] && [ -e $(4) ]; then $(PRINT_OK); \
|
||||
else if [ "$$3" = 255 ] && [ -e $(4) ]; then $(PRINT_SKIP); err=0; \
|
||||
else $(PRINT_FAILED); cat $(1).stderr; err=64; fi; fi; \
|
||||
rm -f $(1).stderr; exit $$err
|
||||
|
||||
.PHONY: test test-par-YES test-par-NO test-ser test-par test-clean test-print
|
||||
@@ -80,6 +85,26 @@ mfem-test-file = \
|
||||
# What sets of tests to run in serial and parallel
|
||||
test-par-YES: $(PAR_$(MFEM_TESTS):=-test-par) $(SEQ_$(MFEM_TESTS):=-test-seq)
|
||||
test-par-NO: $(SEQ_$(MFEM_TESTS):=-test-seq)
|
||||
ifeq ($(MFEM_USE_CUDA),YES)
|
||||
.PHONY: test-par-YES-cuda test-par-NO-cuda test-ser-cuda test-par-cuda test-cuda
|
||||
test-par-YES: test-par-YES-cuda
|
||||
test-par-NO: test-par-NO-cuda
|
||||
test-par-YES-cuda: test-par-cuda test-ser-cuda
|
||||
test-par-NO-cuda: test-ser-cuda
|
||||
test-ser-cuda: $(SEQ_DEVICE_$(MFEM_TESTS):=-test-seq-cuda)
|
||||
test-par-cuda: $(PAR_DEVICE_$(MFEM_TESTS):=-test-par-cuda)
|
||||
test-cuda: test-par-$(MFEM_USE_MPI)-cuda clean-exec
|
||||
endif
|
||||
ifeq ($(MFEM_USE_HIP),YES)
|
||||
.PHONY: test-par-YES-hip test-par-NO-hip test-ser-hip test-par-hip test-hip
|
||||
test-par-YES: test-par-YES-hip
|
||||
test-par-NO: test-par-NO-hip
|
||||
test-par-YES-hip: test-par-hip test-ser-hip
|
||||
test-par-NO-hip: test-ser-hip
|
||||
test-ser-hip: $(SEQ_DEVICE_$(MFEM_TESTS):=-test-seq-hip)
|
||||
test-par-hip: $(PAR_DEVICE_$(MFEM_TESTS):=-test-par-hip)
|
||||
test-hip: test-par-$(MFEM_USE_MPI)-hip clean-exec
|
||||
endif
|
||||
test-ser: test-par-NO
|
||||
test-par: test-par-YES
|
||||
test: all test-par-$(MFEM_USE_MPI) clean-exec
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
FMS: 100
|
||||
DataCollection/Name: star
|
||||
DataCollection/NumberOfFieldDescriptors: 1
|
||||
DataCollection/FieldDescriptors/0/Name: CoordsDescriptor
|
||||
DataCollection/FieldDescriptors/0/ComponentName: volume
|
||||
DataCollection/FieldDescriptors/0/Type: 0
|
||||
DataCollection/FieldDescriptors/0/FixedOrder/Size: 3
|
||||
DataCollection/FieldDescriptors/0/FixedOrder/Type: FMS_UINT64
|
||||
DataCollection/FieldDescriptors/0/FixedOrder/Values: [0, 1, 3]
|
||||
DataCollection/FieldDescriptors/0/NumDofs: 211
|
||||
DataCollection/NumberOfFields: 1
|
||||
DataCollection/Fields/0/Name: Coords
|
||||
DataCollection/Fields/0/LayoutType: 0
|
||||
DataCollection/Fields/0/NumberOfVectorComponents: 2
|
||||
DataCollection/Fields/0/FieldDescriptorName: CoordsDescriptor
|
||||
DataCollection/Fields/0/Data/Size: 422
|
||||
DataCollection/Fields/0/Data/Type: FMS_DOUBLE
|
||||
DataCollection/Fields/0/Data/Values: [-0.016886, 1.000000, 0.309017,
|
||||
1.309020, -0.809017, -0.500000,
|
||||
-0.809017, -1.618030, 0.309017,
|
||||
-0.500000, 1.309020, 0.519420,
|
||||
1.154510, 0.809019, 0.147680,
|
||||
-0.095492, -0.654508, -0.415586,
|
||||
-1.213520, -1.213520, -0.392210,
|
||||
-0.654508, -0.095492, 0.139949,
|
||||
0.809019, 1.154510, 0.660184,
|
||||
-0.264063, -0.800064, -0.231060,
|
||||
0.663691, 0.183114, 0.317639,
|
||||
0.543082, 0.598483, 0.345112,
|
||||
0.478298, 0.027703, 0.095229,
|
||||
0.012368, -0.092534, -0.334412,
|
||||
-0.313767, -0.140526, -0.293881,
|
||||
-0.534056, -0.660290, -0.537646,
|
||||
-0.655590, -0.121396, -0.274504,
|
||||
-0.346497, -0.296570, 0.004737,
|
||||
-0.098835, 0.069287, 0.082675,
|
||||
0.318799, 0.467183, 0.564505,
|
||||
0.595190, 0.846237, 0.671735,
|
||||
1.051500, 1.103010, 0.964008,
|
||||
0.821603, 1.257520, 1.206010,
|
||||
1.142350, 0.975686, 0.781273,
|
||||
0.717257, 0.475684, 0.642352,
|
||||
0.268930, 0.211049, 0.174181,
|
||||
0.039345, -0.147746, -0.177481,
|
||||
-0.365164, -0.230328, -0.551503,
|
||||
-0.603005, -0.497587, -0.389864,
|
||||
-0.757514, -0.706011, -0.675487,
|
||||
-0.528946, -0.943851, -1.078690,
|
||||
-1.087600, -0.955467, -1.483190,
|
||||
-1.348360, -1.483190, -1.348360,
|
||||
-1.085930, -0.938010, -0.943851,
|
||||
-1.078690, -0.681476, -0.540944,
|
||||
-0.757514, -0.706011, -0.540614,
|
||||
-0.367058, -0.551503, -0.603005,
|
||||
-0.365164, -0.230328, -0.138552,
|
||||
-0.206896, 0.174181, 0.039345,
|
||||
0.268468, 0.222269, 0.475684,
|
||||
0.642352, 0.759791, 0.719381,
|
||||
1.142350, 0.975686, 1.257520,
|
||||
1.206010, 0.972837, 0.836119,
|
||||
1.051500, 1.103010, 0.214572,
|
||||
0.407449, 0.288323, 0.449827,
|
||||
-0.086700, -0.027358, -0.200560,
|
||||
-0.166595, -0.271802, -0.418426,
|
||||
-0.426131, -0.551441, -0.096117,
|
||||
-0.206969, -0.027946, -0.184969,
|
||||
0.211136, 0.260131, 0.407172,
|
||||
0.430781, 0.718277, 0.885068,
|
||||
0.753103, 0.957692, 0.866273,
|
||||
1.024530, 0.934099, 1.093820,
|
||||
0.348422, 0.524463, 0.404903,
|
||||
0.587376, 0.054525, 0.146431,
|
||||
-0.078026, -0.007795, -0.329488,
|
||||
-0.302967, -0.488115, -0.439332,
|
||||
-0.498515, -0.453527, -0.633059,
|
||||
-0.570251, -0.655787, -0.791132,
|
||||
-0.802013, -0.956872, -1.094720,
|
||||
-1.208560, -1.207720, -1.339910,
|
||||
-0.693371, -0.795404, -0.803594,
|
||||
-0.945068, -0.464668, -0.631721,
|
||||
-0.458968, -0.547876, -0.332878,
|
||||
-0.485696, -0.286385, -0.408481,
|
||||
0.053021, -0.058200, 0.110846,
|
||||
-0.002086, 0.381384, 0.416784,
|
||||
0.551133, 0.613261, 0.872474,
|
||||
0.901208, 1.038300, 1.084660,
|
||||
0.737459, 0.751250, 0.890002,
|
||||
0.915210, 0.010915, 0.000000,
|
||||
0.951057, 0.951057, 0.587785,
|
||||
1.538840, -0.587785, 0.000000,
|
||||
-0.951057, -1.538840, -0.951057,
|
||||
-0.015847, 0.475529, 0.951057,
|
||||
0.492248, 1.244950, 1.063310,
|
||||
0.274399, 0.293893, -0.293892,
|
||||
-0.296404, -1.063310, -1.244950,
|
||||
-0.453865, -0.951057, -0.475529,
|
||||
0.466620, 0.792932, -0.013913,
|
||||
-0.748783, -0.497528, 0.021382,
|
||||
-0.017158, 0.172591, 0.330125,
|
||||
0.458568, 0.457971, 0.137740,
|
||||
0.299049, 0.588394, 0.667324,
|
||||
0.432341, 0.634346, 0.117322,
|
||||
0.193603, 0.211702, 0.098278,
|
||||
-0.199438, -0.077304, -0.082243,
|
||||
-0.216296, -0.458634, -0.592374,
|
||||
-0.563926, -0.680404, -0.135751,
|
||||
-0.302942, -0.469005, -0.453640,
|
||||
-0.182727, -0.314240, 0.024270,
|
||||
0.021546, 0.158510, 0.317019,
|
||||
0.485799, 0.492951, 0.792548,
|
||||
0.634038, 0.951057, 0.951057,
|
||||
0.777915, 0.613430, 0.951057,
|
||||
0.951057, 0.793994, 0.635800,
|
||||
1.049020, 1.146990, 1.084480,
|
||||
0.924310, 1.440880, 1.342910,
|
||||
1.380330, 1.221820, 0.948209,
|
||||
0.856297, 0.746293, 0.904802,
|
||||
0.476242, 0.393234, 0.489821,
|
||||
0.391857, 0.194471, 0.075751,
|
||||
0.097964, 0.195929, -0.097964,
|
||||
-0.195928, -0.173234, -0.078922,
|
||||
-0.489821, -0.391856, -0.467007,
|
||||
-0.397859, -0.746293, -0.904802,
|
||||
-0.945206, -0.849559, -1.380330,
|
||||
-1.221820, -1.440880, -1.342910,
|
||||
-1.100830, -0.923191, -1.049020,
|
||||
-1.146990, -0.774515, -0.621542,
|
||||
-0.951057, -0.951057, -0.803055,
|
||||
-0.635255, -0.951057, -0.951057,
|
||||
-0.792548, -0.634038, -0.454301,
|
||||
-0.479369, -0.158510, -0.317019,
|
||||
0.149331, 0.178643, 0.295860,
|
||||
0.306275, 0.246225, 0.406610,
|
||||
0.367954, 0.498458, -0.014929,
|
||||
0.084917, -0.094272, -0.000726,
|
||||
-0.245374, -0.340755, -0.435351,
|
||||
-0.490564, -0.176355, -0.294974,
|
||||
-0.148010, -0.328246, 0.136248,
|
||||
0.182883, 0.328957, 0.309903,
|
||||
0.646446, 0.622546, 0.800859,
|
||||
0.801803, 0.643087, 0.654473,
|
||||
0.796963, 0.816799, 0.748189,
|
||||
0.898148, 0.819092, 0.970033,
|
||||
1.049540, 1.162660, 1.115310,
|
||||
1.266700, 0.539960, 0.728396,
|
||||
0.656318, 0.783152, 0.302716,
|
||||
0.403858, 0.219006, 0.309252,
|
||||
0.009667, 0.107161, -0.118211,
|
||||
0.011786, -0.284704, -0.179858,
|
||||
-0.411567, -0.296676, -0.570168,
|
||||
-0.635348, -0.726784, -0.793211,
|
||||
-1.016860, -1.112970, -1.170910,
|
||||
-1.281530, -0.737860, -0.851723,
|
||||
-0.883732, -0.995070, -0.653153,
|
||||
-0.769939, -0.631918, -0.797688,
|
||||
-0.616289, -0.806819, -0.638485,
|
||||
-0.790356, -0.136399, -0.322769,
|
||||
-0.165339, -0.309622]
|
||||
DataCollection/Mesh/PartitionInfo/Size: 2
|
||||
DataCollection/Mesh/PartitionInfo/Type: FMS_UINT64
|
||||
DataCollection/Mesh/PartitionInfo/Values: [0, 1]
|
||||
DataCollection/Mesh/NumDomainNames: 1
|
||||
DataCollection/Mesh/NumComponents: 1
|
||||
DataCollection/Mesh/NumTags: 0
|
||||
DataCollection/Mesh/DomainNames/0/Name: Domain
|
||||
DataCollection/Mesh/DomainNames/0/NumDomains: 1
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Dimension: 2
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/NumVertices: 31
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/0/EntityType: FMS_EDGE
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/0/NumEntities: 50
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/0/Size: 100
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/0/Type: FMS_INT32
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/0/Values: [11, 0, 26,
|
||||
11, 26, 14,
|
||||
14, 0, 27,
|
||||
14, 27, 17,
|
||||
17, 0, 28,
|
||||
17, 28, 20,
|
||||
20, 0, 29,
|
||||
20, 29, 23,
|
||||
23, 0, 30,
|
||||
23, 30, 11,
|
||||
11, 1, 12,
|
||||
1, 26, 12,
|
||||
12, 3, 13,
|
||||
3, 26, 13,
|
||||
13, 2, 14,
|
||||
2, 15, 2,
|
||||
27, 15, 15,
|
||||
5, 16, 5,
|
||||
27, 16, 16,
|
||||
4, 17, 4,
|
||||
18, 4, 28,
|
||||
18, 18, 7,
|
||||
19, 7, 28,
|
||||
19, 19, 6,
|
||||
20, 6, 21,
|
||||
6, 29, 21,
|
||||
21, 9, 22,
|
||||
9, 29, 22,
|
||||
22, 8, 23,
|
||||
8, 24, 8,
|
||||
30, 24, 24,
|
||||
10, 25, 10,
|
||||
30, 25, 25, 1]
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/1/EntityType: FMS_QUADRILATERAL
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/1/NumEntities: 20
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/1/Size: 80
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/1/Type: FMS_INT32
|
||||
DataCollection/Mesh/DomainNames/0/Domains/0/Entities/1/Values: [0, 1, 2,
|
||||
3, 3, 4,
|
||||
5, 6, 6,
|
||||
7, 8, 9,
|
||||
9, 10, 11,
|
||||
12, 12, 13,
|
||||
14, 0, 15,
|
||||
16, 17, 1,
|
||||
17, 18, 19,
|
||||
20, 2, 20,
|
||||
21, 22, 22,
|
||||
23, 24, 4,
|
||||
24, 25, 26,
|
||||
27, 5, 27,
|
||||
28, 29, 29,
|
||||
30, 31, 7,
|
||||
31, 32, 33,
|
||||
34, 8, 34,
|
||||
35, 36, 36,
|
||||
37, 38, 10,
|
||||
38, 39, 40,
|
||||
41, 11, 41,
|
||||
42, 43, 43,
|
||||
44, 45, 13,
|
||||
45, 46, 47,
|
||||
48, 14, 48,
|
||||
49, 15]
|
||||
DataCollection/Mesh/Components/0/Name: volume
|
||||
DataCollection/Mesh/Components/0/Dimension: 2
|
||||
DataCollection/Mesh/Components/0/NumEntities: 20
|
||||
DataCollection/Mesh/Components/0/Coordinates: Coords
|
||||
DataCollection/Mesh/Components/0/NumParts: 1
|
||||
DataCollection/Mesh/Components/0/Parts/0/DomainName: Domain
|
||||
DataCollection/Mesh/Components/0/Parts/0/DomainID: 0
|
||||
DataCollection/Mesh/Components/0/Parts/0/FullDomain: Yes
|
||||
DataCollection/Mesh/Components/0/Relations/Size: 0
|
||||
DataCollection/Mesh/Components/0/Relations/Type: FMS_UINT64
|
||||
@@ -38,7 +38,7 @@ PROJECT_NAME = "MFEM"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = v4.2.1
|
||||
PROJECT_NUMBER = v4.3.1
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
+31
-2
@@ -84,8 +84,9 @@ foreach(SRC_FILE ${ALL_EXE_SRCS})
|
||||
get_filename_component(SRC_FILENAME ${SRC_FILE} NAME)
|
||||
string(REPLACE ".cpp" "" TEST_NAME ${SRC_FILENAME})
|
||||
|
||||
if (NOT (${TEST_NAME} MATCHES "ex0p?"))
|
||||
set(THIS_TEST_OPTIONS "-no-vis")
|
||||
set(THIS_TEST_OPTIONS "-no-vis")
|
||||
if (${TEST_NAME} MATCHES "ex0p?")
|
||||
set(THIS_TEST_OPTIONS)
|
||||
endif()
|
||||
if (${TEST_NAME} MATCHES "ex10p*")
|
||||
list(APPEND THIS_TEST_OPTIONS "-tf" "5")
|
||||
@@ -107,6 +108,34 @@ foreach(SRC_FILE ${ALL_EXE_SRCS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Add CUDA/HIP tests.
|
||||
set(DEVICE_EXAMPLES
|
||||
# serial examples with device support:
|
||||
ex1 ex3 ex4 ex5 ex6 ex9 ex22 ex24 ex25 ex26
|
||||
# parallel examples with device support:
|
||||
ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex9p ex13p ex22p ex24p ex25p ex26p)
|
||||
set(MFEM_TEST_DEVICE)
|
||||
if (MFEM_USE_CUDA)
|
||||
set(MFEM_TEST_DEVICE "cuda")
|
||||
elseif (MFEM_USE_HIP)
|
||||
set(MFEM_TEST_DEVICE "hip")
|
||||
endif()
|
||||
if (MFEM_TEST_DEVICE)
|
||||
foreach(TEST_NAME ${DEVICE_EXAMPLES})
|
||||
set(THIS_TEST_OPTIONS "-no-vis" "-d" "${MFEM_TEST_DEVICE}")
|
||||
if (NOT (${TEST_NAME} MATCHES ".*p$"))
|
||||
add_test(NAME ${TEST_NAME}_${MFEM_TEST_DEVICE}_ser
|
||||
COMMAND ${TEST_NAME} ${THIS_TEST_OPTIONS})
|
||||
elseif (MFEM_USE_MPI)
|
||||
add_test(NAME ${TEST_NAME}_${MFEM_TEST_DEVICE}_np=${MFEM_MPI_NP}
|
||||
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MFEM_MPI_NP}
|
||||
${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:${TEST_NAME}> ${THIS_TEST_OPTIONS}
|
||||
${MPIEXEC_POSTFLAGS})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# If STRUMPACK is enabled, add a test run that uses it.
|
||||
if (MFEM_USE_STRUMPACK)
|
||||
add_test(NAME ex11p_strumpack_np=${MFEM_MPI_NP}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Finite Element Discretization Library
|
||||
__
|
||||
_ __ ___ / _| ___ _ __ ___
|
||||
| '_ ` _ \ | |_ / _ \| '_ ` _ \
|
||||
| | | | | || _|| __/| | | | | |
|
||||
|_| |_| |_||_| \___||_| |_| |_|
|
||||
|
||||
https://mfem.org
|
||||
|
||||
This directory contains modifications of the example codes that illustrate the
|
||||
use of MFEM features based on the Caliper performance profiling library.
|
||||
|
||||
To build these examples, make sure that MFEM is configured with the option
|
||||
"MFEM_USE_CALIPER = YES", see the top-level INSTALL file for details (version
|
||||
2.5.0 of Caliper is recommended, though older versions may work too).
|
||||
|
||||
We recommend comparing the original example codes with the corresponding files
|
||||
in the current directory.
|
||||
+20
-12
@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int nev = 5;
|
||||
bool visualization = 1;
|
||||
const char *device_config = "cpu";
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -71,6 +72,8 @@ int main(int argc, char *argv[])
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
"--no-visualization",
|
||||
"Enable or disable GLVis visualization.");
|
||||
args.AddOption(&device_config, "-d", "--device",
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -86,13 +89,18 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
// 3. Read the (serial) mesh from the given mesh file on all processors. We
|
||||
// 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);
|
||||
if (myid == 0) { device.Print(); }
|
||||
|
||||
// 4. Read the (serial) mesh from the given mesh file on all processors. We
|
||||
// can handle triangular, quadrilateral, tetrahedral, hexahedral, surface
|
||||
// and volume meshes with the same code.
|
||||
Mesh *mesh = new Mesh(mesh_file, 1, 1);
|
||||
int dim = mesh->Dimension();
|
||||
|
||||
// 4. Refine the serial mesh on all processors to increase the resolution. In
|
||||
// 5. Refine the serial mesh on all processors to increase the resolution. In
|
||||
// this example we do 'ref_levels' of uniform refinement (2 by default, or
|
||||
// specified on the command line with -rs).
|
||||
for (int lev = 0; lev < ser_ref_levels; lev++)
|
||||
@@ -100,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
mesh->UniformRefinement();
|
||||
}
|
||||
|
||||
// 5. Define a parallel mesh by a partitioning of the serial mesh. Refine
|
||||
// 6. Define a parallel mesh by a partitioning of the serial mesh. Refine
|
||||
// this mesh further in parallel to increase the resolution (1 time by
|
||||
// default, or specified on the command line with -rp). Once the parallel
|
||||
// mesh is defined, the serial mesh can be deleted.
|
||||
@@ -112,7 +120,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
pmesh->ReorientTetMesh();
|
||||
|
||||
// 6. Define a parallel finite element space on the parallel mesh. Here we
|
||||
// 7. Define a parallel finite element space on the parallel mesh. Here we
|
||||
// use the Nedelec finite elements of the specified order.
|
||||
FiniteElementCollection *fec = new ND_FECollection(order, dim);
|
||||
ParFiniteElementSpace *fespace = new ParFiniteElementSpace(pmesh, fec);
|
||||
@@ -122,7 +130,7 @@ int main(int argc, char *argv[])
|
||||
cout << "Number of unknowns: " << size << endl;
|
||||
}
|
||||
|
||||
// 7. Set up the parallel bilinear forms a(.,.) and m(.,.) on the finite
|
||||
// 8. Set up the parallel bilinear forms a(.,.) and m(.,.) on the finite
|
||||
// element space. The first corresponds to the curl curl, while the second
|
||||
// is a simple mass matrix needed on the right hand side of the
|
||||
// generalized eigenvalue problem below. The boundary conditions are
|
||||
@@ -164,7 +172,7 @@ int main(int argc, char *argv[])
|
||||
delete a;
|
||||
delete m;
|
||||
|
||||
// 8. Define and configure the AME eigensolver and the AMS preconditioner for
|
||||
// 9. Define and configure the AME eigensolver and the AMS preconditioner for
|
||||
// A to be used within the solver. Set the matrices which define the
|
||||
// generalized eigenproblem A x = lambda M x.
|
||||
HypreAMS *ams = new HypreAMS(*A,fespace);
|
||||
@@ -180,15 +188,15 @@ int main(int argc, char *argv[])
|
||||
ame->SetMassMatrix(*M);
|
||||
ame->SetOperator(*A);
|
||||
|
||||
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
ame->Solve();
|
||||
ame->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
// 10. Save the refined mesh and the modes in parallel. This output can be
|
||||
// 11. Save the refined mesh and the modes in parallel. This output can be
|
||||
// viewed later using GLVis: "glvis -np <np> -m mesh -g mode".
|
||||
{
|
||||
ostringstream mesh_name, mode_name;
|
||||
@@ -213,7 +221,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// 11. Send the solution by socket to a GLVis server.
|
||||
// 12. Send the solution by socket to a GLVis server.
|
||||
if (visualization)
|
||||
{
|
||||
char vishost[] = "localhost";
|
||||
@@ -253,7 +261,7 @@ int main(int argc, char *argv[])
|
||||
mode_sock.close();
|
||||
}
|
||||
|
||||
// 12. Free the used memory.
|
||||
// 13. Free the used memory.
|
||||
delete ame;
|
||||
delete ams;
|
||||
delete M;
|
||||
|
||||
+23
-7
@@ -196,6 +196,12 @@ void InitialDeformation(const Vector &x, Vector &y);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef HYPRE_USING_CUDA
|
||||
cout << "\nAs of mfem-4.3 and hypre-2.22.0 (July 2021) this example\n"
|
||||
<< "is NOT supported with the CUDA version of hypre.\n\n";
|
||||
return 255;
|
||||
#endif
|
||||
|
||||
// 1. Initialize MPI
|
||||
MPI_Session mpi;
|
||||
const int myid = mpi.WorldRank();
|
||||
@@ -438,16 +444,20 @@ JacobianPreconditioner::JacobianPreconditioner(Array<ParFiniteElementSpace *>
|
||||
void JacobianPreconditioner::Mult(const Vector &k, Vector &y) const
|
||||
{
|
||||
// Extract the blocks from the input and output vectors
|
||||
Vector disp_in(k.GetData() + block_trueOffsets[0],
|
||||
block_trueOffsets[1]-block_trueOffsets[0]);
|
||||
Vector pres_in(k.GetData() + block_trueOffsets[1],
|
||||
block_trueOffsets[2]-block_trueOffsets[1]);
|
||||
|
||||
Vector disp_out(y.GetData() + block_trueOffsets[0],
|
||||
Vector disp_in;
|
||||
disp_in.MakeRef(const_cast<Vector&>(k), block_trueOffsets[0],
|
||||
block_trueOffsets[1]-block_trueOffsets[0]);
|
||||
Vector pres_out(y.GetData() + block_trueOffsets[1],
|
||||
Vector pres_in;
|
||||
pres_in.MakeRef(const_cast<Vector&>(k), block_trueOffsets[1],
|
||||
block_trueOffsets[2]-block_trueOffsets[1]);
|
||||
|
||||
Vector disp_out;
|
||||
disp_out.MakeRef(y, block_trueOffsets[0],
|
||||
block_trueOffsets[1]-block_trueOffsets[0]);
|
||||
Vector pres_out;
|
||||
pres_out.MakeRef(y, block_trueOffsets[1],
|
||||
block_trueOffsets[2]-block_trueOffsets[1]);
|
||||
|
||||
Vector temp(block_trueOffsets[1]-block_trueOffsets[0]);
|
||||
Vector temp2(block_trueOffsets[1]-block_trueOffsets[0]);
|
||||
|
||||
@@ -459,6 +469,9 @@ void JacobianPreconditioner::Mult(const Vector &k, Vector &y) const
|
||||
subtract(disp_in, temp, temp2);
|
||||
|
||||
stiff_pcg->Mult(temp2, disp_out);
|
||||
|
||||
disp_out.SyncAliasMemory(y);
|
||||
pres_out.SyncAliasMemory(y);
|
||||
}
|
||||
|
||||
void JacobianPreconditioner::SetOperator(const Operator &op)
|
||||
@@ -473,7 +486,10 @@ void JacobianPreconditioner::SetOperator(const Operator &op)
|
||||
|
||||
if (!spaces[0]->GetParMesh()->Nonconforming())
|
||||
{
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
// Not available yet when hypre is built with CUDA
|
||||
stiff_prec_amg->SetElasticityOptions(spaces[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
stiff_prec = stiff_prec_amg;
|
||||
|
||||
+7
-6
@@ -89,7 +89,8 @@ int main(int argc, char *argv[])
|
||||
args.AddOption(&device_config, "-d", "--device",
|
||||
"Device configuration string, see Device::Configure().");
|
||||
#ifdef MFEM_USE_CEED
|
||||
args.AddOption(&algebraic_ceed, "-a", "--algebraic", "-no-a", "--no-algebraic",
|
||||
args.AddOption(&algebraic_ceed, "-a", "--algebraic",
|
||||
"-no-a", "--no-algebraic",
|
||||
"Use algebraic Ceed solver");
|
||||
#endif
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
@@ -197,15 +198,15 @@ int main(int argc, char *argv[])
|
||||
b.AddDomainIntegrator(new DomainLFIntegrator(one));
|
||||
b.Assemble();
|
||||
|
||||
// 10. Define the solution vector x as a parallel finite element grid function
|
||||
// corresponding to fespace. Initialize x with initial guess of zero,
|
||||
// which satisfies the boundary conditions.
|
||||
// 10. Define the solution vector x as a parallel finite element grid
|
||||
// function corresponding to fespace. Initialize x with initial guess of
|
||||
// zero, which satisfies the boundary conditions.
|
||||
ParGridFunction x(&fespace);
|
||||
x = 0.0;
|
||||
|
||||
// 11. Set up the parallel bilinear form a(.,.) on the finite element space
|
||||
// corresponding to the Laplacian operator -Delta, by adding the Diffusion
|
||||
// domain integrator.
|
||||
// corresponding to the Laplacian operator -Delta, by adding the
|
||||
// Diffusion domain integrator.
|
||||
ParBilinearForm a(&fespace);
|
||||
if (pa) { a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
|
||||
a.AddDomainIntegrator(new DiffusionIntegrator(one));
|
||||
|
||||
@@ -81,6 +81,12 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef HYPRE_USING_CUDA
|
||||
cout << "\nAs of mfem-4.3 and hypre-2.22.0 (July 2021) this example\n"
|
||||
<< "is NOT supported with the CUDA version of hypre.\n\n";
|
||||
return 255;
|
||||
#endif
|
||||
|
||||
// 1. Initialize MPI.
|
||||
int num_procs, myid;
|
||||
MPI_Init(&argc, &argv);
|
||||
@@ -360,6 +366,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
delete pmesh;
|
||||
|
||||
// HYPRE_Finalize();
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
|
||||
+31
-23
@@ -61,6 +61,7 @@ int main(int argc, char *argv[])
|
||||
bool visualization = 1;
|
||||
bool amg_elast = 0;
|
||||
bool reorder_space = false;
|
||||
const char *device_config = "cpu";
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -78,6 +79,8 @@ int main(int argc, char *argv[])
|
||||
"Enable or disable GLVis visualization.");
|
||||
args.AddOption(&reorder_space, "-nodes", "--by-nodes", "-vdim", "--by-vdim",
|
||||
"Use byNODES ordering of vector space instead of byVDIM");
|
||||
args.AddOption(&device_config, "-d", "--device",
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -93,7 +96,12 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
// 3. Read the (serial) mesh from the given mesh file on all processors. We
|
||||
// 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);
|
||||
if (myid == 0) { device.Print(); }
|
||||
|
||||
// 4. Read the (serial) mesh from the given mesh file on all processors. We
|
||||
// can handle triangular, quadrilateral, tetrahedral, hexahedral, surface
|
||||
// and volume meshes with the same code.
|
||||
Mesh *mesh = new Mesh(mesh_file, 1, 1);
|
||||
@@ -109,14 +117,14 @@ int main(int argc, char *argv[])
|
||||
return 3;
|
||||
}
|
||||
|
||||
// 4. Select the order of the finite element discretization space. For NURBS
|
||||
// 5. Select the order of the finite element discretization space. For NURBS
|
||||
// meshes, we increase the order by degree elevation.
|
||||
if (mesh->NURBSext)
|
||||
{
|
||||
mesh->DegreeElevate(order, order);
|
||||
}
|
||||
|
||||
// 5. Refine the serial mesh on all processors to increase the resolution. In
|
||||
// 6. Refine the serial mesh on all processors to increase the resolution. In
|
||||
// this example we do 'ref_levels' of uniform refinement. We choose
|
||||
// 'ref_levels' to be the largest number that gives a final mesh with no
|
||||
// more than 1,000 elements.
|
||||
@@ -129,7 +137,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Define a parallel mesh by a partitioning of the serial mesh. Refine
|
||||
// 7. Define a parallel mesh by a partitioning of the serial mesh. Refine
|
||||
// this mesh further in parallel to increase the resolution. Once the
|
||||
// parallel mesh is defined, the serial mesh can be deleted.
|
||||
ParMesh *pmesh = new ParMesh(MPI_COMM_WORLD, *mesh);
|
||||
@@ -142,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Define a parallel finite element space on the parallel mesh. Here we
|
||||
// 8. Define a parallel finite element space on the parallel mesh. Here we
|
||||
// use vector finite elements, i.e. dim copies of a scalar finite element
|
||||
// space. We use the ordering by vector dimension (the last argument of
|
||||
// the FiniteElementSpace constructor) which is expected in the systems
|
||||
@@ -175,7 +183,7 @@ int main(int argc, char *argv[])
|
||||
<< "Assembling: " << flush;
|
||||
}
|
||||
|
||||
// 8. Determine the list of true (i.e. parallel conforming) essential
|
||||
// 9. Determine the list of true (i.e. parallel conforming) essential
|
||||
// boundary dofs. In this example, the boundary conditions are defined by
|
||||
// marking only boundary attribute 1 from the mesh as essential and
|
||||
// converting it to a list of true dofs.
|
||||
@@ -184,14 +192,14 @@ int main(int argc, char *argv[])
|
||||
ess_bdr[0] = 1;
|
||||
fespace->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
|
||||
|
||||
// 9. Set up the parallel linear form b(.) which corresponds to the
|
||||
// right-hand side of the FEM linear system. In this case, b_i equals the
|
||||
// boundary integral of f*phi_i where f represents a "pull down" force on
|
||||
// the Neumann part of the boundary and phi_i are the basis functions in
|
||||
// the finite element fespace. The force is defined by the object f, which
|
||||
// is a vector of Coefficient objects. The fact that f is non-zero on
|
||||
// boundary attribute 2 is indicated by the use of piece-wise constants
|
||||
// coefficient for its last component.
|
||||
// 10. Set up the parallel linear form b(.) which corresponds to the
|
||||
// right-hand side of the FEM linear system. In this case, b_i equals the
|
||||
// boundary integral of f*phi_i where f represents a "pull down" force on
|
||||
// the Neumann part of the boundary and phi_i are the basis functions in
|
||||
// the finite element fespace. The force is defined by the object f, which
|
||||
// is a vector of Coefficient objects. The fact that f is non-zero on
|
||||
// boundary attribute 2 is indicated by the use of piece-wise constants
|
||||
// coefficient for its last component.
|
||||
VectorArrayCoefficient f(dim);
|
||||
for (int i = 0; i < dim-1; i++)
|
||||
{
|
||||
@@ -212,13 +220,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
b->Assemble();
|
||||
|
||||
// 10. Define the solution vector x as a parallel finite element grid
|
||||
// 11. Define the solution vector x as a parallel finite element grid
|
||||
// function corresponding to fespace. Initialize x with initial guess of
|
||||
// zero, which satisfies the boundary conditions.
|
||||
ParGridFunction x(fespace);
|
||||
x = 0.0;
|
||||
|
||||
// 11. Set up the parallel bilinear form a(.,.) on the finite element space
|
||||
// 12. Set up the parallel bilinear form a(.,.) on the finite element space
|
||||
// corresponding to the linear elasticity integrator with piece-wise
|
||||
// constants coefficient lambda and mu.
|
||||
Vector lambda(pmesh->attributes.Max());
|
||||
@@ -233,7 +241,7 @@ int main(int argc, char *argv[])
|
||||
ParBilinearForm *a = new ParBilinearForm(fespace);
|
||||
a->AddDomainIntegrator(new ElasticityIntegrator(lambda_func, mu_func));
|
||||
|
||||
// 12. Assemble the parallel bilinear form and the corresponding linear
|
||||
// 13. Assemble the parallel bilinear form and the corresponding linear
|
||||
// system, applying any necessary transformations such as: parallel
|
||||
// assembly, eliminating boundary conditions, applying conforming
|
||||
// constraints for non-conforming AMR, static condensation, etc.
|
||||
@@ -250,7 +258,7 @@ int main(int argc, char *argv[])
|
||||
cout << "Size of linear system: " << A.GetGlobalNumRows() << endl;
|
||||
}
|
||||
|
||||
// 13. Define and apply a parallel PCG solver for A X = B with the BoomerAMG
|
||||
// 14. Define and apply a parallel PCG solver for A X = B with the BoomerAMG
|
||||
// preconditioner from hypre.
|
||||
HypreBoomerAMG *amg = new HypreBoomerAMG(A);
|
||||
if (amg_elast && !a->StaticCondensationIsEnabled())
|
||||
@@ -268,11 +276,11 @@ int main(int argc, char *argv[])
|
||||
pcg->SetPreconditioner(*amg);
|
||||
pcg->Mult(B, X);
|
||||
|
||||
// 14. Recover the parallel grid function corresponding to X. This is the
|
||||
// 15. Recover the parallel grid function corresponding to X. This is the
|
||||
// local finite element solution on each processor.
|
||||
a->RecoverFEMSolution(X, *b, x);
|
||||
|
||||
// 15. For non-NURBS meshes, make the mesh curved based on the finite element
|
||||
// 16. For non-NURBS meshes, make the mesh curved based on the finite element
|
||||
// space. This means that we define the mesh elements through a fespace
|
||||
// based transformation of the reference element. This allows us to save
|
||||
// the displaced mesh as a curved mesh when using high-order finite
|
||||
@@ -284,7 +292,7 @@ int main(int argc, char *argv[])
|
||||
pmesh->SetNodalFESpace(fespace);
|
||||
}
|
||||
|
||||
// 16. Save in parallel the displaced mesh and the inverted solution (which
|
||||
// 17. Save in parallel the displaced mesh and the inverted solution (which
|
||||
// gives the backward displacements to the original grid). This output
|
||||
// can be viewed later using GLVis: "glvis -np <np> -m mesh -g sol".
|
||||
{
|
||||
@@ -305,7 +313,7 @@ int main(int argc, char *argv[])
|
||||
x.Save(sol_ofs);
|
||||
}
|
||||
|
||||
// 17. Send the above data by socket to a GLVis server. Use the "n" and "b"
|
||||
// 18. Send the above data by socket to a GLVis server. Use the "n" and "b"
|
||||
// keys in GLVis to visualize the displacements.
|
||||
if (visualization)
|
||||
{
|
||||
@@ -317,7 +325,7 @@ int main(int argc, char *argv[])
|
||||
sol_sock << "solution\n" << *pmesh << x << flush;
|
||||
}
|
||||
|
||||
// 18. Free the used memory.
|
||||
// 19. Free the used memory.
|
||||
delete pcg;
|
||||
delete amg;
|
||||
delete a;
|
||||
|
||||
@@ -103,6 +103,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
args.PrintUsage(cout);
|
||||
}
|
||||
// HYPRE_Finalize();
|
||||
MPI_Finalize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
+11
-3
@@ -197,6 +197,7 @@ int main(int argc, char *argv[])
|
||||
SparseMatrix &M(mVarf->SpMat());
|
||||
SparseMatrix &B(bVarf->SpMat());
|
||||
B *= -1.;
|
||||
if (Device::IsEnabled()) { B.BuildTranspose(); }
|
||||
Bt = new TransposeOperator(&B);
|
||||
|
||||
darcyOp.SetBlock(0,0, &M);
|
||||
@@ -240,6 +241,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
SparseMatrix &M(mVarf->SpMat());
|
||||
M.GetDiag(Md);
|
||||
Md.HostReadWrite();
|
||||
|
||||
SparseMatrix &B(bVarf->SpMat());
|
||||
MinvBt = Transpose(B);
|
||||
@@ -287,12 +289,18 @@ int main(int argc, char *argv[])
|
||||
chrono.Stop();
|
||||
|
||||
if (solver.GetConverged())
|
||||
{
|
||||
std::cout << "MINRES converged in " << solver.GetNumIterations()
|
||||
<< " iterations with a residual norm of " << solver.GetFinalNorm() << ".\n";
|
||||
<< " iterations with a residual norm of "
|
||||
<< solver.GetFinalNorm() << ".\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "MINRES did not converge in " << solver.GetNumIterations()
|
||||
<< " iterations. Residual norm is " << solver.GetFinalNorm() << ".\n";
|
||||
std::cout << "MINRES solver took " << chrono.RealTime() << "s. \n";
|
||||
<< " iterations. Residual norm is " << solver.GetFinalNorm()
|
||||
<< ".\n";
|
||||
}
|
||||
std::cout << "MINRES solver took " << chrono.RealTime() << "s.\n";
|
||||
|
||||
// 12. Create the grid functions u and p. Compute the L2 error norms.
|
||||
GridFunction u, p;
|
||||
|
||||
+21
-13
@@ -47,6 +47,7 @@ int main(int argc, char *argv[])
|
||||
int order = 2;
|
||||
bool always_snap = false;
|
||||
bool visualization = 1;
|
||||
const char *device_config = "cpu";
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&elem_type, "-e", "--elem",
|
||||
@@ -65,6 +66,8 @@ int main(int argc, char *argv[])
|
||||
"--snap-at-the-end",
|
||||
"If true, snap nodes to the sphere initially and after each refinement "
|
||||
"otherwise, snap only after the last refinement");
|
||||
args.AddOption(&device_config, "-d", "--device",
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -80,7 +83,12 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
// 3. Generate an initial high-order (surface) mesh on the unit sphere. The
|
||||
// 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);
|
||||
if (myid == 0) { device.Print(); }
|
||||
|
||||
// 4. Generate an initial high-order (surface) mesh on the unit sphere. The
|
||||
// Mesh object represents a 2D mesh in 3 spatial dimensions. We first add
|
||||
// the elements and the vertices of the mesh, and then make it high-order
|
||||
// by specifying a finite element space for its nodes.
|
||||
@@ -146,7 +154,7 @@ int main(int argc, char *argv[])
|
||||
FiniteElementSpace nodal_fes(mesh, &fec, mesh->SpaceDimension());
|
||||
mesh->SetNodalFESpace(&nodal_fes);
|
||||
|
||||
// 4. Refine the mesh while snapping nodes to the sphere. Number of parallel
|
||||
// 5. Refine the mesh while snapping nodes to the sphere. Number of parallel
|
||||
// refinements is fixed to 2.
|
||||
for (int l = 0; l <= ref_levels; l++)
|
||||
{
|
||||
@@ -218,7 +226,7 @@ int main(int argc, char *argv[])
|
||||
SnapNodes(*pmesh);
|
||||
}
|
||||
|
||||
// 5. Define a finite element space on the mesh. Here we use isoparametric
|
||||
// 6. Define a finite element space on the mesh. Here we use isoparametric
|
||||
// finite elements -- the same as the mesh nodes.
|
||||
ParFiniteElementSpace *fespace = new ParFiniteElementSpace(pmesh, &fec);
|
||||
HYPRE_BigInt size = fespace->GlobalTrueVSize();
|
||||
@@ -227,7 +235,7 @@ int main(int argc, char *argv[])
|
||||
cout << "Number of unknowns: " << size << endl;
|
||||
}
|
||||
|
||||
// 6. Set up the linear form b(.) which corresponds to the right-hand side of
|
||||
// 7. Set up the linear form b(.) which corresponds to the right-hand side of
|
||||
// the FEM linear system, which in this case is (1,phi_i) where phi_i are
|
||||
// the basis functions in the finite element fespace.
|
||||
ParLinearForm *b = new ParLinearForm(fespace);
|
||||
@@ -237,27 +245,27 @@ int main(int argc, char *argv[])
|
||||
b->AddDomainIntegrator(new DomainLFIntegrator(rhs_coef));
|
||||
b->Assemble();
|
||||
|
||||
// 7. Define the solution vector x as a finite element grid function
|
||||
// 8. Define the solution vector x as a finite element grid function
|
||||
// corresponding to fespace. Initialize x with initial guess of zero.
|
||||
ParGridFunction x(fespace);
|
||||
x = 0.0;
|
||||
|
||||
// 8. Set up the bilinear form a(.,.) on the finite element space
|
||||
// 9. Set up the bilinear form a(.,.) on the finite element space
|
||||
// corresponding to the Laplacian operator -Delta, by adding the Diffusion
|
||||
// and Mass domain integrators.
|
||||
ParBilinearForm *a = new ParBilinearForm(fespace);
|
||||
a->AddDomainIntegrator(new DiffusionIntegrator(one));
|
||||
a->AddDomainIntegrator(new MassIntegrator(one));
|
||||
|
||||
// 9. Assemble the parallel linear system, applying any transformations
|
||||
// such as: parallel assembly, applying conforming constraints, etc.
|
||||
// 10. Assemble the parallel linear system, applying any transformations
|
||||
// such as: parallel assembly, applying conforming constraints, etc.
|
||||
a->Assemble();
|
||||
HypreParMatrix A;
|
||||
Vector B, X;
|
||||
Array<int> empty_tdof_list;
|
||||
a->FormLinearSystem(empty_tdof_list, x, *b, A, X, B);
|
||||
|
||||
// 10. Define and apply a parallel PCG solver for AX=B with the BoomerAMG
|
||||
// 11. Define and apply a parallel PCG solver for AX=B with the BoomerAMG
|
||||
// preconditioner from hypre. Extract the parallel grid function x
|
||||
// corresponding to the finite element approximation X. This is the local
|
||||
// solution on each processor.
|
||||
@@ -273,14 +281,14 @@ int main(int argc, char *argv[])
|
||||
delete a;
|
||||
delete b;
|
||||
|
||||
// 11. Compute and print the L^2 norm of the error.
|
||||
// 12. Compute and print the L^2 norm of the error.
|
||||
double err = x.ComputeL2Error(sol_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\nL2 norm of error: " << err << endl;
|
||||
}
|
||||
|
||||
// 12. Save the refined mesh and the solution. This output can be viewed
|
||||
// 13. Save the refined mesh and the solution. This output can be viewed
|
||||
// later using GLVis: "glvis -np <np> -m sphere_refined -g sol".
|
||||
{
|
||||
ostringstream mesh_name, sol_name;
|
||||
@@ -296,7 +304,7 @@ int main(int argc, char *argv[])
|
||||
x.Save(sol_ofs);
|
||||
}
|
||||
|
||||
// 13. Send the solution by socket to a GLVis server.
|
||||
// 14. Send the solution by socket to a GLVis server.
|
||||
if (visualization)
|
||||
{
|
||||
char vishost[] = "localhost";
|
||||
@@ -307,7 +315,7 @@ int main(int argc, char *argv[])
|
||||
sol_sock << "solution\n" << *pmesh << x << flush;
|
||||
}
|
||||
|
||||
// 14. Free the used memory.
|
||||
// 15. Free the used memory.
|
||||
delete pcg;
|
||||
delete amg;
|
||||
delete fespace;
|
||||
|
||||
@@ -26,6 +26,9 @@ SEQ_EXAMPLES = ex0 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex14 ex15 ex16 \
|
||||
PAR_EXAMPLES = ex0p ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex8p ex9p ex10p ex11p \
|
||||
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \
|
||||
ex25p ex26p ex27p ex28p ex29p
|
||||
SEQ_DEVICE_EXAMPLES = ex1 ex3 ex4 ex5 ex6 ex9 ex22 ex24 ex25 ex26
|
||||
PAR_DEVICE_EXAMPLES = ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex9p ex13p ex22p \
|
||||
ex24p ex25p ex26p
|
||||
|
||||
ifeq ($(MFEM_USE_MPI),NO)
|
||||
EXAMPLES = $(SEQ_EXAMPLES)
|
||||
@@ -99,6 +102,14 @@ RUN_MPI = $(MFEM_MPIEXEC) $(MFEM_MPIEXEC_NP) $(MFEM_MPI_NP)
|
||||
@$(call mfem-test,$<, $(RUN_MPI), Parallel example)
|
||||
%-test-seq: %
|
||||
@$(call mfem-test,$<,, Serial example)
|
||||
%-test-par-cuda: %
|
||||
@$(call mfem-test,$<, $(RUN_MPI), Parallel CUDA example,-d cuda)
|
||||
%-test-seq-cuda: %
|
||||
@$(call mfem-test,$<,, Serial CUDA example,-d cuda)
|
||||
%-test-par-hip: %
|
||||
@$(call mfem-test,$<, $(RUN_MPI), Parallel HIP example,-d hip)
|
||||
%-test-seq-hip: %
|
||||
@$(call mfem-test,$<,, Serial HIP example,-d hip)
|
||||
|
||||
# Testing: Specific execution options
|
||||
ex0-test-seq: ex0
|
||||
|
||||
@@ -282,6 +282,10 @@ int main(int argc, char *argv[])
|
||||
superlu->SetOperator(*SLU_A);
|
||||
superlu->SetPrintStatistics(true);
|
||||
superlu->Mult(B, X);
|
||||
superlu->DismantleGrid();
|
||||
|
||||
delete SLU_A;
|
||||
delete superlu;
|
||||
|
||||
// 14. Recover the parallel grid function corresponding to X. This is the
|
||||
// local finite element solution on each processor.
|
||||
|
||||
@@ -105,6 +105,7 @@ set(SRCS
|
||||
tmop/tmop_pa_w3.cpp
|
||||
tmop/tmop_pa_w3_c0.cpp
|
||||
tmop_tools.cpp
|
||||
tmop_amr.cpp
|
||||
gslib.cpp
|
||||
transfer.cpp
|
||||
lor.cpp
|
||||
@@ -164,6 +165,7 @@ set(HDRS
|
||||
tmop.hpp
|
||||
tmop/tmop_pa.hpp
|
||||
tmop_tools.hpp
|
||||
tmop_amr.hpp
|
||||
gslib.hpp
|
||||
transfer.hpp
|
||||
lor.hpp
|
||||
@@ -184,6 +186,11 @@ if (MFEM_USE_ADIOS2)
|
||||
list(APPEND HDRS adios2datacollection.hpp)
|
||||
endif()
|
||||
|
||||
if (MFEM_USE_FMS)
|
||||
list(APPEND SRCS fmsdatacollection.cpp fmsconvert.cpp)
|
||||
list(APPEND HDRS fmsdatacollection.hpp fmsconvert.hpp)
|
||||
endif()
|
||||
|
||||
if (MFEM_USE_MPI)
|
||||
list(APPEND SRCS
|
||||
pbilinearform.cpp
|
||||
|
||||
@@ -725,8 +725,8 @@ void BilinearForm::FormLinearSystem(const Array<int> &ess_tdof_list, Vector &x,
|
||||
{
|
||||
// A, X and B point to the same data as mat, x and b
|
||||
EliminateVDofsInRHS(ess_tdof_list, x, b);
|
||||
X.NewMemoryAndSize(x.GetMemory(), x.Size(), false);
|
||||
B.NewMemoryAndSize(b.GetMemory(), b.Size(), false);
|
||||
X.MakeRef(x, 0, x.Size());
|
||||
B.MakeRef(b, 0, b.Size());
|
||||
if (!copy_interior) { X.SetSubVectorComplement(ess_tdof_list, 0.0); }
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -711,7 +711,7 @@ protected:
|
||||
{
|
||||
return "MixedScalarDerivativeIntegrator: "
|
||||
"Trial and test spaces must both be scalar fields in 1D "
|
||||
"and the trial space must implement CaldDShape.";
|
||||
"and the trial space must implement CalcDShape.";
|
||||
}
|
||||
|
||||
inline virtual void CalcTrialShape(const FiniteElement & trial_fe,
|
||||
@@ -2936,11 +2936,11 @@ public:
|
||||
|
||||
- F. Bassi and S. Rebay. A high order discontinuous Galerkin method for
|
||||
compressible turbulent flows. In B. Cockburn, G. E. Karniadakis, and
|
||||
C.-W. Shu, editors, Discontinuous Galerkin Methods, pages 77–88. Springer
|
||||
C.-W. Shu, editors, Discontinuous Galerkin Methods, pages 77-88. Springer
|
||||
Berlin Heidelberg, 2000.
|
||||
- D. N. Arnold, F. Brezzi, B. Cockburn, and L. D. Marini. Unified analysis
|
||||
of discontinuous Galerkin methods for elliptic problems. SIAM Journal on
|
||||
Numerical Analysis, 39(5):1749–1779, 2002.
|
||||
Numerical Analysis, 39(5):1749-1779, 2002.
|
||||
*/
|
||||
class DGDiffusionBR2Integrator : public BilinearFormIntegrator
|
||||
{
|
||||
|
||||
+14
-1
@@ -1204,17 +1204,30 @@ ParSesquilinearForm::FormLinearSystem(const Array<int> &ess_tdof_list,
|
||||
});
|
||||
// Modify offdiagonal blocks (imaginary parts of the matrix) to conform
|
||||
// with standard essential BC treatment
|
||||
ess_tdof_list.HostRead();
|
||||
if (A_i.Type() == Operator::Hypre_ParCSR)
|
||||
{
|
||||
HypreParMatrix * Ah;
|
||||
A_i.Get(Ah);
|
||||
hypre_ParCSRMatrix *Aih = *Ah;
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
ess_tdof_list.HostRead();
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
const int j = ess_tdof_list[k];
|
||||
Aih->diag->data[Aih->diag->i[j]] = 0.0;
|
||||
}
|
||||
#else
|
||||
Ah->HypreReadWrite();
|
||||
const int *d_ess_tdof_list =
|
||||
ess_tdof_list.GetMemory().Read(MemoryClass::DEVICE, n);
|
||||
const int *d_diag_i = Aih->diag->i;
|
||||
double *d_diag_data = Aih->diag->data;
|
||||
CuWrap1D(n, [=] MFEM_DEVICE (int k)
|
||||
{
|
||||
const int j = d_ess_tdof_list[k];
|
||||
d_diag_data[d_diag_i[j]] = 0.0;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ public:
|
||||
|
||||
/// Set the desired print level, useful for debugging.
|
||||
/** The valid options are: -1 - never print (default); 0 - print only errors;
|
||||
1 - print the first and last last iterations; 2 - print every iteration;
|
||||
1 - print the first and last iterations; 2 - print every iteration;
|
||||
and 3 - print every iteration including point coordinates. */
|
||||
void SetPrintLevel(int pr_level) { print_level = pr_level; }
|
||||
|
||||
|
||||
@@ -495,6 +495,7 @@ void ScalarFiniteElement::ScalarLocalRestriction(
|
||||
R *= 1.0 / Trans.Weight();
|
||||
}
|
||||
}
|
||||
|
||||
const DofToQuad &ScalarFiniteElement::GetDofToQuad(const IntegrationRule &ir,
|
||||
DofToQuad::Mode mode) const
|
||||
{
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ public:
|
||||
{
|
||||
"Gauss-Legendre", "Gauss-Lobatto", "Positive (Bernstein)",
|
||||
"Open uniform", "Closed uniform", "Open half uniform",
|
||||
"Seredipity", "Closed Gauss-Legendre",
|
||||
"Serendipity", "Closed Gauss-Legendre",
|
||||
"Integrated Gauss-Lobatto indicator"
|
||||
};
|
||||
return name[Check(b_type)];
|
||||
@@ -1126,7 +1126,7 @@ public:
|
||||
{ dofs = 1.0; }
|
||||
};
|
||||
|
||||
/// A 1D quadractic finite element with uniformly spaced nodes
|
||||
/// A 1D quadratic finite element with uniformly spaced nodes
|
||||
class Quad1DFiniteElement : public NodalFiniteElement
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "staticcond.hpp"
|
||||
#include "tmop.hpp"
|
||||
#include "tmop_tools.hpp"
|
||||
#include "tmop_amr.hpp"
|
||||
#include "gslib.hpp"
|
||||
#include "restriction.hpp"
|
||||
#include "quadinterpolator.hpp"
|
||||
@@ -64,4 +65,9 @@
|
||||
#include "adios2datacollection.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef MFEM_USE_FMS
|
||||
#include "fmsconvert.hpp"
|
||||
#include "fmsdatacollection.hpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+1967
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2010-2021, 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.
|
||||
|
||||
#ifndef FMS_CONVERT
|
||||
#define FMS_CONVERT
|
||||
|
||||
#include "../config/config.hpp"
|
||||
#include "datacollection.hpp"
|
||||
|
||||
#ifdef MFEM_USE_FMS
|
||||
#include <fms.h>
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
/** In-memory conversion of FMS data collection to an MFEM data collection.
|
||||
@param dc The FMS data collection to convert.
|
||||
@param[out] mfem_dc A pointer to a new MFEM DataCollection containing the
|
||||
FMS data.
|
||||
@return 0 on success; non-zero on failure.
|
||||
*/
|
||||
int FmsDataCollectionToDataCollection(FmsDataCollection dc,
|
||||
DataCollection **mfem_dc);
|
||||
|
||||
/** In-memory conversion of MFEM data collection to an FMS data collection.
|
||||
@param mfem_dc The MFEM data collection to convert.
|
||||
@param[out] dc A pointer to a new FmsDataCollection containing the MFEM
|
||||
data.
|
||||
@return 0 on success; non-zero on failure.
|
||||
*/
|
||||
int DataCollectionToFmsDataCollection(DataCollection *mfem_dc,
|
||||
FmsDataCollection *dc);
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
// Copyright (c) 2010-2021, 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 "../config/config.hpp"
|
||||
|
||||
#ifdef MFEM_USE_FMS
|
||||
|
||||
#include "fem.hpp"
|
||||
#include "../general/text.hpp"
|
||||
|
||||
#include <fmsio.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
// class FMSDataCollection implementation
|
||||
|
||||
FMSDataCollection::FMSDataCollection(const std::string& coll_name,
|
||||
Mesh *mesh)
|
||||
: DataCollection(coll_name, mesh),
|
||||
fms_protocol("ascii")
|
||||
{
|
||||
appendRankToFileName = false; // always include rank in file names
|
||||
cycle = 0; // always include cycle in directory names
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
FMSDataCollection::FMSDataCollection(MPI_Comm comm,
|
||||
const std::string& coll_name,
|
||||
Mesh *mesh)
|
||||
: DataCollection(coll_name, mesh),
|
||||
fms_protocol("ascii")
|
||||
{
|
||||
m_comm = comm;
|
||||
MPI_Comm_rank(comm, &myid);
|
||||
MPI_Comm_size(comm, &num_procs);
|
||||
appendRankToFileName = true; // always include rank in file names
|
||||
cycle = 0; // always include cycle in directory names
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
FMSDataCollection::~FMSDataCollection()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
void FMSDataCollection::Save()
|
||||
{
|
||||
// Convert this to FmsDataCollection.
|
||||
|
||||
FmsDataCollection dc;
|
||||
if (DataCollectionToFmsDataCollection(this, &dc) == 0)
|
||||
{
|
||||
std::string root(RootFileName());
|
||||
int err = FmsIOWrite(root.c_str(), fms_protocol.c_str(), dc);
|
||||
FmsDataCollectionDestroy(&dc);
|
||||
if (err)
|
||||
{
|
||||
MFEM_ABORT("Error creating FMS file: " << root);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_ABORT("Error converting data collection");
|
||||
}
|
||||
}
|
||||
|
||||
void FMSDataCollection::Load(int cycle)
|
||||
{
|
||||
DeleteAll();
|
||||
this->cycle = cycle;
|
||||
|
||||
FmsDataCollection dc;
|
||||
std::string root(RootFileName());
|
||||
int err = FmsIORead(root.c_str(), fms_protocol.c_str(), &dc);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
DataCollection *mdc = nullptr;
|
||||
if (FmsDataCollectionToDataCollection(dc,&mdc) == 0)
|
||||
{
|
||||
// Tell the data collection we read that it does not own data.
|
||||
// We will steal its data.
|
||||
mdc->SetOwnData(false);
|
||||
|
||||
SetCycle(mdc->GetCycle());
|
||||
SetTime(mdc->GetTime());
|
||||
SetTimeStep(mdc->GetTimeStep());
|
||||
name = mdc->GetCollectionName();
|
||||
|
||||
// Set mdc's mesh as our mesh.
|
||||
SetMesh(mdc->GetMesh());
|
||||
|
||||
// Set mdc's fields/qfields as ours.
|
||||
std::vector<std::string> names;
|
||||
for (const auto &pair : mdc->GetFieldMap())
|
||||
{
|
||||
names.push_back(pair.first);
|
||||
RegisterField(pair.first, pair.second);
|
||||
}
|
||||
for (const auto &name : names)
|
||||
{
|
||||
mdc->DeregisterField(name);
|
||||
}
|
||||
|
||||
names.clear();
|
||||
for (const auto &pair : mdc->GetQFieldMap())
|
||||
{
|
||||
names.push_back(pair.first);
|
||||
RegisterQField(pair.first, pair.second);
|
||||
}
|
||||
for (const auto &name : names)
|
||||
{
|
||||
mdc->DeregisterField(name);
|
||||
}
|
||||
|
||||
// Indicate that we own the data.
|
||||
SetOwnData(true);
|
||||
|
||||
// Delete mdc. We stole its contents.
|
||||
delete mdc;
|
||||
}
|
||||
FmsDataCollectionDestroy(&dc);
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_ABORT("Error reading data collection: " << root);
|
||||
}
|
||||
}
|
||||
|
||||
void FMSDataCollection::SetProtocol(const std::string &protocol)
|
||||
{
|
||||
fms_protocol = protocol;
|
||||
}
|
||||
|
||||
std::string FMSDataCollection::RootFileName()
|
||||
{
|
||||
std::string res;
|
||||
if (pad_digits_cycle)
|
||||
{
|
||||
res = prefix_path + name + "_" +
|
||||
to_padded_string(cycle, pad_digits_cycle) +
|
||||
".fms";
|
||||
}
|
||||
else
|
||||
{
|
||||
res = prefix_path + name + ".fms";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2010-2021, 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.
|
||||
|
||||
#ifndef MFEM_FMSDATACOLLECTION
|
||||
#define MFEM_FMSDATACOLLECTION
|
||||
|
||||
#include "../config/config.hpp"
|
||||
|
||||
#ifdef MFEM_USE_FMS
|
||||
|
||||
#include "datacollection.hpp"
|
||||
#include <fms.h>
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
/** @brief Data collection that uses FMS. */
|
||||
/** FMSDataCollection lets MFEM read/write data using FMS.
|
||||
|
||||
For more information, see:
|
||||
- FMS project, https://ceed.exascaleproject.org/fms/
|
||||
*/
|
||||
|
||||
/// Data collection with FMS I/O routines
|
||||
class FMSDataCollection : public DataCollection
|
||||
{
|
||||
protected:
|
||||
// file name helpers
|
||||
|
||||
/// Returns file name for the current cycle
|
||||
std::string RootFileName();
|
||||
|
||||
// holds currently active i/o protocol
|
||||
std::string fms_protocol;
|
||||
|
||||
public:
|
||||
/// Constructor. The collection name is used when saving the data.
|
||||
/** If @a mesh is NULL, then the mesh can be set later by calling either
|
||||
SetMesh() or Load(). The latter works only in serial. */
|
||||
FMSDataCollection(const std::string& collection_name,
|
||||
Mesh *mesh = NULL);
|
||||
#ifdef MFEM_USE_MPI
|
||||
/// Construct a parallel FMSDataCollection.
|
||||
FMSDataCollection(MPI_Comm comm, const std::string& collection_name,
|
||||
Mesh *mesh = NULL);
|
||||
#endif
|
||||
|
||||
/// We will delete the mesh and fields if we own them
|
||||
virtual ~FMSDataCollection();
|
||||
|
||||
/// Set the FMS relay i/o protocol to use
|
||||
/** Supported options: ascii (default), json, yaml, hdf5 */
|
||||
void SetProtocol(const std::string &protocol);
|
||||
|
||||
/// Save the collection and a FMS blueprint root file
|
||||
virtual void Save();
|
||||
|
||||
/// Load the collection based blueprint data
|
||||
virtual void Load(int cycle = 0);
|
||||
};
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+7
-9
@@ -218,7 +218,7 @@ void GridFunction::MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
|
||||
|
||||
void GridFunction::MakeTRef(FiniteElementSpace *f, double *tv)
|
||||
{
|
||||
if (!f->GetProlongationMatrix())
|
||||
if (IsIdentityProlongation(f->GetProlongationMatrix()))
|
||||
{
|
||||
MakeRef(f, tv);
|
||||
t_vec.NewDataAndSize(tv, size);
|
||||
@@ -232,7 +232,8 @@ void GridFunction::MakeTRef(FiniteElementSpace *f, double *tv)
|
||||
|
||||
void GridFunction::MakeTRef(FiniteElementSpace *f, Vector &tv, int tv_offset)
|
||||
{
|
||||
if (!f->GetProlongationMatrix())
|
||||
tv.UseDevice(true);
|
||||
if (IsIdentityProlongation(f->GetProlongationMatrix()))
|
||||
{
|
||||
MakeRef(f, tv, tv_offset);
|
||||
t_vec.NewMemoryAndSize(data, size, false);
|
||||
@@ -241,10 +242,7 @@ void GridFunction::MakeTRef(FiniteElementSpace *f, Vector &tv, int tv_offset)
|
||||
{
|
||||
MFEM_ASSERT(tv.Size() >= tv_offset + f->GetTrueVSize(), "");
|
||||
SetSpace(f); // works in parallel
|
||||
tv.UseDevice(true);
|
||||
const int tv_size = f->GetTrueVSize();
|
||||
t_vec.NewMemoryAndSize(Memory<double>(tv.GetMemory(), tv_offset, tv_size),
|
||||
tv_size, true);
|
||||
t_vec.MakeRef(tv, tv_offset, f->GetTrueVSize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,10 +332,10 @@ int GridFunction::VectorDim() const
|
||||
void GridFunction::GetTrueDofs(Vector &tv) const
|
||||
{
|
||||
const SparseMatrix *R = fes->GetRestrictionMatrix();
|
||||
if (!R)
|
||||
if (!R || IsIdentityProlongation(fes->GetProlongationMatrix()))
|
||||
{
|
||||
// R is identity -> make tv a reference to *this
|
||||
tv.MakeRef(const_cast<GridFunction &>(*this), 0, size);
|
||||
// R is identity
|
||||
tv = *this; // no real copy if 'tv' and '*this' use the same data
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+7
-3
@@ -95,6 +95,12 @@ public:
|
||||
: Vector(data, f->GetVSize())
|
||||
{ fes = f; fec = NULL; fes_sequence = f->GetSequence(); UseDevice(true); }
|
||||
|
||||
/** @brief Construct a GridFunction using previously allocated Vector @a base
|
||||
starting at the given offset, @a base_offset. */
|
||||
GridFunction(FiniteElementSpace *f, Vector &base, int base_offset = 0)
|
||||
: Vector(base, base_offset, f->GetVSize())
|
||||
{ fes = f; fec = NULL; fes_sequence = f->GetSequence(); UseDevice(true); }
|
||||
|
||||
/// Construct a GridFunction on the given Mesh, using the data from @a input.
|
||||
/** The content of @a input should be in the format created by the method
|
||||
Save(). The reconstructed FiniteElementSpace and FiniteElementCollection
|
||||
@@ -130,9 +136,7 @@ public:
|
||||
or set. */
|
||||
Vector &GetTrueVector() { return t_vec; }
|
||||
|
||||
/// @brief Extract the true-dofs from the GridFunction. If all dofs are true,
|
||||
/// then `tv` will be set to point to the data of `*this`.
|
||||
/** @warning This method breaks const-ness when all dofs are true. */
|
||||
/// Extract the true-dofs from the GridFunction.
|
||||
void GetTrueDofs(Vector &tv) const;
|
||||
|
||||
/// Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
|
||||
|
||||
+18
-9
@@ -19,7 +19,11 @@
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
// External GSLIB header (the MFEM header is gslib.hpp)
|
||||
namespace gslib
|
||||
{
|
||||
#include "gslib.h"
|
||||
}
|
||||
|
||||
#ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -34,13 +38,13 @@ FindPointsGSLIB::FindPointsGSLIB()
|
||||
dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
|
||||
avgtype(AvgType::ARITHMETIC)
|
||||
{
|
||||
gsl_comm = new comm;
|
||||
cr = new crystal;
|
||||
gsl_comm = new gslib::comm;
|
||||
cr = new gslib::crystal;
|
||||
#ifdef MFEM_USE_MPI
|
||||
int initialized;
|
||||
MPI_Initialized(&initialized);
|
||||
if (!initialized) { MPI_Init(NULL, NULL); }
|
||||
MPI_Comm comm = MPI_COMM_WORLD;;
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
comm_init(gsl_comm, comm);
|
||||
#else
|
||||
comm_init(gsl_comm, 0);
|
||||
@@ -62,8 +66,8 @@ FindPointsGSLIB::FindPointsGSLIB(MPI_Comm comm_)
|
||||
dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
|
||||
avgtype(AvgType::ARITHMETIC)
|
||||
{
|
||||
gsl_comm = new comm;
|
||||
cr = new crystal;
|
||||
gsl_comm = new gslib::comm;
|
||||
cr = new gslib::crystal;
|
||||
comm_init(gsl_comm, comm_);
|
||||
}
|
||||
#endif
|
||||
@@ -606,7 +610,12 @@ void FindPointsGSLIB::Interpolate(const GridFunction &field_in,
|
||||
{
|
||||
if (gsl_code[i] == 1) { indl2.Append(i); }
|
||||
}
|
||||
if (indl2.Size() == 0) { return; } // no points on element borders
|
||||
int borderPts = indl2.Size();
|
||||
#ifdef MFEM_USE_MPI
|
||||
MPI_Allreduce(MPI_IN_PLACE, &borderPts, 1, MPI_INT, MPI_SUM, gsl_comm->c);
|
||||
#endif
|
||||
if (borderPts == 0) { return; } // no points on element borders
|
||||
|
||||
|
||||
Vector field_out_l2(field_out.Size());
|
||||
VectorGridFunctionCoefficient field_in_dg(&field_in);
|
||||
@@ -728,7 +737,7 @@ void FindPointsGSLIB::InterpolateGeneral(const GridFunction &field_in,
|
||||
}
|
||||
|
||||
// Pack data to send via crystal router
|
||||
struct array *outpt = new array;
|
||||
struct gslib::array *outpt = new gslib::array;
|
||||
struct out_pt { double r[3], ival; uint index, el, proc; };
|
||||
struct out_pt *pt;
|
||||
array_init(struct out_pt, outpt, nptsend);
|
||||
@@ -788,7 +797,7 @@ void FindPointsGSLIB::InterpolateGeneral(const GridFunction &field_in,
|
||||
}
|
||||
|
||||
// Save index and proc data in a struct
|
||||
struct array *savpt = new array;
|
||||
struct gslib::array *savpt = new gslib::array;
|
||||
struct sav_pt { uint index, proc; };
|
||||
struct sav_pt *spt;
|
||||
array_init(struct sav_pt, savpt, npt);
|
||||
@@ -806,7 +815,7 @@ void FindPointsGSLIB::InterpolateGeneral(const GridFunction &field_in,
|
||||
delete outpt;
|
||||
|
||||
// Copy data from save struct to send struct and send component wise
|
||||
struct array *sendpt = new array;
|
||||
struct gslib::array *sendpt = new gslib::array;
|
||||
struct send_pt { double ival; uint index, proc; };
|
||||
struct send_pt *sdpt;
|
||||
for (int j = 0; j < ncomp; j++)
|
||||
|
||||
+7
-5
@@ -17,11 +17,13 @@
|
||||
|
||||
#ifdef MFEM_USE_GSLIB
|
||||
|
||||
namespace gslib
|
||||
{
|
||||
struct comm;
|
||||
struct findpts_data_2;
|
||||
struct findpts_data_3;
|
||||
struct array;
|
||||
struct crystal;
|
||||
}
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -50,10 +52,10 @@ public:
|
||||
protected:
|
||||
Mesh *mesh, *meshsplit;
|
||||
IntegrationRule *ir_simplex; // IntegrationRule to split quads/hex -> simplex
|
||||
struct findpts_data_2 *fdata2D; // gslib's internal data
|
||||
struct findpts_data_3 *fdata3D; // gslib's internal data
|
||||
struct crystal *cr; // gslib's internal data
|
||||
struct comm *gsl_comm; // gslib's internal data
|
||||
struct gslib::findpts_data_2 *fdata2D; // gslib's internal data
|
||||
struct gslib::findpts_data_3 *fdata3D; // gslib's internal data
|
||||
struct gslib::crystal *cr; // gslib's internal data
|
||||
struct gslib::comm *gsl_comm; // gslib's internal data
|
||||
int dim, points_cnt;
|
||||
Array<unsigned int> gsl_code, gsl_proc, gsl_elem, gsl_mfem_elem;
|
||||
Vector gsl_mesh, gsl_ref, gsl_dist, gsl_mfem_ref;
|
||||
|
||||
+4
-6
@@ -267,18 +267,16 @@ void LinearForm::Assemble()
|
||||
|
||||
void LinearForm::Update(FiniteElementSpace *f, Vector &v, int v_offset)
|
||||
{
|
||||
MFEM_ASSERT(v.Size() >= v_offset + f->GetVSize(), "");
|
||||
fes = f;
|
||||
NewMemoryAndSize(Memory<double>(v.GetMemory(), v_offset, f->GetVSize()),
|
||||
f->GetVSize(), false);
|
||||
v.UseDevice(true);
|
||||
this->Vector::MakeRef(v, v_offset, fes->GetVSize());
|
||||
ResetDeltaLocations();
|
||||
}
|
||||
|
||||
void LinearForm::MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
|
||||
{
|
||||
MFEM_ASSERT(v.Size() >= v_offset + f->GetVSize(), "");
|
||||
fes = f;
|
||||
v.UseDevice(true);
|
||||
this->Vector::MakeRef(v, v_offset, fes->GetVSize());
|
||||
Update(f, v, v_offset);
|
||||
}
|
||||
|
||||
void LinearForm::AssembleDelta()
|
||||
|
||||
+10
-6
@@ -630,7 +630,7 @@ double BlockNonlinearForm::GetEnergyBlocked(const BlockVector &bx) const
|
||||
|
||||
double BlockNonlinearForm::GetEnergy(const Vector &x) const
|
||||
{
|
||||
xs.Update(x.GetData(), block_offsets);
|
||||
xs.Update(const_cast<Vector&>(x), block_offsets);
|
||||
return GetEnergyBlocked(xs);
|
||||
}
|
||||
|
||||
@@ -646,7 +646,9 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
|
||||
Array<const FiniteElement *> fe2(fes.Size());
|
||||
ElementTransformation *T;
|
||||
|
||||
by.UseDevice(true);
|
||||
by = 0.0;
|
||||
by.SyncToBlocks();
|
||||
for (int s=0; s<fes.Size(); ++s)
|
||||
{
|
||||
el_x_const[s] = el_x[s] = new Vector();
|
||||
@@ -785,6 +787,8 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
|
||||
delete el_y[s];
|
||||
delete el_x[s];
|
||||
}
|
||||
|
||||
by.SyncFromBlocks();
|
||||
}
|
||||
|
||||
const BlockVector &BlockNonlinearForm::Prolongate(const BlockVector &bx) const
|
||||
@@ -805,8 +809,8 @@ const BlockVector &BlockNonlinearForm::Prolongate(const BlockVector &bx) const
|
||||
|
||||
void BlockNonlinearForm::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
BlockVector bx(x.GetData(), block_trueOffsets);
|
||||
BlockVector by(y.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(x), block_trueOffsets);
|
||||
BlockVector by(y, block_trueOffsets);
|
||||
|
||||
const BlockVector &pbx = Prolongate(bx);
|
||||
if (needs_prolongation)
|
||||
@@ -815,8 +819,8 @@ void BlockNonlinearForm::Mult(const Vector &x, Vector &y) const
|
||||
}
|
||||
BlockVector &pby = needs_prolongation ? aux2 : by;
|
||||
|
||||
xs.Update(pbx.GetData(), block_offsets);
|
||||
ys.Update(pby.GetData(), block_offsets);
|
||||
xs.Update(const_cast<BlockVector&>(pbx), block_offsets);
|
||||
ys.Update(pby, block_offsets);
|
||||
MultBlocked(xs, ys);
|
||||
|
||||
for (int s = 0; s < fes.Size(); s++)
|
||||
@@ -1021,7 +1025,7 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
|
||||
|
||||
Operator &BlockNonlinearForm::GetGradient(const Vector &x) const
|
||||
{
|
||||
BlockVector bx(x.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(x), block_trueOffsets);
|
||||
const BlockVector &pbx = Prolongate(bx);
|
||||
|
||||
ComputeGradientBlocked(pbx);
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public:
|
||||
@param[in,out] y The result Vector: @f$ y += G x @f$. */
|
||||
virtual void AddMultGradPA(const Vector &x, Vector &y) const;
|
||||
|
||||
/// Method for computing the diagonal of the gradient with partial assmebly.
|
||||
/// Method for computing the diagonal of the gradient with partial assembly.
|
||||
/** The result Vector @a diag is an E-Vector. This method can be called only
|
||||
after the method AssembleGradPA() has been called.
|
||||
|
||||
|
||||
@@ -317,10 +317,6 @@ ParallelEliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
|
||||
void ParBilinearForm::TrueAddMult(const Vector &x, Vector &y, const double a)
|
||||
const
|
||||
{
|
||||
MFEM_VERIFY(interior_face_integs.Size() == 0,
|
||||
"the case of interior face integrators is not"
|
||||
" implemented");
|
||||
|
||||
if (X.ParFESpace() != pfes)
|
||||
{
|
||||
X.SetSpace(pfes);
|
||||
@@ -334,6 +330,9 @@ const
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_VERIFY(interior_face_integs.Size() == 0,
|
||||
"the case of interior face integrators is not"
|
||||
" implemented");
|
||||
mat->Mult(X, Y);
|
||||
}
|
||||
pfes->Dof_TrueDof_Matrix()->MultTranspose(a, Y, 1.0, y);
|
||||
@@ -473,7 +472,7 @@ void ParBilinearForm::RecoverFEMSolution(
|
||||
else
|
||||
{
|
||||
// Apply conforming prolongation
|
||||
x.SetSize(P.Height());
|
||||
x.SetSize(P.Height(), GetHypreMemoryType());
|
||||
P.Mult(X, x);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-12
@@ -2885,19 +2885,10 @@ ParFiniteElementSpace::ParallelDerefinementMatrix(int old_ndofs,
|
||||
|
||||
HypreParMatrix* R;
|
||||
R = new HypreParMatrix(MyComm, dof_offsets[nrk], old_dof_offsets[nrk],
|
||||
dof_offsets, old_dof_offsets, diag, offd, cmap);
|
||||
dof_offsets, old_dof_offsets, diag, offd, cmap,
|
||||
true);
|
||||
|
||||
#ifndef HYPRE_BIGINT
|
||||
diag->LoseData();
|
||||
offd->LoseData();
|
||||
#else
|
||||
diag->SetDataOwner(false);
|
||||
offd->SetDataOwner(false);
|
||||
#endif
|
||||
delete diag;
|
||||
delete offd;
|
||||
|
||||
R->SetOwnerFlags(3, 3, 1);
|
||||
R->SetOwnerFlags(R->OwnsDiag(), R->OwnsOffd(), 1);
|
||||
|
||||
return R;
|
||||
}
|
||||
|
||||
+1
-1
@@ -291,7 +291,7 @@ public:
|
||||
/** Returns pointer to the FiniteElement in the FiniteElementCollection
|
||||
associated with i'th element in the mesh object. If @a i is greater than
|
||||
or equal to the number of local mesh elements, @a i will be interpreted
|
||||
as a shifted index of a face neigbor element. */
|
||||
as a shifted index of a face neighbor element. */
|
||||
virtual const FiniteElement *GetFE(int i) const;
|
||||
|
||||
/** Returns an Operator that converts L-vectors to E-vectors on each face.
|
||||
|
||||
@@ -65,6 +65,11 @@ public:
|
||||
ParGridFunction(ParFiniteElementSpace *pf, double *data) :
|
||||
GridFunction(pf, data), pfes(pf) { }
|
||||
|
||||
/** @brief Construct a ParGridFunction using previously allocated Vector
|
||||
@a base starting at the given offset, @a base_offset. */
|
||||
ParGridFunction(ParFiniteElementSpace *pf, Vector &base, int base_offset = 0)
|
||||
: GridFunction(pf, base, base_offset), pfes(pf) { }
|
||||
|
||||
/// Construct a ParGridFunction using a GridFunction as external data.
|
||||
/** The parallel space @a *pf and the space used by @a *gf should match. The
|
||||
data from @a *gf is used as the local data of the ParGridFunction on each
|
||||
|
||||
+12
-5
@@ -218,7 +218,8 @@ void ParBlockNonlinearForm::SetEssentialBC(const
|
||||
|
||||
double ParBlockNonlinearForm::GetEnergy(const Vector &x) const
|
||||
{
|
||||
xs_true.Update(x.GetData(), block_trueOffsets);
|
||||
// xs_true is not modified, so const_cast is okay
|
||||
xs_true.Update(const_cast<Vector &>(x), block_trueOffsets);
|
||||
xs.Update(block_offsets);
|
||||
|
||||
for (int s = 0; s < fes.Size(); ++s)
|
||||
@@ -237,8 +238,9 @@ double ParBlockNonlinearForm::GetEnergy(const Vector &x) const
|
||||
|
||||
void ParBlockNonlinearForm::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
xs_true.Update(x.GetData(), block_trueOffsets);
|
||||
ys_true.Update(y.GetData(), block_trueOffsets);
|
||||
// xs_true is not modified, so const_cast is okay
|
||||
xs_true.Update(const_cast<Vector &>(x), block_trueOffsets);
|
||||
ys_true.Update(y, block_trueOffsets);
|
||||
xs.Update(block_offsets);
|
||||
ys.Update(block_offsets);
|
||||
|
||||
@@ -262,13 +264,17 @@ void ParBlockNonlinearForm::Mult(const Vector &x, Vector &y) const
|
||||
|
||||
ys_true.GetBlock(s).SetSubVector(*ess_tdofs[s], 0.0);
|
||||
}
|
||||
|
||||
ys_true.SyncFromBlocks();
|
||||
y.SyncMemory(ys_true);
|
||||
}
|
||||
|
||||
/// Return the local gradient matrix for the given true-dof vector x
|
||||
const BlockOperator & ParBlockNonlinearForm::GetLocalGradient(
|
||||
const Vector &x) const
|
||||
{
|
||||
xs_true.Update(x.GetData(), block_trueOffsets);
|
||||
// xs_true is not modified, so const_cast is okay
|
||||
xs_true.Update(const_cast<Vector &>(x), block_trueOffsets);
|
||||
xs.Update(block_offsets);
|
||||
|
||||
for (int s=0; s<fes.Size(); ++s)
|
||||
@@ -277,7 +283,8 @@ const BlockOperator & ParBlockNonlinearForm::GetLocalGradient(
|
||||
xs_true.GetBlock(s), xs.GetBlock(s));
|
||||
}
|
||||
|
||||
BlockNonlinearForm::ComputeGradientBlocked(xs); // (re)assemble Grad with b.c.
|
||||
// (re)assemble Grad without b.c. into 'Grads'
|
||||
BlockNonlinearForm::ComputeGradientBlocked(xs);
|
||||
|
||||
delete BlockGrad;
|
||||
BlockGrad = new BlockOperator(block_offsets);
|
||||
|
||||
@@ -33,6 +33,10 @@ ParL2FaceRestriction::ParL2FaceRestriction(const ParFiniteElementSpace &fes,
|
||||
// If fespace == L2
|
||||
const ParFiniteElementSpace &pfes =
|
||||
static_cast<const ParFiniteElementSpace&>(this->fes);
|
||||
|
||||
// Ensure the face neighbor data is constructed
|
||||
pfes.GetParMesh()->ExchangeFaceNbrData();
|
||||
|
||||
const FiniteElement *fe = pfes.GetFE(0);
|
||||
const TensorBasisElement *tfe = dynamic_cast<const TensorBasisElement*>(fe);
|
||||
MFEM_VERIFY(tfe != NULL &&
|
||||
|
||||
+28
-18
@@ -13,6 +13,13 @@
|
||||
#include "gridfunc.hpp"
|
||||
#include "fespace.hpp"
|
||||
#include "../general/forall.hpp"
|
||||
#include <climits>
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
#include "pfespace.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -267,35 +274,25 @@ void ElementRestriction::FillSparseMatrix(const Vector &mat_ea,
|
||||
FillJAndData(mat_ea, mat);
|
||||
}
|
||||
|
||||
template <int MaxNbNbr>
|
||||
static MFEM_HOST_DEVICE int GetMinElt(const int *my_elts, const int nbElts,
|
||||
const int *nbr_elts, const int nbrNbElts)
|
||||
{
|
||||
// Building the intersection
|
||||
int inter[MaxNbNbr];
|
||||
int cpt = 0;
|
||||
// Find the minimal element index found in both my_elts[] and nbr_elts[]
|
||||
int min_el = INT_MAX;
|
||||
for (int i = 0; i < nbElts; i++)
|
||||
{
|
||||
const int e_i = my_elts[i];
|
||||
if (e_i >= min_el) { continue; }
|
||||
for (int j = 0; j < nbrNbElts; j++)
|
||||
{
|
||||
if (e_i==nbr_elts[j])
|
||||
{
|
||||
inter[cpt] = e_i;
|
||||
cpt++;
|
||||
min_el = e_i; // we already know e_i < min_el
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Finding the minimum
|
||||
int min = inter[0];
|
||||
for (int i = 1; i < cpt; i++)
|
||||
{
|
||||
if (inter[i] < min)
|
||||
{
|
||||
min = inter[i];
|
||||
}
|
||||
}
|
||||
return min;
|
||||
return min_el;
|
||||
}
|
||||
|
||||
/** Returns the index where a non-zero entry should be added and increment the
|
||||
@@ -355,7 +352,7 @@ int ElementRestriction::FillI(SparseMatrix &mat) const
|
||||
const int elt = j_E/elt_dofs;
|
||||
j_elts[e_j] = elt;
|
||||
}
|
||||
int min_e = GetMinElt<Max>(i_elts, i_nbElts, j_elts, j_nbElts);
|
||||
int min_e = GetMinElt(i_elts, i_nbElts, j_elts, j_nbElts);
|
||||
if (e == min_e) // add the nnz only once
|
||||
{
|
||||
GetAndIncrementNnzIndex(i_L, I);
|
||||
@@ -434,7 +431,7 @@ void ElementRestriction::FillJAndData(const Vector &ea_data,
|
||||
j_elts[e_j] = elt;
|
||||
j_B[e_j] = j_E%elt_dofs;
|
||||
}
|
||||
int min_e = GetMinElt<Max>(i_elts, i_nbElts, j_elts, j_nbElts);
|
||||
int min_e = GetMinElt(i_elts, i_nbElts, j_elts, j_nbElts);
|
||||
if (e == min_e) // add the nnz only once
|
||||
{
|
||||
double val = 0.0;
|
||||
@@ -684,6 +681,19 @@ H1FaceRestriction::H1FaceRestriction(const FiniteElementSpace &fes,
|
||||
gather_indices(nf*dof)
|
||||
{
|
||||
if (nf==0) { return; }
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
// If the underlying finite element space is parallel, ensure the face
|
||||
// neighbor information is generated.
|
||||
if (const ParFiniteElementSpace *pfes
|
||||
= dynamic_cast<const ParFiniteElementSpace*>(&fes))
|
||||
{
|
||||
pfes->GetParMesh()->ExchangeFaceNbrData();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// If fespace == H1
|
||||
const FiniteElement *fe = fes.GetFE(0);
|
||||
const TensorBasisElement *tfe = dynamic_cast<const TensorBasisElement*>(fe);
|
||||
|
||||
+382
-67
@@ -1314,33 +1314,61 @@ static inline void device_copy(double *d_dest, const double *d_src, int size)
|
||||
} // namespace internal
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void DiscreteAdaptTC::FinalizeParDiscreteTargetSpec(const ParGridFunction
|
||||
&tspec_)
|
||||
void DiscreteAdaptTC::FinalizeParDiscreteTargetSpec(const ParGridFunction &t)
|
||||
{
|
||||
MFEM_VERIFY(adapt_eval, "SetAdaptivityEvaluator() has not been called!")
|
||||
MFEM_VERIFY(ncomp > 0, "No target specifications have been set!");
|
||||
|
||||
ParFiniteElementSpace *ptspec_fes = tspec_.ParFESpace();
|
||||
ParFiniteElementSpace *ptspec_fes = t.ParFESpace();
|
||||
|
||||
adapt_eval->SetParMetaInfo(*ptspec_fes->GetParMesh(),
|
||||
*ptspec_fes->FEColl(), ncomp);
|
||||
adapt_eval->SetInitialField(*tspec_fes->GetMesh()->GetNodes(), tspec);
|
||||
adapt_eval->SetInitialField(*ptspec_fes->GetMesh()->GetNodes(), tspec);
|
||||
|
||||
tspec_sav = tspec;
|
||||
|
||||
delete tspec_fesv;
|
||||
tspec_fesv = new FiniteElementSpace(tspec_fes->GetMesh(),
|
||||
tspec_fes->FEColl(), ncomp);
|
||||
tspec_fesv = new FiniteElementSpace(ptspec_fes->GetMesh(),
|
||||
ptspec_fes->FEColl(), ncomp);
|
||||
|
||||
delete ptspec_fesv;
|
||||
ptspec_fesv = new ParFiniteElementSpace(ptspec_fes->GetParMesh(),
|
||||
ptspec_fes->FEColl(), ncomp);
|
||||
|
||||
delete tspec_pgf;
|
||||
tspec_pgf = new ParGridFunction(ptspec_fesv, tspec);
|
||||
tspec_gf = tspec_pgf;
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::ParUpdateAfterMeshTopologyChange()
|
||||
{
|
||||
ptspec_fesv->Update();
|
||||
if (tspec_fesv)
|
||||
{
|
||||
delete tspec_fesv;
|
||||
tspec_fesv = new FiniteElementSpace(ptspec_fesv->GetMesh(),
|
||||
ptspec_fesv->FEColl(), ncomp);
|
||||
}
|
||||
tspec_pgf->Update();
|
||||
tspec_gf = tspec_pgf;
|
||||
tspec.SetDataAndSize(tspec_pgf->GetData(), tspec_pgf->Size());
|
||||
tspec_sav = tspec;
|
||||
|
||||
adapt_eval->SetParMetaInfo(*ptspec_fesv->GetParMesh(),
|
||||
*ptspec_fesv->FEColl(), ncomp);
|
||||
adapt_eval->SetInitialField(*ptspec_fesv->GetMesh()->GetNodes(), tspec);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetTspecAtIndex(int idx, const ParGridFunction &tspec_)
|
||||
{
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
dof_cnt = tspec_.Size()/vdim;
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
ndof = tspec_.FESpace()->GetNDofs();
|
||||
MFEM_VERIFY(ndof == tspec.Size()/ncomp, "Inconsistency in SetTspecAtIndex.");
|
||||
|
||||
const auto tspec__d = tspec_.Read();
|
||||
auto tspec_d = tspec.ReadWrite();
|
||||
const int offset = idx*dof_cnt;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
|
||||
const int offset = idx*ndof;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
|
||||
FinalizeParDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
|
||||
@@ -1360,78 +1388,71 @@ void DiscreteAdaptTC::SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
|
||||
FinalizeParDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetParDiscreteTargetAspectRatio(const ParGridFunction
|
||||
&tspec_)
|
||||
void DiscreteAdaptTC::SetParDiscreteTargetAspectRatio(const ParGridFunction &ar)
|
||||
{
|
||||
if (aspectratioidx > -1) { SetTspecAtIndex(aspectratioidx, tspec_); return; }
|
||||
if (aspectratioidx > -1) { SetTspecAtIndex(aspectratioidx, ar); return; }
|
||||
aspectratioidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeParDiscreteTargetSpec(tspec_);
|
||||
SetDiscreteTargetBase(ar);
|
||||
FinalizeParDiscreteTargetSpec(ar);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetParDiscreteTargetOrientation(const ParGridFunction
|
||||
&tspec_)
|
||||
void DiscreteAdaptTC::SetParDiscreteTargetOrientation(const ParGridFunction &o)
|
||||
{
|
||||
if (orientationidx > -1) { SetTspecAtIndex(orientationidx, tspec_); return; }
|
||||
if (orientationidx > -1) { SetTspecAtIndex(orientationidx, o); return; }
|
||||
orientationidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeParDiscreteTargetSpec(tspec_);
|
||||
SetDiscreteTargetBase(o);
|
||||
FinalizeParDiscreteTargetSpec(o);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
|
||||
{
|
||||
SetParDiscreteTargetSize(tspec_);
|
||||
FinalizeParDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
#endif // MFEM_USE_MPI
|
||||
|
||||
void DiscreteAdaptTC::SetDiscreteTargetBase(const GridFunction &tspec_)
|
||||
{
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
dof_cnt = tspec_.Size()/vdim;
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
ndof = tspec_.FESpace()->GetNDofs();
|
||||
|
||||
ncomp += vdim;
|
||||
|
||||
delete tspec_fes;
|
||||
tspec_fes = new FiniteElementSpace(tspec_.FESpace()->GetMesh(),
|
||||
tspec_.FESpace()->FEColl(), 1);
|
||||
|
||||
// need to append data to tspec
|
||||
// make a copy of tspec->tspec_temp, increase its size, and
|
||||
// copy data from tspec_temp -> tspec, then add new entries
|
||||
Vector tspec_temp = tspec;
|
||||
tspec.UseDevice(true);
|
||||
tspec_sav.UseDevice(true);
|
||||
tspec.SetSize(ncomp*dof_cnt);
|
||||
tspec.SetSize(ncomp*ndof);
|
||||
|
||||
const auto tspec_temp_d = tspec_temp.Read();
|
||||
auto tspec_d = tspec.ReadWrite();
|
||||
internal::device_copy(tspec_d, tspec_temp_d, tspec_temp.Size());
|
||||
|
||||
const auto tspec__d = tspec_.Read();
|
||||
const int offset = (ncomp-vdim)*dof_cnt;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
|
||||
const int offset = (ncomp-vdim)*ndof;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetTspecAtIndex(int idx, const GridFunction &tspec_)
|
||||
{
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
dof_cnt = tspec_.Size()/vdim;
|
||||
const int vdim = tspec_.FESpace()->GetVDim(),
|
||||
ndof = tspec_.FESpace()->GetNDofs();
|
||||
MFEM_VERIFY(ndof == tspec.Size()/ncomp, "Inconsistency in SetTargetSpec.");
|
||||
|
||||
const auto tspec__d = tspec_.Read();
|
||||
auto tspec_d = tspec.ReadWrite();
|
||||
const int offset = idx*dof_cnt;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
const int offset = idx*ndof;
|
||||
internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
|
||||
FinalizeSerialDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetSize(const GridFunction &tspec_)
|
||||
{
|
||||
|
||||
if (sizeidx > -1) { SetTspecAtIndex(sizeidx, tspec_); return; }
|
||||
sizeidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
FinalizeSerialDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
|
||||
@@ -1439,32 +1460,31 @@ void DiscreteAdaptTC::SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
|
||||
if (skewidx > -1) { SetTspecAtIndex(skewidx, tspec_); return; }
|
||||
skewidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
FinalizeSerialDiscreteTargetSpec(tspec_);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetAspectRatio(
|
||||
const GridFunction &tspec_)
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetAspectRatio(const GridFunction &ar)
|
||||
{
|
||||
if (aspectratioidx > -1) { SetTspecAtIndex(aspectratioidx, tspec_); return; }
|
||||
if (aspectratioidx > -1) { SetTspecAtIndex(aspectratioidx, ar); return; }
|
||||
aspectratioidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
SetDiscreteTargetBase(ar);
|
||||
FinalizeSerialDiscreteTargetSpec(ar);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetOrientation(
|
||||
const GridFunction &tspec_)
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetOrientation(const GridFunction &o)
|
||||
{
|
||||
if (orientationidx > -1) { SetTspecAtIndex(orientationidx, tspec_); return; }
|
||||
if (orientationidx > -1) { SetTspecAtIndex(orientationidx, o); return; }
|
||||
orientationidx = ncomp;
|
||||
SetDiscreteTargetBase(tspec_);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
SetDiscreteTargetBase(o);
|
||||
FinalizeSerialDiscreteTargetSpec(o);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::FinalizeSerialDiscreteTargetSpec()
|
||||
void DiscreteAdaptTC::FinalizeSerialDiscreteTargetSpec(const GridFunction &t)
|
||||
{
|
||||
MFEM_VERIFY(adapt_eval, "SetAdaptivityEvaluator() has not been called!")
|
||||
MFEM_VERIFY(ncomp > 0, "No target specifications have been set!");
|
||||
|
||||
const FiniteElementSpace *tspec_fes = t.FESpace();
|
||||
adapt_eval->SetSerialMetaInfo(*tspec_fes->GetMesh(),
|
||||
*tspec_fes->FEColl(), ncomp);
|
||||
adapt_eval->SetInitialField(*tspec_fes->GetMesh()->GetNodes(), tspec);
|
||||
@@ -1474,12 +1494,40 @@ void DiscreteAdaptTC::FinalizeSerialDiscreteTargetSpec()
|
||||
delete tspec_fesv;
|
||||
tspec_fesv = new FiniteElementSpace(tspec_fes->GetMesh(),
|
||||
tspec_fes->FEColl(), ncomp);
|
||||
|
||||
delete tspec_gf;
|
||||
tspec_gf = new GridFunction(tspec_fesv, tspec);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::GetDiscreteTargetSpec(GridFunction &tspec_, int idx)
|
||||
{
|
||||
if (idx < 0) { return; }
|
||||
const int ndof = tspec_.FESpace()->GetNDofs(),
|
||||
vdim = tspec_.FESpace()->GetVDim();
|
||||
MFEM_VERIFY(ndof == tspec.Size()/ncomp,
|
||||
"Inconsistency in GetSerialDiscreteTargetSpec.");
|
||||
|
||||
for (int i = 0; i < ndof*vdim; i++)
|
||||
{
|
||||
tspec_(i) = tspec(i + idx*ndof);
|
||||
}
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::UpdateAfterMeshTopologyChange()
|
||||
{
|
||||
tspec_fesv->Update();
|
||||
tspec_gf->Update();
|
||||
tspec.SetDataAndSize(tspec_gf->GetData(), tspec_gf->Size());
|
||||
tspec_sav = tspec;
|
||||
|
||||
adapt_eval->SetSerialMetaInfo(*tspec_fesv->GetMesh(),
|
||||
*tspec_fesv->FEColl(), ncomp);
|
||||
adapt_eval->SetInitialField(*tspec_fesv->GetMesh()->GetNodes(), tspec);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
|
||||
{
|
||||
SetSerialDiscreteTargetSize(tspec_);
|
||||
FinalizeSerialDiscreteTargetSpec();
|
||||
}
|
||||
|
||||
|
||||
@@ -1509,7 +1557,7 @@ void DiscreteAdaptTC::UpdateTargetSpecificationAtNode(const FiniteElement &el,
|
||||
MFEM_VERIFY(tspec.Size() > 0, "Target specification is not set!");
|
||||
|
||||
Array<int> dofs;
|
||||
tspec_fes->GetElementDofs(T.ElementNo, dofs);
|
||||
tspec_fesv->GetElementDofs(T.ElementNo, dofs);
|
||||
const int cnt = tspec.Size()/ncomp; // dofs per scalar-field
|
||||
|
||||
for (int i = 0; i < ncomp; i++)
|
||||
@@ -1524,7 +1572,7 @@ void DiscreteAdaptTC::RestoreTargetSpecificationAtNode(ElementTransformation &T,
|
||||
MFEM_VERIFY(tspec.Size() > 0, "Target specification is not set!");
|
||||
|
||||
Array<int> dofs;
|
||||
tspec_fes->GetElementDofs(T.ElementNo, dofs);
|
||||
tspec_fesv->GetElementDofs(T.ElementNo, dofs);
|
||||
const int cnt = tspec.Size()/ncomp;
|
||||
for (int i = 0; i < ncomp; i++)
|
||||
{
|
||||
@@ -1532,6 +1580,40 @@ void DiscreteAdaptTC::RestoreTargetSpecificationAtNode(ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetTspecFromIntRule(int e_id,
|
||||
const IntegrationRule &intrule)
|
||||
{
|
||||
switch (target_type)
|
||||
{
|
||||
case IDEAL_SHAPE_GIVEN_SIZE:
|
||||
case GIVEN_SHAPE_AND_SIZE:
|
||||
{
|
||||
const int ndofs = tspec_fesv->GetFE(e_id)->GetDof(),
|
||||
ntspec_dofs = ndofs*ncomp;
|
||||
|
||||
Vector tspec_vals(ntspec_dofs);
|
||||
|
||||
Array<int> dofs;
|
||||
tspec_fesv->GetElementVDofs(e_id, dofs);
|
||||
tspec.GetSubVector(dofs, tspec_vals);
|
||||
DenseMatrix tr;
|
||||
tspec_gf->GetVectorValues(e_id, intrule, tspec_refine, tr);
|
||||
tspec_refine.Transpose();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
MFEM_ABORT("Incompatible target type for discrete adaptation!");
|
||||
}
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::SetTspecDataForDerefinement(FiniteElementSpace *fes)
|
||||
{
|
||||
coarse_tspec_fesv = fes;
|
||||
const Operator *c_op = fes->GetUpdateOperator();
|
||||
tspec_derefine.SetSize(c_op->Height());
|
||||
c_op->Mult(tspec, tspec_derefine);
|
||||
}
|
||||
|
||||
void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
const IntegrationRule &ir,
|
||||
const Vector &elfun,
|
||||
@@ -1542,6 +1624,8 @@ void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
nqp = ir.GetNPoints();
|
||||
Jtrcomp.SetSize(dim, dim, 4*nqp);
|
||||
|
||||
FiniteElementSpace *src_fes = tspec_fesv;
|
||||
|
||||
switch (target_type)
|
||||
{
|
||||
case IDEAL_SHAPE_GIVEN_SIZE:
|
||||
@@ -1550,7 +1634,7 @@ void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
const DenseMatrix &Wideal =
|
||||
Geometries.GetGeomToPerfGeomJac(fe.GetGeomType());
|
||||
const int dim = Wideal.Height(),
|
||||
ndofs = tspec_fes->GetFE(e_id)->GetDof(),
|
||||
ndofs = tspec_fesv->GetFE(e_id)->GetDof(),
|
||||
ntspec_dofs = ndofs*ncomp;
|
||||
|
||||
Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
|
||||
@@ -1561,11 +1645,29 @@ void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
tspec_fesv->GetElementVDofs(e_id, dofs);
|
||||
tspec.UseDevice(true);
|
||||
tspec.GetSubVector(dofs, tspec_vals);
|
||||
if (tspec_refine.NumCols() > 0) // Refinement
|
||||
{
|
||||
MFEM_VERIFY(amr_el >= 0, " Target being constructed for an AMR element.");
|
||||
for (int i = 0; i < ncomp; i++)
|
||||
{
|
||||
for (int j = 0; j < ndofs; j++)
|
||||
{
|
||||
tspec_vals(j + i*ndofs) = tspec_refine(j + amr_el*ndofs, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tspec_derefine.Size() > 0) // Derefinement
|
||||
{
|
||||
dofs.SetSize(0);
|
||||
coarse_tspec_fesv->GetElementVDofs(e_id, dofs);
|
||||
tspec_derefine.GetSubVector(dofs, tspec_vals);
|
||||
src_fes = coarse_tspec_fesv;
|
||||
}
|
||||
|
||||
for (int q = 0; q < nqp; q++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(q);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
src_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
Jtr(q) = Wideal; // Initialize to identity
|
||||
for (int d = 0; d < 4; d++)
|
||||
{
|
||||
@@ -1576,9 +1678,16 @@ void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
if (sizeidx != -1) // Set size
|
||||
{
|
||||
par_vals.SetDataAndSize(tspec_vals.GetData()+sizeidx*ndofs, ndofs);
|
||||
const double min_size = par_vals.Min();
|
||||
MFEM_VERIFY(min_size > 0.0,
|
||||
"Non-positive size propagated in the target definition.");
|
||||
double min_size = par_vals.Min();//0.001; //
|
||||
if (lim_min_size > 0.)
|
||||
{
|
||||
min_size = lim_min_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_VERIFY(min_size > 0.0,
|
||||
"Non-positive size propagated in the target definition.");
|
||||
}
|
||||
const double size = std::max(shape * par_vals, min_size);
|
||||
Jtr(q).Set(std::pow(size, 1.0/dim), Jtr(q));
|
||||
DenseMatrix Jtrcomp_q(Jtrcomp.GetData(0 + 4*q), dim, dim);
|
||||
@@ -1593,6 +1702,9 @@ void DiscreteAdaptTC::ComputeElementTargets(int e_id, const FiniteElement &fe,
|
||||
{
|
||||
par_vals.SetDataAndSize(tspec_vals.GetData()+
|
||||
aspectratioidx*ndofs, ndofs);
|
||||
const double min_size = par_vals.Min();
|
||||
MFEM_VERIFY(min_size > 0.0,
|
||||
"Non-positive aspect-ratio propagated in the target definition.");
|
||||
|
||||
const double aspectratio = shape * par_vals;
|
||||
D_rho = 0.;
|
||||
@@ -1777,7 +1889,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
|
||||
grad_phys.Mult(par_vals, grad_ptr_c1);
|
||||
Vector grad_q(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q);
|
||||
|
||||
const double min_size = par_vals.Min();
|
||||
@@ -1810,7 +1922,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
|
||||
grad_phys.Mult(par_vals, grad_ptr_c1);
|
||||
Vector grad_q(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q);
|
||||
|
||||
const double aspectratio = shape * par_vals;
|
||||
@@ -1841,7 +1953,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
grad_phys.Mult(par_vals_c2, grad_ptr_c2);
|
||||
grad_phys.Mult(par_vals_c3, grad_ptr_c3);
|
||||
Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q1);
|
||||
grad_e_c2.MultTranspose(shape, grad_q2);
|
||||
grad_e_c3.MultTranspose(shape, grad_q3);
|
||||
@@ -1880,7 +1992,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
|
||||
grad_phys.Mult(par_vals, grad_ptr_c1);
|
||||
Vector grad_q(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q);
|
||||
|
||||
const double skew = shape * par_vals;
|
||||
@@ -1913,7 +2025,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
grad_phys.Mult(par_vals_c2, grad_ptr_c2);
|
||||
grad_phys.Mult(par_vals_c3, grad_ptr_c3);
|
||||
Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q1);
|
||||
grad_e_c2.MultTranspose(shape, grad_q2);
|
||||
grad_e_c3.MultTranspose(shape, grad_q3);
|
||||
@@ -1960,7 +2072,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
|
||||
grad_phys.Mult(par_vals, grad_ptr_c1);
|
||||
Vector grad_q(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q);
|
||||
|
||||
const double theta = shape * par_vals;
|
||||
@@ -1991,7 +2103,7 @@ void DiscreteAdaptTC::ComputeElementTargetsGradient(const IntegrationRule &ir,
|
||||
grad_phys.Mult(par_vals_c2, grad_ptr_c2);
|
||||
grad_phys.Mult(par_vals_c3, grad_ptr_c3);
|
||||
Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
|
||||
tspec_fes->GetFE(e_id)->CalcShape(ip, shape);
|
||||
tspec_fesv->GetFE(e_id)->CalcShape(ip, shape);
|
||||
grad_e_c1.MultTranspose(shape, grad_q1);
|
||||
grad_e_c2.MultTranspose(shape, grad_q2);
|
||||
grad_e_c3.MultTranspose(shape, grad_q3);
|
||||
@@ -2071,7 +2183,7 @@ void DiscreteAdaptTC::UpdateGradientTargetSpecification(const Vector &x,
|
||||
{
|
||||
if (use_flag && good_tspec_grad) { return; }
|
||||
|
||||
const int dim = tspec_fes->GetFE(0)->GetDim(),
|
||||
const int dim = tspec_fesv->GetFE(0)->GetDim(),
|
||||
cnt = x.Size()/dim;
|
||||
|
||||
tspec_pert1h.SetSize(x.Size()*ncomp);
|
||||
@@ -2097,7 +2209,7 @@ void DiscreteAdaptTC::UpdateHessianTargetSpecification(const Vector &x,
|
||||
|
||||
if (use_flag && good_tspec_hess) { return; }
|
||||
|
||||
const int dim = tspec_fes->GetFE(0)->GetDim(),
|
||||
const int dim = tspec_fesv->GetFE(0)->GetDim(),
|
||||
cnt = x.Size()/dim,
|
||||
totmix = 1+2*(dim-2);
|
||||
|
||||
@@ -2145,6 +2257,16 @@ void DiscreteAdaptTC::UpdateHessianTargetSpecification(const Vector &x,
|
||||
good_tspec_hess = use_flag;
|
||||
}
|
||||
|
||||
DiscreteAdaptTC::~DiscreteAdaptTC()
|
||||
{
|
||||
delete tspec_gf;
|
||||
delete adapt_eval;
|
||||
delete tspec_fesv;
|
||||
#ifdef MFEM_USE_MPI
|
||||
delete ptspec_fesv;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AdaptivityEvaluator::SetSerialMetaInfo(const Mesh &m,
|
||||
const FiniteElementCollection &fec,
|
||||
int num_comp)
|
||||
@@ -2258,6 +2380,7 @@ void TMOP_Integrator::EnableAdaptiveLimiting(const ParGridFunction &z0,
|
||||
AdaptivityEvaluator &ae)
|
||||
{
|
||||
zeta_0 = &z0;
|
||||
pzeta_0 = &z0;
|
||||
delete zeta;
|
||||
zeta = new GridFunction(z0);
|
||||
coeff_zeta = &coeff;
|
||||
@@ -2270,6 +2393,33 @@ void TMOP_Integrator::EnableAdaptiveLimiting(const ParGridFunction &z0,
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOP_Integrator::UpdateAfterMeshTopologyChange()
|
||||
{
|
||||
if (zeta)
|
||||
{
|
||||
zeta->Update();
|
||||
adapt_eval->SetSerialMetaInfo(*zeta->FESpace()->GetMesh(),
|
||||
*zeta->FESpace()->FEColl(), 1);
|
||||
adapt_eval->SetInitialField
|
||||
(*zeta->FESpace()->GetMesh()->GetNodes(), *zeta);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOP_Integrator::ParUpdateAfterMeshTopologyChange()
|
||||
{
|
||||
if (zeta)
|
||||
{
|
||||
zeta->Update();
|
||||
adapt_eval->SetParMetaInfo(*pzeta_0->ParFESpace()->GetParMesh(),
|
||||
*pzeta_0->ParFESpace()->FEColl(), 1);
|
||||
adapt_eval->SetInitialField
|
||||
(*zeta->FESpace()->GetMesh()->GetNodes(), *zeta);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
double TMOP_Integrator::GetElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun)
|
||||
@@ -2378,6 +2528,145 @@ double TMOP_Integrator::GetElementEnergy(const FiniteElement &el,
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
double TMOP_Integrator::GetRefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun,
|
||||
const IntegrationRule &irule)
|
||||
{
|
||||
int dof = el.GetDof(), dim = el.GetDim(),
|
||||
NEsplit = elfun.Size() / (dof*dim), el_id = T.ElementNo;
|
||||
double energy = 0.;
|
||||
|
||||
TargetConstructor *tc = const_cast<TargetConstructor *>(targetC);
|
||||
DiscreteAdaptTC *dtc = dynamic_cast<DiscreteAdaptTC *>(tc);
|
||||
// For DiscreteAdaptTC the GridFunctions used to set the targets must be
|
||||
// mapped onto the fine elements.
|
||||
if (dtc) { dtc->SetTspecFromIntRule(el_id, irule); }
|
||||
|
||||
for (int e = 0; e < NEsplit; e++)
|
||||
{
|
||||
DSh.SetSize(dof, dim);
|
||||
Jrt.SetSize(dim);
|
||||
Jpr.SetSize(dim);
|
||||
Jpt.SetSize(dim);
|
||||
Vector elfun_child(dof*dim);
|
||||
for (int i = 0; i < dof; i++)
|
||||
{
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
// elfun is (xe1,xe2,...xen,ye1,ye2...yen) and has nodal coordinates
|
||||
// for all the children element of the parent element being considered.
|
||||
// So we must index and get (xek, yek) i.e. nodal coordinates for
|
||||
// the fine element being considered.
|
||||
elfun_child(i + d*dof) = elfun(i + e*dof + d*dof*NEsplit);
|
||||
}
|
||||
}
|
||||
PMatI.UseExternalData(elfun_child.GetData(), dof, dim);
|
||||
|
||||
const IntegrationRule &ir = EnergyIntegrationRule(el);
|
||||
|
||||
double el_energy = 0;
|
||||
DenseTensor Jtr(dim, dim, ir.GetNPoints());
|
||||
if (dtc)
|
||||
{
|
||||
// This is used to index into the tspec vector inside DiscreteAdaptTC.
|
||||
dtc->SetRefinementSubElement(e);
|
||||
}
|
||||
targetC->ComputeElementTargets(el_id, el, ir, elfun_child, Jtr);
|
||||
|
||||
// Define ref->physical transformation, wn a Coefficient is specified.
|
||||
IsoparametricTransformation *Tpr = NULL;
|
||||
if (coeff1 || coeff0)
|
||||
{
|
||||
Tpr = new IsoparametricTransformation;
|
||||
Tpr->SetFE(&el);
|
||||
Tpr->ElementNo = T.ElementNo;
|
||||
Tpr->ElementType = ElementTransformation::ELEMENT;
|
||||
Tpr->Attribute = T.Attribute;
|
||||
Tpr->GetPointMat().Transpose(PMatI); // PointMat = PMatI^T
|
||||
}
|
||||
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(i);
|
||||
const DenseMatrix &Jtr_i = Jtr(i);
|
||||
h_metric->SetTargetJacobian(Jtr_i);
|
||||
CalcInverse(Jtr_i, Jrt);
|
||||
const double weight = ip.weight * Jtr_i.Det();
|
||||
|
||||
el.CalcDShape(ip, DSh);
|
||||
MultAtB(PMatI, DSh, Jpr);
|
||||
Mult(Jpr, Jrt, Jpt);
|
||||
|
||||
double val = metric_normal * h_metric->EvalW(Jpt);
|
||||
if (coeff1) { val *= coeff1->Eval(*Tpr, ip); }
|
||||
|
||||
el_energy += weight * val;
|
||||
delete Tpr;
|
||||
}
|
||||
energy += el_energy;
|
||||
}
|
||||
energy /= NEsplit;
|
||||
|
||||
if (dtc) { dtc->ResetRefinementTspecData(); }
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
double TMOP_Integrator::GetDerefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun)
|
||||
{
|
||||
int dof = el.GetDof(), dim = el.GetDim();
|
||||
double energy = 0.;
|
||||
|
||||
DSh.SetSize(dof, dim);
|
||||
Jrt.SetSize(dim);
|
||||
Jpr.SetSize(dim);
|
||||
Jpt.SetSize(dim);
|
||||
PMatI.UseExternalData(elfun.GetData(), dof, dim);
|
||||
|
||||
const IntegrationRule &ir = EnergyIntegrationRule(el);
|
||||
|
||||
energy = 0.0;
|
||||
DenseTensor Jtr(dim, dim, ir.GetNPoints());
|
||||
targetC->ComputeElementTargets(T.ElementNo, el, ir, elfun, Jtr);
|
||||
|
||||
// Define ref->physical transformation, wn a Coefficient is specified.
|
||||
IsoparametricTransformation *Tpr = NULL;
|
||||
if (coeff1)
|
||||
{
|
||||
Tpr = new IsoparametricTransformation;
|
||||
Tpr->SetFE(&el);
|
||||
Tpr->ElementNo = T.ElementNo;
|
||||
Tpr->ElementType = ElementTransformation::ELEMENT;
|
||||
Tpr->Attribute = T.Attribute;
|
||||
Tpr->GetPointMat().Transpose(PMatI); // PointMat = PMatI^T
|
||||
}
|
||||
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(i);
|
||||
const DenseMatrix &Jtr_i = Jtr(i);
|
||||
h_metric->SetTargetJacobian(Jtr_i);
|
||||
CalcInverse(Jtr_i, Jrt);
|
||||
const double weight = ip.weight * Jtr_i.Det();
|
||||
|
||||
el.CalcDShape(ip, DSh);
|
||||
MultAtB(PMatI, DSh, Jpr);
|
||||
Mult(Jpr, Jrt, Jpt);
|
||||
|
||||
double val = metric_normal * h_metric->EvalW(Jpt);
|
||||
if (coeff1) { val *= coeff1->Eval(*Tpr, ip); }
|
||||
|
||||
energy += weight * val;
|
||||
}
|
||||
|
||||
delete Tpr;
|
||||
return energy;
|
||||
}
|
||||
|
||||
void TMOP_Integrator::AssembleElementVector(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun, Vector &elvect)
|
||||
@@ -3039,7 +3328,7 @@ void TMOP_Integrator::ComputeMinJac(const Vector &x,
|
||||
dx = detv_avg_min / dxscale;
|
||||
}
|
||||
|
||||
void TMOP_Integrator::UpdateAfterMeshChange(const Vector &new_x)
|
||||
void TMOP_Integrator::UpdateAfterMeshPositionChange(const Vector &new_x)
|
||||
{
|
||||
if (discr_tc)
|
||||
{
|
||||
@@ -3168,6 +3457,32 @@ void TMOPComboIntegrator::AssembleElementGrad(const FiniteElement &el,
|
||||
}
|
||||
}
|
||||
|
||||
double TMOPComboIntegrator::GetRefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun,
|
||||
const IntegrationRule &irule)
|
||||
{
|
||||
double energy= 0.0;
|
||||
for (int i = 0; i < tmopi.Size(); i++)
|
||||
{
|
||||
energy += tmopi[i]->GetRefinementElementEnergy(el, T, elfun, irule);
|
||||
}
|
||||
return energy;
|
||||
}
|
||||
|
||||
double TMOPComboIntegrator::GetDerefinementElementEnergy(
|
||||
const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun)
|
||||
{
|
||||
double energy= 0.0;
|
||||
for (int i = 0; i < tmopi.Size(); i++)
|
||||
{
|
||||
energy += tmopi[i]->GetDerefinementElementEnergy(el, T, elfun);
|
||||
}
|
||||
return energy;
|
||||
}
|
||||
|
||||
void TMOPComboIntegrator::EnableNormalization(const GridFunction &x)
|
||||
{
|
||||
const int cnt = tmopi.Size();
|
||||
|
||||
+118
-16
@@ -1057,14 +1057,31 @@ protected:
|
||||
// eta1(x+h,y), eta2(x+h,y) ... etan(x+h,y), eta1(x,y+h), eta2(x,y+h) ...
|
||||
// same for tspec_pert2h and tspec_pertmix.
|
||||
|
||||
// DenseMatrix to hold target_spec values for the (children of the)
|
||||
// element being refined to consider for h-refinement.
|
||||
DenseMatrix tspec_refine;
|
||||
// Vector to hold the target_spec values for the coarse version of the
|
||||
// current mesh. Used for derefinement decision with hr-adaptivity.
|
||||
Vector tspec_derefine;
|
||||
|
||||
// Components of Target Jacobian at each quadrature point of an element. This
|
||||
// is required for computation of the derivative using chain rule.
|
||||
mutable DenseTensor Jtrcomp;
|
||||
|
||||
// Note: do not use the Nodes of this space as they may not be on the
|
||||
// positions corresponding to the values of tspec.
|
||||
const FiniteElementSpace *tspec_fes;
|
||||
const FiniteElementSpace *tspec_fesv;
|
||||
FiniteElementSpace *tspec_fesv; //owned
|
||||
FiniteElementSpace *coarse_tspec_fesv; //not owned, derefinement FESpace
|
||||
GridFunction *tspec_gf; //owned, uses tspec and tspec_fes
|
||||
// discrete adaptivity
|
||||
#ifdef MFEM_USE_MPI
|
||||
ParFiniteElementSpace *ptspec_fesv; //owned, needed for derefinement to
|
||||
// get update operator.
|
||||
ParGridFunction *tspec_pgf; // similar to tspec_gf
|
||||
#endif
|
||||
|
||||
int amr_el;
|
||||
double lim_min_size;
|
||||
|
||||
// These flags can be used by outside functions to avoid recomputing the
|
||||
// tspec and tspec_perth fields again on the same mesh.
|
||||
@@ -1076,7 +1093,7 @@ protected:
|
||||
|
||||
void SetDiscreteTargetBase(const GridFunction &tspec_);
|
||||
void SetTspecAtIndex(int idx, const GridFunction &tspec_);
|
||||
void FinalizeSerialDiscreteTargetSpec();
|
||||
void FinalizeSerialDiscreteTargetSpec(const GridFunction &tspec_);
|
||||
#ifdef MFEM_USE_MPI
|
||||
void SetTspecAtIndex(int idx, const ParGridFunction &tspec_);
|
||||
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_);
|
||||
@@ -1088,16 +1105,16 @@ public:
|
||||
ncomp(0),
|
||||
sizeidx(-1), skewidx(-1), aspectratioidx(-1), orientationidx(-1),
|
||||
tspec(), tspec_sav(), tspec_pert1h(), tspec_pert2h(), tspec_pertmix(),
|
||||
tspec_fes(NULL), tspec_fesv(NULL),
|
||||
tspec_refine(), tspec_derefine(),
|
||||
tspec_fesv(NULL), coarse_tspec_fesv(NULL), tspec_gf(NULL),
|
||||
#ifdef MFEM_USE_MPI
|
||||
ptspec_fesv(NULL), tspec_pgf(NULL),
|
||||
#endif
|
||||
amr_el(-1), lim_min_size(-0.1),
|
||||
good_tspec(false), good_tspec_grad(false), good_tspec_hess(false),
|
||||
adapt_eval(NULL) { }
|
||||
|
||||
virtual ~DiscreteAdaptTC()
|
||||
{
|
||||
delete adapt_eval;
|
||||
delete tspec_fes;
|
||||
delete tspec_fesv;
|
||||
}
|
||||
virtual ~DiscreteAdaptTC();
|
||||
|
||||
/** @name Target specification methods.
|
||||
The following methods are used to specify geometric parameters of the
|
||||
@@ -1128,6 +1145,20 @@ public:
|
||||
void ResetUpdateFlags()
|
||||
{ good_tspec = good_tspec_grad = good_tspec_hess = false; }
|
||||
|
||||
/// Get one of the discrete fields from tspec.
|
||||
void GetDiscreteTargetSpec(GridFunction &tspec_, int idx);
|
||||
/// Get the FESpace associated with tspec.
|
||||
FiniteElementSpace *GetTSpecFESpace() { return tspec_fesv; }
|
||||
/// Get the entire tspec.
|
||||
GridFunction *GetTSpecData() { return tspec_gf; }
|
||||
/// Update all discrete fields based on tspec and update for AMR
|
||||
void UpdateAfterMeshTopologyChange();
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
ParFiniteElementSpace *GetTSpecParFESpace() { return ptspec_fesv; }
|
||||
void ParUpdateAfterMeshTopologyChange();
|
||||
#endif
|
||||
|
||||
/** Used to update the target specification after the mesh has changed. The
|
||||
new mesh positions are given by new_x. If @a use_flags is true, repeated
|
||||
calls won't do anything until ResetUpdateFlags() is called. */
|
||||
@@ -1184,6 +1215,36 @@ public:
|
||||
const Vector &elfun,
|
||||
IsoparametricTransformation &Tpr,
|
||||
DenseTensor &dJtr) const;
|
||||
|
||||
// Generates tspec_vals for target construction using intrule
|
||||
// Used for the refinement component in hr-adaptivity.
|
||||
void SetTspecFromIntRule(int e_id, const IntegrationRule &intrule);
|
||||
|
||||
// Targets based on discrete functions can result in invalid (negative)
|
||||
// size at the quadrature points. This method can be used to set a
|
||||
// minimum target size.
|
||||
void SetMinSizeForTargets(double min_size_) { lim_min_size = min_size_; }
|
||||
|
||||
/// Computes target specification data with respect to the coarse FE space.
|
||||
void SetTspecDataForDerefinement(FiniteElementSpace *fes);
|
||||
|
||||
// Reset refinement data associated with h-adaptivity component.
|
||||
void ResetRefinementTspecData()
|
||||
{
|
||||
tspec_refine.Clear();
|
||||
amr_el = -1;
|
||||
}
|
||||
|
||||
// Reset derefinement data associated with h-adaptivity component.
|
||||
void ResetDerefinementTspecData()
|
||||
{
|
||||
tspec_derefine.Destroy();
|
||||
coarse_tspec_fesv = NULL;
|
||||
}
|
||||
|
||||
// Used to specify the fine element for determining energy of children of a
|
||||
// parent element.
|
||||
void SetRefinementSubElement(int amr_el_) { amr_el = amr_el_; }
|
||||
};
|
||||
|
||||
class TMOPNewtonSolver;
|
||||
@@ -1201,6 +1262,7 @@ protected:
|
||||
friend class TMOPNewtonSolver;
|
||||
friend class TMOPComboIntegrator;
|
||||
|
||||
TMOP_QualityMetric *h_metric;
|
||||
TMOP_QualityMetric *metric; // not owned
|
||||
const TargetConstructor *targetC; // not owned
|
||||
|
||||
@@ -1227,6 +1289,9 @@ protected:
|
||||
|
||||
// Adaptive limiting.
|
||||
const GridFunction *zeta_0; // Not owned.
|
||||
#ifdef MFEM_USE_MPI
|
||||
const ParGridFunction *pzeta_0;
|
||||
#endif
|
||||
GridFunction *zeta; // Owned. Updated by adapt_eval.
|
||||
Coefficient *coeff_zeta; // Not owned.
|
||||
AdaptivityEvaluator *adapt_eval; // Not owned.
|
||||
@@ -1337,7 +1402,7 @@ protected:
|
||||
#endif
|
||||
void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes);
|
||||
|
||||
void UpdateAfterMeshChange(const Vector &new_x);
|
||||
void UpdateAfterMeshPositionChange(const Vector &new_x);
|
||||
|
||||
void DisableLimiting()
|
||||
{
|
||||
@@ -1395,11 +1460,13 @@ protected:
|
||||
void ComputeAllElementTargets(const Vector &xe = Vector()) const;
|
||||
|
||||
public:
|
||||
/** @param[in] m TMOP_QualityMetric that will be integrated (not owned).
|
||||
@param[in] tc Target-matrix construction algorithm to use (not owned). */
|
||||
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc)
|
||||
: metric(m), targetC(tc), IntegRules(NULL), integ_order(-1),
|
||||
coeff1(NULL), metric_normal(1.0),
|
||||
/** @param[in] m TMOP_QualityMetric for r-adaptivity (not owned).
|
||||
@param[in] tc Target-matrix construction algorithm to use (not owned).
|
||||
@param[in] hm TMOP_QualityMetric for h-adaptivity (not owned). */
|
||||
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc,
|
||||
TMOP_QualityMetric *hm)
|
||||
: h_metric(hm), metric(m), targetC(tc), IntegRules(NULL),
|
||||
integ_order(-1), coeff1(NULL), metric_normal(1.0),
|
||||
nodes0(NULL), coeff0(NULL),
|
||||
lim_dist(NULL), lim_func(NULL), lim_normal(1.0),
|
||||
zeta_0(NULL), zeta(NULL), coeff_zeta(NULL), adapt_eval(NULL),
|
||||
@@ -1407,6 +1474,9 @@ public:
|
||||
fdflag(false), dxscale(1.0e3), fd_call_flag(false), exact_action(false)
|
||||
{ PA.enabled = false; }
|
||||
|
||||
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc)
|
||||
: TMOP_Integrator(m, tc, m) { }
|
||||
|
||||
~TMOP_Integrator();
|
||||
|
||||
/// Release the device memory of large PA allocations. This will copy device
|
||||
@@ -1478,6 +1548,22 @@ public:
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun);
|
||||
|
||||
/** @brief Computes the mean of the energies of the given element's children.
|
||||
|
||||
In addition to the inputs for GetElementEnergy, this function requires an
|
||||
IntegrationRule to be specified that will give the decomposition of the
|
||||
given element based on the refinement type being considered. */
|
||||
virtual double GetRefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun,
|
||||
const IntegrationRule &irule);
|
||||
|
||||
/// This function is similar to GetElementEnergy, but ignores components
|
||||
/// such as limiting etc. to compute the element energy.
|
||||
virtual double GetDerefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun);
|
||||
|
||||
virtual void AssembleElementVector(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun, Vector &elvect);
|
||||
@@ -1486,6 +1572,13 @@ public:
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun, DenseMatrix &elmat);
|
||||
|
||||
TMOP_QualityMetric &GetAMRQualityMetric() { return *h_metric; }
|
||||
|
||||
void UpdateAfterMeshTopologyChange();
|
||||
#ifdef MFEM_USE_MPI
|
||||
void ParUpdateAfterMeshTopologyChange();
|
||||
#endif
|
||||
|
||||
// PA extension
|
||||
using NonlinearFormIntegrator::AssemblePA;
|
||||
virtual void AssemblePA(const FiniteElementSpace&);
|
||||
@@ -1564,6 +1657,15 @@ public:
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun, DenseMatrix &elmat);
|
||||
|
||||
virtual double GetRefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun,
|
||||
const IntegrationRule &irule);
|
||||
|
||||
virtual double GetDerefinementElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
const Vector &elfun);
|
||||
|
||||
/// Normalization factor that considers all integrators in the combination.
|
||||
void EnableNormalization(const GridFunction &x);
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
Executable
+896
@@ -0,0 +1,896 @@
|
||||
// Copyright (c) 2010-2021, 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 "tmop_amr.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
using namespace mfem;
|
||||
|
||||
void TMOPRefinerEstimator::ComputeEstimates()
|
||||
{
|
||||
bool iso = false;
|
||||
bool aniso = false;
|
||||
if (amrmetric == 1 || amrmetric == 2 || amrmetric == 58)
|
||||
{
|
||||
aniso = true;
|
||||
}
|
||||
if (amrmetric == 55 || amrmetric == 56 || amrmetric == 77 ||
|
||||
amrmetric == 315 || amrmetric == 316 || amrmetric == 321)
|
||||
{
|
||||
iso = true;
|
||||
}
|
||||
if (amrmetric == 7 || amrmetric == 9)
|
||||
{
|
||||
iso = true; aniso = true;
|
||||
}
|
||||
|
||||
MFEM_VERIFY(iso || aniso, "Metric type not supported in hr-adaptivity.");
|
||||
|
||||
const int dim = mesh->Dimension();
|
||||
const int num_ref_types = 3 + 4*(dim-2);
|
||||
const int NEorig = mesh->GetNE();
|
||||
|
||||
aniso_flags.SetSize(NEorig);
|
||||
error_estimates.SetSize(NEorig);
|
||||
Vector amr_base_energy(NEorig), amr_temp_energy(NEorig);
|
||||
error_estimates = 1.*std::numeric_limits<float>::max();
|
||||
aniso_flags = -1;
|
||||
GetTMOPRefinementEnergy(0, amr_base_energy);
|
||||
|
||||
for (int i = 1; i < num_ref_types+1; i++)
|
||||
{
|
||||
if ( dim == 2 && i < 3 && aniso != true ) { continue; }
|
||||
if ( dim == 2 && i == 3 && iso != true ) { continue; }
|
||||
if ( dim == 3 && i < 7 && aniso != true ) { continue; }
|
||||
if ( dim == 3 && i == 7 && iso != true ) { continue; }
|
||||
|
||||
GetTMOPRefinementEnergy(i, amr_temp_energy);
|
||||
|
||||
for (int e = 0; e < NEorig; e++)
|
||||
{
|
||||
if ( amr_temp_energy(e) < error_estimates(e) )
|
||||
{
|
||||
error_estimates(e) = amr_temp_energy(e);
|
||||
aniso_flags[e] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
error_estimates *= energy_scaling_factor;
|
||||
|
||||
if (spat_gf)
|
||||
{
|
||||
L2_FECollection avg_fec(0, mesh->Dimension());
|
||||
FiniteElementSpace avg_fes(spat_gf->FESpace()->GetMesh(), &avg_fec);
|
||||
GridFunction elem_avg(&avg_fes);
|
||||
spat_gf->GetElementAverages(elem_avg);
|
||||
for (int i = 0; i < amr_base_energy.Size(); i++)
|
||||
{
|
||||
if (elem_avg(i) < spat_gf_critical) { amr_base_energy(i) = 0.; }
|
||||
}
|
||||
}
|
||||
|
||||
error_estimates -= amr_base_energy;
|
||||
error_estimates *= -1; // error = E(parent) - scaling_factor*mean(E(children))
|
||||
current_sequence = mesh->GetSequence();
|
||||
}
|
||||
|
||||
void TMOPRefinerEstimator::GetTMOPRefinementEnergy(int reftype,
|
||||
Vector &el_energy_vec)
|
||||
{
|
||||
const FiniteElementSpace *fes = mesh->GetNodalFESpace();
|
||||
const int NE = fes->GetNE();
|
||||
GridFunction *xdof = mesh->GetNodes();
|
||||
xdof->SetTrueVector();
|
||||
xdof->SetFromTrueVector();
|
||||
|
||||
el_energy_vec.SetSize(NE);
|
||||
el_energy_vec = std::numeric_limits<float>::max();
|
||||
|
||||
for (int e = 0; e < NE; e++)
|
||||
{
|
||||
Geometry::Type gtype = fes->GetFE(e)->GetGeomType();
|
||||
DenseMatrix tr, xsplit;
|
||||
IntegrationRule *irule = NULL;
|
||||
|
||||
if ( (gtype == Geometry::TRIANGLE && reftype > 0 && reftype < 3) ||
|
||||
(gtype == Geometry::CUBE && reftype > 0 && reftype < 7) ||
|
||||
(gtype == Geometry::TETRAHEDRON && reftype > 0 && reftype < 7) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (gtype)
|
||||
{
|
||||
case Geometry::TRIANGLE:
|
||||
{
|
||||
int ref_access = reftype == 0 ? 0 : 1;
|
||||
xdof->GetVectorValues(e, *TriIntRule[ref_access], xsplit, tr);
|
||||
irule = TriIntRule[ref_access];
|
||||
break;
|
||||
}
|
||||
case Geometry::TETRAHEDRON:
|
||||
{
|
||||
int ref_access = reftype == 0 ? 0 : 1;
|
||||
xdof->GetVectorValues(e, *TetIntRule[ref_access], xsplit, tr);
|
||||
irule = TetIntRule[ref_access];
|
||||
break;
|
||||
}
|
||||
case Geometry::SQUARE:
|
||||
{
|
||||
MFEM_VERIFY(QuadIntRule[reftype], " Integration rule does not exist.");
|
||||
xdof->GetVectorValues(e, *QuadIntRule[reftype], xsplit, tr);
|
||||
irule = QuadIntRule[reftype];
|
||||
break;
|
||||
}
|
||||
case Geometry::CUBE:
|
||||
{
|
||||
int ref_access = reftype == 0 ? 0 : 1;
|
||||
xdof->GetVectorValues(e, *HexIntRule[ref_access], xsplit, tr);
|
||||
irule = HexIntRule[ref_access];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
MFEM_ABORT("Incompatible geometry type!");
|
||||
}
|
||||
xsplit.Transpose();
|
||||
|
||||
el_energy_vec(e) = 0.; // Re-set to 0
|
||||
|
||||
// The data format is xe1,xe2,..xen,ye1,ye2..yen.
|
||||
// We will reformat it inside GetRefinementElementEnergy
|
||||
Vector elfun(xsplit.GetData(), xsplit.NumCols()*xsplit.NumRows());
|
||||
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
TMOP_Integrator *ti = NULL;
|
||||
TMOPComboIntegrator *co = NULL;
|
||||
for (int i = 0; i < integs.Size(); i++)
|
||||
{
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
el_energy_vec(e) = ti->GetRefinementElementEnergy(*fes->GetFE(e),
|
||||
*mesh->GetElementTransformation(e),
|
||||
elfun,
|
||||
*irule);
|
||||
}
|
||||
co = dynamic_cast<TMOPComboIntegrator *>(integs[i]);
|
||||
if (co)
|
||||
{
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
el_energy_vec(e) += ati[j]->GetRefinementElementEnergy(*fes->GetFE(e),
|
||||
*mesh->GetElementTransformation(e),
|
||||
elfun,
|
||||
*irule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPRefinerEstimator::SetHexIntRules()
|
||||
{
|
||||
HexIntRule.SetSize(1+1);
|
||||
// Reftype = 0 -> original element
|
||||
Mesh meshsplit = Mesh::MakeCartesian3D(1, 1, 1, Element::HEXAHEDRON);
|
||||
Mesh base_mesh_copy(meshsplit);
|
||||
HexIntRule[0] = SetIntRulesFromMesh(meshsplit);
|
||||
meshsplit.Clear();
|
||||
|
||||
// Reftype = 7
|
||||
for (int i = 7; i < 8; i++)
|
||||
{
|
||||
Array<Refinement> marked_elements;
|
||||
Mesh mesh_ref(base_mesh_copy);
|
||||
for (int e = 0; e < mesh_ref.GetNE(); e++)
|
||||
{
|
||||
marked_elements.Append(Refinement(e, i));
|
||||
}
|
||||
mesh_ref.GeneralRefinement(marked_elements, 1, 0);
|
||||
HexIntRule[1] = SetIntRulesFromMesh(mesh_ref);
|
||||
mesh_ref.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPRefinerEstimator::SetQuadIntRules()
|
||||
{
|
||||
QuadIntRule.SetSize(3+1);
|
||||
|
||||
// Reftype = 0 -> original element
|
||||
Mesh meshsplit = Mesh::MakeCartesian2D(1, 1, Element::QUADRILATERAL);
|
||||
Mesh base_mesh_copy(meshsplit);
|
||||
QuadIntRule[0] = SetIntRulesFromMesh(meshsplit);
|
||||
meshsplit.Clear();
|
||||
|
||||
// Reftype = 1-3
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
Array<Refinement> marked_elements;
|
||||
Mesh mesh_ref(base_mesh_copy);
|
||||
for (int e = 0; e < mesh_ref.GetNE(); e++)
|
||||
{
|
||||
marked_elements.Append(Refinement(e, i));
|
||||
}
|
||||
mesh_ref.GeneralRefinement(marked_elements, 1, 0);
|
||||
QuadIntRule[i] = SetIntRulesFromMesh(mesh_ref);
|
||||
mesh_ref.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPRefinerEstimator::SetTriIntRules()
|
||||
{
|
||||
TriIntRule.SetSize(1+1);
|
||||
|
||||
// Reftype = 0 // original element
|
||||
const int Nvert = 3, NEsplit = 1;
|
||||
Mesh meshsplit(2, Nvert, NEsplit, 0 ,2);
|
||||
const double tri_v[3][2] =
|
||||
{
|
||||
{0, 0}, {1, 0}, {0, 1}
|
||||
};
|
||||
const int tri_e[1][3] =
|
||||
{
|
||||
{0, 1, 2}
|
||||
};
|
||||
|
||||
for (int j = 0; j < Nvert; j++)
|
||||
{
|
||||
meshsplit.AddVertex(tri_v[j]);
|
||||
}
|
||||
meshsplit.AddTriangle(tri_e[0], 1);
|
||||
meshsplit.FinalizeTriMesh(1, 1, true);
|
||||
|
||||
Mesh base_mesh_copy(meshsplit);
|
||||
TriIntRule[0] = SetIntRulesFromMesh(meshsplit);
|
||||
meshsplit.Clear();
|
||||
|
||||
// no anisotropic refinements for triangle
|
||||
// Reftype = 3
|
||||
for (int i = 1; i < 2; i++)
|
||||
{
|
||||
Array<Refinement> marked_elements;
|
||||
Mesh mesh_ref(base_mesh_copy);
|
||||
for (int e = 0; e < mesh_ref.GetNE(); e++)
|
||||
{
|
||||
marked_elements.Append(Refinement(e, i));
|
||||
}
|
||||
mesh_ref.GeneralRefinement(marked_elements, 1, 0);
|
||||
TriIntRule[i] = SetIntRulesFromMesh(mesh_ref);
|
||||
mesh_ref.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPRefinerEstimator::SetTetIntRules()
|
||||
{
|
||||
TetIntRule.SetSize(1+1);
|
||||
|
||||
// Reftype = 0 // original element
|
||||
const int Nvert = 4, NEsplit = 1;
|
||||
Mesh meshsplit(3, Nvert, NEsplit, 0, 3);
|
||||
const double tet_v[4][3] =
|
||||
{
|
||||
{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}
|
||||
};
|
||||
const int tet_e[1][4] =
|
||||
{
|
||||
{0, 1, 2, 3}
|
||||
};
|
||||
|
||||
for (int j = 0; j < Nvert; j++)
|
||||
{
|
||||
meshsplit.AddVertex(tet_v[j]);
|
||||
}
|
||||
meshsplit.AddTet(tet_e[0], 1);
|
||||
meshsplit.FinalizeTetMesh(1, 1, true);
|
||||
|
||||
Mesh base_mesh_copy(meshsplit);
|
||||
TetIntRule[0] = SetIntRulesFromMesh(meshsplit);
|
||||
meshsplit.Clear();
|
||||
|
||||
// no anisotropic refinements for triangle
|
||||
// Reftype = 7
|
||||
for (int i = 1; i < 2; i++)
|
||||
{
|
||||
Array<Refinement> marked_elements;
|
||||
Mesh mesh_ref(base_mesh_copy);
|
||||
for (int e = 0; e < mesh_ref.GetNE(); e++)
|
||||
{
|
||||
marked_elements.Append(Refinement(e, i)); //ref_type will default to 7
|
||||
}
|
||||
mesh_ref.GeneralRefinement(marked_elements, 1, 0);
|
||||
TetIntRule[i] = SetIntRulesFromMesh(mesh_ref);
|
||||
mesh_ref.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
IntegrationRule* TMOPRefinerEstimator::SetIntRulesFromMesh(Mesh &meshsplit)
|
||||
{
|
||||
const int dim = meshsplit.Dimension();
|
||||
H1_FECollection fec(order, dim);
|
||||
FiniteElementSpace nodal_fes(&meshsplit, &fec, dim);
|
||||
meshsplit.SetNodalFESpace(&nodal_fes);
|
||||
|
||||
const int NEsplit = meshsplit.GetNE();
|
||||
const int dof_cnt = nodal_fes.GetFE(0)->GetDof(),
|
||||
pts_cnt = NEsplit * dof_cnt;
|
||||
|
||||
DenseMatrix pos(dof_cnt, dim);
|
||||
Vector posV(pos.Data(), dof_cnt * dim);
|
||||
Array<int> xdofs(dof_cnt * dim);
|
||||
|
||||
// Create an IntegrationRule on the nodes of the reference submesh.
|
||||
IntegrationRule *irule = new IntegrationRule(pts_cnt);
|
||||
GridFunction *nodesplit = meshsplit.GetNodes();
|
||||
|
||||
int pt_id = 0;
|
||||
for (int i = 0; i < NEsplit; i++)
|
||||
{
|
||||
nodal_fes.GetElementVDofs(i, xdofs);
|
||||
nodesplit->GetSubVector(xdofs, posV);
|
||||
for (int j = 0; j < dof_cnt; j++)
|
||||
{
|
||||
if (dim == 2)
|
||||
{
|
||||
irule->IntPoint(pt_id).Set2(pos(j, 0), pos(j, 1));
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
irule->IntPoint(pt_id).Set3(pos(j, 0), pos(j, 1), pos(j, 2));
|
||||
}
|
||||
pt_id++;
|
||||
}
|
||||
}
|
||||
return irule;
|
||||
}
|
||||
|
||||
bool TMOPDeRefinerEstimator::GetDerefineEnergyForIntegrator(
|
||||
TMOP_Integrator &tmopi,
|
||||
Vector &fine_energy)
|
||||
{
|
||||
DiscreteAdaptTC *tcd = tmopi.GetDiscreteAdaptTC();
|
||||
fine_energy.SetSize(mesh->GetNE());
|
||||
|
||||
if (serial)
|
||||
{
|
||||
Mesh meshcopy(*mesh);
|
||||
FiniteElementSpace *tcdfes = NULL;
|
||||
if (tcd)
|
||||
{
|
||||
tcdfes = new FiniteElementSpace(*tcd->GetTSpecFESpace(), &meshcopy);
|
||||
}
|
||||
|
||||
Vector local_err(meshcopy.GetNE());
|
||||
local_err = 0.;
|
||||
double threshold = std::numeric_limits<float>::max();
|
||||
meshcopy.DerefineByError(local_err, threshold, 0, 1);
|
||||
|
||||
if (meshcopy.GetGlobalNE() == mesh->GetGlobalNE())
|
||||
{
|
||||
delete tcdfes;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tcd)
|
||||
{
|
||||
tcdfes->Update();
|
||||
tcd->SetTspecDataForDerefinement(tcdfes);
|
||||
}
|
||||
|
||||
Vector coarse_energy(meshcopy.GetNE());
|
||||
GetTMOPDerefinementEnergy(meshcopy, tmopi, coarse_energy);
|
||||
if (tcd) { tcd->ResetDerefinementTspecData(); }
|
||||
GetTMOPDerefinementEnergy(*mesh, tmopi, fine_energy);
|
||||
|
||||
const CoarseFineTransformations &dtrans =
|
||||
meshcopy.ncmesh->GetDerefinementTransforms();
|
||||
Table coarse_to_fine;
|
||||
dtrans.GetCoarseToFineMap(meshcopy, coarse_to_fine);
|
||||
|
||||
for (int pe = 0; pe < coarse_to_fine.Size(); pe++)
|
||||
{
|
||||
Array<int> tabrow;
|
||||
coarse_to_fine.GetRow(pe, tabrow);
|
||||
int nchild = tabrow.Size();
|
||||
double parent_energy = coarse_energy(pe);
|
||||
for (int fe = 0; fe < nchild; fe++)
|
||||
{
|
||||
int child = tabrow[fe];
|
||||
MFEM_VERIFY(child < mesh->GetNE(), " invalid coarse to fine mapping");
|
||||
fine_energy(child) -= parent_energy;
|
||||
}
|
||||
}
|
||||
delete tcdfes;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef MFEM_USE_MPI
|
||||
ParMesh meshcopy(*pmesh);
|
||||
ParFiniteElementSpace *tcdfes = NULL;
|
||||
if (tcd)
|
||||
{
|
||||
tcdfes = new ParFiniteElementSpace(*tcd->GetTSpecParFESpace(), meshcopy);
|
||||
}
|
||||
|
||||
Vector local_err(meshcopy.GetNE());
|
||||
local_err = 0.;
|
||||
double threshold = std::numeric_limits<float>::max();
|
||||
meshcopy.DerefineByError(local_err, threshold, 0, 1);
|
||||
|
||||
if (meshcopy.GetGlobalNE() == pmesh->GetGlobalNE())
|
||||
{
|
||||
delete tcdfes;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tcd)
|
||||
{
|
||||
tcdfes->Update();
|
||||
tcd->SetTspecDataForDerefinement(tcdfes);
|
||||
}
|
||||
|
||||
Vector coarse_energy(meshcopy.GetNE());
|
||||
GetTMOPDerefinementEnergy(meshcopy, tmopi, coarse_energy);
|
||||
if (tcd) { tcd->ResetDerefinementTspecData(); }
|
||||
GetTMOPDerefinementEnergy(*pmesh, tmopi, fine_energy);
|
||||
|
||||
const CoarseFineTransformations &dtrans =
|
||||
meshcopy.pncmesh->GetDerefinementTransforms();
|
||||
Table coarse_to_fine;
|
||||
dtrans.GetCoarseToFineMap(meshcopy, coarse_to_fine);
|
||||
|
||||
for (int pe = 0; pe < meshcopy.GetNE(); pe++)
|
||||
{
|
||||
Array<int> tabrow;
|
||||
coarse_to_fine.GetRow(pe, tabrow);
|
||||
int nchild = tabrow.Size();
|
||||
double parent_energy = coarse_energy(pe);
|
||||
for (int fe = 0; fe < nchild; fe++)
|
||||
{
|
||||
int child = tabrow[fe];
|
||||
MFEM_VERIFY(child < pmesh->GetNE(), " invalid coarse to fine mapping");
|
||||
fine_energy(child) -= parent_energy;
|
||||
}
|
||||
}
|
||||
delete tcdfes;
|
||||
#endif
|
||||
}
|
||||
|
||||
// error_estimate(e) = energy(parent_of_e)-energy(e)
|
||||
// Negative energy means derefinement is desirable.
|
||||
fine_energy *= -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMOPDeRefinerEstimator::ComputeEstimates()
|
||||
{
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
TMOP_Integrator *ti = NULL;
|
||||
TMOPComboIntegrator *co = NULL;
|
||||
error_estimates.SetSize(mesh->GetNE());
|
||||
error_estimates = 0.;
|
||||
Vector fine_energy(mesh->GetNE());
|
||||
|
||||
for (int i = 0; i < integs.Size(); i++)
|
||||
{
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
bool deref = GetDerefineEnergyForIntegrator(*ti, fine_energy);
|
||||
if (!deref) { error_estimates = 1; return; }
|
||||
error_estimates += fine_energy;
|
||||
}
|
||||
co = dynamic_cast<TMOPComboIntegrator *>(integs[i]);
|
||||
if (co)
|
||||
{
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
bool deref = GetDerefineEnergyForIntegrator(*ati[j], fine_energy);
|
||||
if (!deref) { error_estimates = 1; return; }
|
||||
error_estimates += fine_energy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMOPDeRefinerEstimator::GetTMOPDerefinementEnergy(Mesh &cmesh,
|
||||
TMOP_Integrator &tmopi,
|
||||
Vector &el_energy_vec)
|
||||
{
|
||||
const int cNE = cmesh.GetNE();
|
||||
el_energy_vec.SetSize(cNE);
|
||||
const FiniteElementSpace *fespace = cmesh.GetNodalFESpace();
|
||||
|
||||
GridFunction *cxdof = cmesh.GetNodes();
|
||||
|
||||
Array<int> vdofs;
|
||||
Vector el_x;
|
||||
const FiniteElement *fe;
|
||||
ElementTransformation *T;
|
||||
|
||||
for (int j = 0; j < cNE; j++)
|
||||
{
|
||||
fe = fespace->GetFE(j);
|
||||
fespace->GetElementVDofs(j, vdofs);
|
||||
T = cmesh.GetElementTransformation(j);
|
||||
cxdof->GetSubVector(vdofs, el_x);
|
||||
el_energy_vec(j) = tmopi.GetDerefinementElementEnergy(*fe, *T, el_x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TMOPHRSolver::TMOPHRSolver(Mesh &mesh_, NonlinearForm &nlf_,
|
||||
TMOPNewtonSolver &tmopns_, GridFunction &x_,
|
||||
bool move_bnd_, bool hradaptivity_,
|
||||
int mesh_poly_deg_, int amr_metric_id_,
|
||||
int hr_iter_, int h_per_r_iter_) :
|
||||
mesh(&mesh_), nlf(&nlf_), tmopns(&tmopns_), x(&x_),
|
||||
gridfuncarr(), fespacearr(),
|
||||
move_bnd(move_bnd_), hradaptivity(hradaptivity_),
|
||||
mesh_poly_deg(mesh_poly_deg_), amr_metric_id(amr_metric_id_),
|
||||
serial(true), hr_iter(hr_iter_), h_per_r_iter(h_per_r_iter_)
|
||||
{
|
||||
if (!hradaptivity) { return; }
|
||||
tmop_r_est = new TMOPRefinerEstimator(*mesh, *nlf, mesh_poly_deg,
|
||||
amr_metric_id);
|
||||
tmop_r = new ThresholdRefiner(*tmop_r_est);
|
||||
tmop_r->SetTotalErrorFraction(0.0);
|
||||
tmop_r_est->SetEnergyScalingFactor(1.);
|
||||
tmop_dr_est= new TMOPDeRefinerEstimator(*mesh, *nlf);
|
||||
tmop_dr = new ThresholdDerefiner(*tmop_dr_est);
|
||||
AddGridFunctionForUpdate(x);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
TMOPHRSolver::TMOPHRSolver(ParMesh &pmesh_, ParNonlinearForm &pnlf_,
|
||||
TMOPNewtonSolver &tmopns_, ParGridFunction &px_,
|
||||
bool move_bnd_, bool hradaptivity_,
|
||||
int mesh_poly_deg_, int amr_metric_id_,
|
||||
int hr_iter_, int h_per_r_iter_) :
|
||||
mesh(&pmesh_), nlf(&pnlf_), tmopns(&tmopns_), x(&px_),
|
||||
gridfuncarr(), fespacearr(),
|
||||
move_bnd(move_bnd_), hradaptivity(hradaptivity_),
|
||||
mesh_poly_deg(mesh_poly_deg_), amr_metric_id(amr_metric_id_),
|
||||
pmesh(&pmesh_), pnlf(&pnlf_), pgridfuncarr(), pfespacearr(),
|
||||
serial(false), hr_iter(hr_iter_), h_per_r_iter(h_per_r_iter_)
|
||||
{
|
||||
if (!hradaptivity) { return; }
|
||||
tmop_r_est = new TMOPRefinerEstimator(*pmesh, *pnlf, mesh_poly_deg,
|
||||
amr_metric_id);
|
||||
tmop_r = new ThresholdRefiner(*tmop_r_est);
|
||||
tmop_r->SetTotalErrorFraction(0.0);
|
||||
tmop_r_est->SetEnergyScalingFactor(1.);
|
||||
tmop_dr_est= new TMOPDeRefinerEstimator(*pmesh, *pnlf);
|
||||
tmop_dr = new ThresholdDerefiner(*tmop_dr_est);
|
||||
AddGridFunctionForUpdate(&px_);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOPHRSolver::Mult()
|
||||
{
|
||||
Vector b(0);
|
||||
int myid = 0;
|
||||
if (serial)
|
||||
{
|
||||
tmopns->SetOperator(*nlf);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef MFEM_USE_MPI
|
||||
myid = pnlf->ParFESpace()->GetMyRank();
|
||||
tmopns->SetOperator(*pnlf);
|
||||
#endif
|
||||
}
|
||||
if (!hradaptivity)
|
||||
{
|
||||
tmopns->Mult(b, x->GetTrueVector());
|
||||
if (tmopns->GetConverged() == false)
|
||||
{
|
||||
if (myid == 0) { mfem::out << "Nonlinear solver: rtol not achieved.\n"; }
|
||||
}
|
||||
x->SetFromTrueVector();
|
||||
return;
|
||||
}
|
||||
|
||||
bool radaptivity = true;
|
||||
|
||||
tmop_dr->Reset();
|
||||
tmop_r->Reset();
|
||||
|
||||
if (serial)
|
||||
{
|
||||
for (int i_hr = 0; i_hr < hr_iter; i_hr++)
|
||||
{
|
||||
if (!radaptivity)
|
||||
{
|
||||
break;
|
||||
}
|
||||
mfem::out << i_hr << " r-adaptivity iteration.\n";
|
||||
|
||||
tmopns->SetOperator(*nlf);
|
||||
tmopns->Mult(b, x->GetTrueVector());
|
||||
x->SetFromTrueVector();
|
||||
|
||||
mfem::out << "TMOP energy after r-adaptivity: " <<
|
||||
nlf->GetGridFunctionEnergy(*x)/mesh->GetNE() <<
|
||||
", Elements: " << mesh->GetNE() << std::endl;
|
||||
|
||||
for (int i_h = 0; i_h < h_per_r_iter; i_h++)
|
||||
{
|
||||
// Derefinement step.
|
||||
if (mesh->ncmesh)
|
||||
{
|
||||
tmop_dr->Apply(*mesh);
|
||||
Update();
|
||||
}
|
||||
mfem::out << "TMOP energy after derefinement: " <<
|
||||
nlf->GetGridFunctionEnergy(*x)/mesh->GetNE() <<
|
||||
", Elements: " << mesh->GetNE() << std::endl;
|
||||
|
||||
// Refinement step.
|
||||
tmop_r->Apply(*mesh);
|
||||
Update();
|
||||
mfem::out << "TMOP energy after refinement: " <<
|
||||
nlf->GetGridFunctionEnergy(*x)/mesh->GetNE() <<
|
||||
", Elements: " << mesh->GetNE() << std::endl;
|
||||
|
||||
if (!tmop_dr->Derefined() && tmop_r->Stop())
|
||||
{
|
||||
radaptivity = false;
|
||||
mfem::out << "AMR stopping criterion satisfied. Stop.\n";
|
||||
break;
|
||||
}
|
||||
} //n_h
|
||||
} //n_hr
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef MFEM_USE_MPI
|
||||
int NEGlob;
|
||||
double tmopenergy;
|
||||
for (int i_hr = 0; i_hr < hr_iter; i_hr++)
|
||||
{
|
||||
if (!radaptivity)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (myid == 0) { mfem::out << i_hr << " r-adaptivity iteration.\n"; }
|
||||
tmopns->SetOperator(*pnlf);
|
||||
tmopns->Mult(b, x->GetTrueVector());
|
||||
x->SetFromTrueVector();
|
||||
|
||||
NEGlob = pmesh->GetGlobalNE();
|
||||
tmopenergy = pnlf->GetParGridFunctionEnergy(*x) / NEGlob;
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "TMOP energy after r-adaptivity: " << tmopenergy <<
|
||||
", Elements: " << NEGlob << std::endl;
|
||||
}
|
||||
|
||||
for (int i_h = 0; i_h < h_per_r_iter; i_h++)
|
||||
{
|
||||
// Derefinement step.
|
||||
if (pmesh->pncmesh)
|
||||
{
|
||||
RebalanceParNCMesh();
|
||||
ParUpdate();
|
||||
|
||||
tmop_dr->Apply(*pmesh);
|
||||
ParUpdate();
|
||||
}
|
||||
NEGlob = pmesh->GetGlobalNE();
|
||||
tmopenergy = pnlf->GetParGridFunctionEnergy(*x) / NEGlob;
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "TMOP energy after derefinement: " << tmopenergy <<
|
||||
", Elements: " << NEGlob << std::endl;
|
||||
}
|
||||
|
||||
// Refinement step.
|
||||
tmop_r->Apply(*pmesh);
|
||||
ParUpdate();
|
||||
NEGlob = pmesh->GetGlobalNE();
|
||||
tmopenergy = pnlf->GetParGridFunctionEnergy(*x) / NEGlob;
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "TMOP energy after refinement: " << tmopenergy <<
|
||||
", Elements: " << NEGlob << std::endl;
|
||||
}
|
||||
|
||||
if (!tmop_dr->Derefined() && tmop_r->Stop())
|
||||
{
|
||||
radaptivity = false;
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "AMR stopping criterion satisfied. Stop.\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} //n_r limit
|
||||
} //n_hr
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOPHRSolver::RebalanceParNCMesh()
|
||||
{
|
||||
ParNCMesh *pncmesh = pmesh->pncmesh;
|
||||
if (pncmesh)
|
||||
{
|
||||
const Table &dreftable = pncmesh->GetDerefinementTable();
|
||||
Array<int> drefs, new_ranks;
|
||||
for (int i = 0; i < dreftable.Size(); i++)
|
||||
{
|
||||
drefs.Append(i);
|
||||
}
|
||||
pncmesh->GetFineToCoarsePartitioning(drefs, new_ranks);
|
||||
pmesh->Rebalance(new_ranks);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOPHRSolver::Update()
|
||||
{
|
||||
// Update FESpace
|
||||
for (int i = 0; i < fespacearr.Size(); i++)
|
||||
{
|
||||
fespacearr[i]->Update();
|
||||
}
|
||||
// Update nodal GF
|
||||
for (int i = 0; i < gridfuncarr.Size(); i++)
|
||||
{
|
||||
gridfuncarr[i]->Update();
|
||||
gridfuncarr[i]->SetTrueVector();
|
||||
gridfuncarr[i]->SetFromTrueVector();
|
||||
}
|
||||
|
||||
// Update Discrete Indicator for all the TMOP_Integrators in NonLinearForm
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
TMOP_Integrator *ti = NULL;
|
||||
TMOPComboIntegrator *co = NULL;
|
||||
DiscreteAdaptTC *dtc = NULL;
|
||||
for (int i = 0; i < integs.Size(); i++)
|
||||
{
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
ti->UpdateAfterMeshTopologyChange();
|
||||
dtc = ti->GetDiscreteAdaptTC();
|
||||
if (dtc) { dtc->UpdateAfterMeshTopologyChange(); }
|
||||
}
|
||||
co = dynamic_cast<TMOPComboIntegrator *>(integs[i]);
|
||||
if (co)
|
||||
{
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
ati[j]->UpdateAfterMeshTopologyChange();
|
||||
dtc = ati[j]->GetDiscreteAdaptTC();
|
||||
if (dtc) { dtc->UpdateAfterMeshTopologyChange(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the Nonlinear form and set Essential BC.
|
||||
UpdateNonlinearFormAndBC(mesh, nlf);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void TMOPHRSolver::ParUpdate()
|
||||
{
|
||||
// Update FESpace
|
||||
for (int i = 0; i < pfespacearr.Size(); i++)
|
||||
{
|
||||
pfespacearr[i]->Update();
|
||||
}
|
||||
// Update nodal GF
|
||||
for (int i = 0; i < pgridfuncarr.Size(); i++)
|
||||
{
|
||||
pgridfuncarr[i]->Update();
|
||||
pgridfuncarr[i]->SetTrueVector();
|
||||
pgridfuncarr[i]->SetFromTrueVector();
|
||||
}
|
||||
|
||||
// Update Discrete Indicator
|
||||
Array<NonlinearFormIntegrator*> &integs = *(nlf->GetDNFI());
|
||||
TMOP_Integrator *ti = NULL;
|
||||
TMOPComboIntegrator *co = NULL;
|
||||
DiscreteAdaptTC *dtc = NULL;
|
||||
for (int i = 0; i < integs.Size(); i++)
|
||||
{
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
ti->ParUpdateAfterMeshTopologyChange();
|
||||
dtc = ti->GetDiscreteAdaptTC();
|
||||
if (dtc) { dtc->ParUpdateAfterMeshTopologyChange(); }
|
||||
}
|
||||
co = dynamic_cast<TMOPComboIntegrator *>(integs[i]);
|
||||
if (co)
|
||||
{
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
ati[j]->ParUpdateAfterMeshTopologyChange();
|
||||
dtc = ati[j]->GetDiscreteAdaptTC();
|
||||
if (dtc) { dtc->ParUpdateAfterMeshTopologyChange(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the Nonlinear form and set Essential BC.
|
||||
UpdateNonlinearFormAndBC(pmesh, pnlf);
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOPHRSolver::UpdateNonlinearFormAndBC(Mesh *mesh, NonlinearForm *nlf)
|
||||
{
|
||||
const FiniteElementSpace &fes = *mesh->GetNodalFESpace();
|
||||
|
||||
// Update Nonlinear form and Set Essential BC
|
||||
nlf->Update();
|
||||
const int dim = fes.GetFE(0)->GetDim();
|
||||
if (move_bnd == false)
|
||||
{
|
||||
Array<int> ess_bdr(mesh->bdr_attributes.Max());
|
||||
ess_bdr = 1;
|
||||
nlf->SetEssentialBC(ess_bdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int nd = fes.GetBE(0)->GetDof();
|
||||
int n = 0;
|
||||
for (int i = 0; i < mesh->GetNBE(); i++)
|
||||
{
|
||||
const int attr = mesh->GetBdrElement(i)->GetAttribute();
|
||||
MFEM_VERIFY(!(dim == 2 && attr == 3),
|
||||
"Boundary attribute 3 must be used only for 3D meshes. "
|
||||
"Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
|
||||
"components, rest for free nodes), or use -fix-bnd.");
|
||||
if (attr == 1 || attr == 2 || attr == 3) { n += nd; }
|
||||
if (attr == 4) { n += nd * dim; }
|
||||
}
|
||||
Array<int> ess_vdofs(n), vdofs;
|
||||
n = 0;
|
||||
for (int i = 0; i < mesh->GetNBE(); i++)
|
||||
{
|
||||
const int attr = mesh->GetBdrElement(i)->GetAttribute();
|
||||
fes.GetBdrElementVDofs(i, vdofs);
|
||||
if (attr == 1) // Fix x components.
|
||||
{
|
||||
for (int j = 0; j < nd; j++)
|
||||
{ ess_vdofs[n++] = vdofs[j]; }
|
||||
}
|
||||
else if (attr == 2) // Fix y components.
|
||||
{
|
||||
for (int j = 0; j < nd; j++)
|
||||
{ ess_vdofs[n++] = vdofs[j+nd]; }
|
||||
}
|
||||
else if (attr == 3) // Fix z components.
|
||||
{
|
||||
for (int j = 0; j < nd; j++)
|
||||
{ ess_vdofs[n++] = vdofs[j+2*nd]; }
|
||||
}
|
||||
else if (attr == 4) // Fix all components.
|
||||
{
|
||||
for (int j = 0; j < vdofs.Size(); j++)
|
||||
{ ess_vdofs[n++] = vdofs[j]; }
|
||||
}
|
||||
}
|
||||
nlf->SetEssentialVDofs(ess_vdofs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
// Copyright (c) 2010-2021, 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.
|
||||
|
||||
#ifndef MFEM_TMOP_AMR_HPP
|
||||
#define MFEM_TMOP_AMR_HPP
|
||||
|
||||
#include "tmop_tools.hpp"
|
||||
#include "nonlinearform.hpp"
|
||||
#include "pnonlinearform.hpp"
|
||||
#include "estimators.hpp"
|
||||
#include "../mesh/mesh_operators.hpp"
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
class TMOPRefinerEstimator : public AnisotropicErrorEstimator
|
||||
{
|
||||
protected:
|
||||
Mesh *mesh; // not owned
|
||||
NonlinearForm *nlf; // not owned
|
||||
int order;
|
||||
int amrmetric;
|
||||
Array<IntegrationRule *> TriIntRule, QuadIntRule, TetIntRule, HexIntRule;
|
||||
long current_sequence;
|
||||
Vector error_estimates;
|
||||
Array<int> aniso_flags;
|
||||
// An element is refined only if
|
||||
// [mean TMOPEnergy(children)]*energy_scaling_factor < TMOPEnergy(parent)
|
||||
double energy_scaling_factor;
|
||||
GridFunction *spat_gf; // If specified, can be used to specify the
|
||||
double spat_gf_critical; // region where hr-adaptivity is done.
|
||||
|
||||
/// Check if the mesh of the solution was modified.
|
||||
bool MeshIsModified()
|
||||
{
|
||||
long mesh_sequence = mesh->GetSequence();
|
||||
MFEM_ASSERT(mesh_sequence >= current_sequence, "");
|
||||
return (mesh_sequence > current_sequence);
|
||||
}
|
||||
|
||||
/// Compute the element error estimates. For an element E in the mesh,
|
||||
/// error(E) = TMOPEnergy(E)*energy_scaling_factor-Mean(TMOPEnergy(ChildofE)),
|
||||
/// where TMOPEnergy of Children of E is obtained by assuming the element E
|
||||
/// is refined using the refinement type being considered based on the TMOP
|
||||
/// mesh quality metric.
|
||||
void ComputeEstimates();
|
||||
|
||||
/// Construct the integration rules to model how each element type is split
|
||||
/// using different refinement types. ref_type = 0 is the original element
|
||||
/// and reftype \ in [1, 7] represent different refinement type based on
|
||||
/// NCMesh class.
|
||||
void SetQuadIntRules(); // supports ref_type = 1 to 3.
|
||||
void SetTriIntRules(); // currently supports only isotropic refinement.
|
||||
void SetHexIntRules(); // currently supports only isotropic refinement.
|
||||
void SetTetIntRules(); // currently supports only isotropic refinement.
|
||||
|
||||
/// Get TMOP energy for each element corresponding to the refinement type
|
||||
/// specified.
|
||||
void GetTMOPRefinementEnergy(int reftype, Vector &el_energy_vec);
|
||||
|
||||
/// Use a mesh to setup an integration rule that will mimic the different
|
||||
/// refinement types.
|
||||
IntegrationRule* SetIntRulesFromMesh(Mesh &meshsplit);
|
||||
public:
|
||||
TMOPRefinerEstimator(Mesh &mesh_, NonlinearForm &nlf_, int order_,
|
||||
int amrmetric_) :
|
||||
mesh(&mesh_), nlf(&nlf_), order(order_), amrmetric(amrmetric_),
|
||||
TriIntRule(0), QuadIntRule(0), TetIntRule(0), HexIntRule(0),
|
||||
current_sequence(-1), error_estimates(), aniso_flags(),
|
||||
energy_scaling_factor(1.), spat_gf(NULL), spat_gf_critical(0.)
|
||||
{
|
||||
if (mesh->Dimension() == 2)
|
||||
{
|
||||
SetQuadIntRules();
|
||||
SetTriIntRules();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHexIntRules();
|
||||
SetTetIntRules();
|
||||
}
|
||||
}
|
||||
|
||||
~TMOPRefinerEstimator()
|
||||
{
|
||||
for (int i = 0; i < QuadIntRule.Size(); i++) { delete QuadIntRule[i]; }
|
||||
for (int i = 0; i < TriIntRule.Size(); i++) { delete TriIntRule[i]; }
|
||||
for (int i = 0; i < HexIntRule.Size(); i++) { delete HexIntRule[i]; }
|
||||
for (int i = 0; i < TetIntRule.Size(); i++) { delete TetIntRule[i]; }
|
||||
}
|
||||
|
||||
/// Get TMOP-based errors for each element in the mesh computed based on the
|
||||
/// refinement types being considered.
|
||||
virtual const Vector &GetLocalErrors()
|
||||
{
|
||||
if (MeshIsModified()) { ComputeEstimates(); }
|
||||
return error_estimates;
|
||||
}
|
||||
/// For anisotropic refinements, get the refinement type (e.g., x or y)
|
||||
virtual const Array<int> &GetAnisotropicFlags()
|
||||
{
|
||||
if (MeshIsModified()) { ComputeEstimates(); }
|
||||
return aniso_flags;
|
||||
}
|
||||
|
||||
/// Scaling factor for the TMOP refinement energy. An element is refined if
|
||||
/// [mean TMOPEnergy(children)]*energy_scaling_factor < TMOPEnergy(parent)
|
||||
void SetEnergyScalingFactor(double scale) { energy_scaling_factor = scale; }
|
||||
|
||||
/// Spatial indicator function (eta) that can be used to prevent elements
|
||||
/// from being refined even if the energy criterion is met. Using this,
|
||||
/// an element E is not refined if mean(@a spat_gf(E)) < @a spat_gf_critical.
|
||||
void SetSpatialIndicator(GridFunction &spat_gf_,
|
||||
double spat_gf_critical_ = 0.5)
|
||||
{ spat_gf = &spat_gf_; spat_gf_critical = spat_gf_critical_; }
|
||||
void SetSpatialIndicatorCritical(double val_) { spat_gf_critical = val_; }
|
||||
|
||||
/// Reset the error estimator.
|
||||
virtual void Reset() { current_sequence = -1; }
|
||||
};
|
||||
|
||||
class TMOPDeRefinerEstimator : public ErrorEstimator
|
||||
{
|
||||
protected:
|
||||
Mesh *mesh;
|
||||
NonlinearForm *nlf;
|
||||
#ifdef MFEM_USE_MPI
|
||||
ParMesh *pmesh;
|
||||
ParNonlinearForm *pnlf;
|
||||
#endif
|
||||
int order;
|
||||
int amrmetric;
|
||||
long current_sequence;
|
||||
Vector error_estimates;
|
||||
bool serial;
|
||||
|
||||
/// Check if the mesh of the solution was modified.
|
||||
bool MeshIsModified()
|
||||
{
|
||||
long mesh_sequence = mesh->GetSequence();
|
||||
MFEM_ASSERT(mesh_sequence >= current_sequence, "");
|
||||
return (mesh_sequence > current_sequence);
|
||||
}
|
||||
|
||||
/// Compute the element error estimates. For a given element E in the mesh,
|
||||
/// error(E) = TMOPEnergy(parent_of_E)-TMOPEnergy(E). Children element of an
|
||||
/// element are derefined if the mean TMOP energy of children is greated than
|
||||
/// the TMOP energy associated with their parent.
|
||||
void ComputeEstimates();
|
||||
|
||||
void GetTMOPDerefinementEnergy(Mesh &cmesh,
|
||||
TMOP_Integrator &tmopi,
|
||||
Vector &el_energy_vec);
|
||||
|
||||
bool GetDerefineEnergyForIntegrator(TMOP_Integrator &tmopi,
|
||||
Vector &fine_energy);
|
||||
public:
|
||||
TMOPDeRefinerEstimator(Mesh &mesh_, NonlinearForm &nlf_) :
|
||||
mesh(&mesh_), nlf(&nlf_),
|
||||
current_sequence(-1), error_estimates(), serial(true) { }
|
||||
#ifdef MFEM_USE_MPI
|
||||
TMOPDeRefinerEstimator(ParMesh &pmesh_, ParNonlinearForm &pnlf_) :
|
||||
mesh(&pmesh_), nlf(&pnlf_), pmesh(&pmesh_), pnlf(&pnlf_),
|
||||
current_sequence(-1), error_estimates(), serial(false) { }
|
||||
#endif
|
||||
|
||||
~TMOPDeRefinerEstimator() { }
|
||||
|
||||
virtual const Vector &GetLocalErrors()
|
||||
{
|
||||
if (MeshIsModified()) { ComputeEstimates(); }
|
||||
return error_estimates;
|
||||
}
|
||||
|
||||
/// Reset the error estimator.
|
||||
virtual void Reset() { current_sequence = -1; }
|
||||
};
|
||||
|
||||
// hr-adaptivity using TMOP.
|
||||
// If hr-adaptivity is disabled, r-adaptivity is done once using the
|
||||
// TMOPNewtonSolver.
|
||||
// Otherwise, "hr_iter" iterations of r-adaptivity are done followed by
|
||||
// "h_per_r_iter" iterations of h-adaptivity after each r-adaptivity iteration.
|
||||
// The solver terminates early if an h-adaptivity iteration does not
|
||||
// refine/derefine any element in the mesh.
|
||||
class TMOPHRSolver
|
||||
{
|
||||
protected:
|
||||
Mesh *mesh;
|
||||
NonlinearForm *nlf;
|
||||
TMOPNewtonSolver *tmopns;
|
||||
GridFunction *x;
|
||||
Array<GridFunction *> gridfuncarr;
|
||||
Array<FiniteElementSpace *> fespacearr;
|
||||
bool move_bnd, hradaptivity;
|
||||
const int mesh_poly_deg, amr_metric_id;
|
||||
#ifdef MFEM_USE_MPI
|
||||
ParMesh *pmesh;
|
||||
ParNonlinearForm *pnlf;
|
||||
Array<ParGridFunction *> pgridfuncarr;
|
||||
Array<ParFiniteElementSpace *> pfespacearr;
|
||||
#endif
|
||||
bool serial;
|
||||
|
||||
// All are owned.
|
||||
TMOPRefinerEstimator *tmop_r_est;
|
||||
ThresholdRefiner *tmop_r;
|
||||
TMOPDeRefinerEstimator *tmop_dr_est;
|
||||
ThresholdDerefiner *tmop_dr;
|
||||
|
||||
int hr_iter, h_per_r_iter;
|
||||
|
||||
void Update();
|
||||
#ifdef MFEM_USE_MPI
|
||||
void ParUpdate();
|
||||
#endif
|
||||
void UpdateNonlinearFormAndBC(Mesh *mesh, NonlinearForm *nlf);
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
// Rebalance ParMesh such that all the children elements are moved to the same
|
||||
// MPI rank where the parent will be if the mesh were to be derefined.
|
||||
void RebalanceParNCMesh();
|
||||
#endif
|
||||
|
||||
public:
|
||||
TMOPHRSolver(Mesh &mesh_, NonlinearForm &nlf_,
|
||||
TMOPNewtonSolver &tmopns_, GridFunction &x_,
|
||||
bool move_bnd_, bool hradaptivity_,
|
||||
int mesh_poly_deg_, int amr_metric_id_,
|
||||
int hr_iter_ = 5, int h_per_r_iter_ = 1);
|
||||
#ifdef MFEM_USE_MPI
|
||||
TMOPHRSolver(ParMesh &pmesh_, ParNonlinearForm &pnlf_,
|
||||
TMOPNewtonSolver &tmopns_, ParGridFunction &x_,
|
||||
bool move_bnd_, bool hradaptivity_,
|
||||
int mesh_poly_deg_, int amr_metric_id_,
|
||||
int hr_iter_ = 5, int h_per_r_iter_ = 1);
|
||||
#endif
|
||||
|
||||
void Mult();
|
||||
|
||||
/// These are used to update spaces and functions that are not owned by the
|
||||
/// TMOPIntegrator or DiscreteAdaptTC. The owned ones are updated in the
|
||||
/// functions UpdateAfterMeshTopologyChange() of both classes.
|
||||
void AddGridFunctionForUpdate(GridFunction *gf) { gridfuncarr.Append(gf); }
|
||||
void AddFESpaceForUpdate(FiniteElementSpace *fes) { fespacearr.Append(fes); }
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
void AddGridFunctionForUpdate(ParGridFunction *pgf_)
|
||||
{
|
||||
pgridfuncarr.Append(pgf_);
|
||||
}
|
||||
void AddFESpaceForUpdate(ParFiniteElementSpace *pfes_)
|
||||
{
|
||||
pfespacearr.Append(pfes_);
|
||||
}
|
||||
#endif
|
||||
|
||||
~TMOPHRSolver()
|
||||
{
|
||||
if (!hradaptivity) { return; }
|
||||
delete tmop_dr;
|
||||
delete tmop_dr_est;
|
||||
delete tmop_r;
|
||||
delete tmop_r_est;
|
||||
}
|
||||
|
||||
/// Total number of hr-adaptivity iterations. At each iteration, we do an
|
||||
/// r-adaptivity iteration followed by a number of h-adaptivity iterations.
|
||||
void SetHRAdaptivityIterations(int iter) { hr_iter = iter; }
|
||||
|
||||
/// Total number of h-adaptivity iterations per r-adaptivity iteration.
|
||||
void SetHAdaptivityIterations(int iter) { h_per_r_iter = iter; }
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
+6
-4
@@ -407,6 +407,8 @@ double TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
|
||||
{
|
||||
// Needed for the line search below. The untangling metrics see this
|
||||
// reference to detect deteriorations.
|
||||
MFEM_VERIFY(min_det_ptr != NULL, " Initial mesh was valid, but"
|
||||
" intermediate mesh is invalid. Contact TMOP Developers.");
|
||||
*min_det_ptr = untangle_factor * min_detT_in;
|
||||
}
|
||||
|
||||
@@ -576,7 +578,7 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &x) const
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
ti->UpdateAfterMeshChange(x_loc);
|
||||
ti->UpdateAfterMeshPositionChange(x_loc);
|
||||
ti->ComputeFDh(x_loc, *pfesc);
|
||||
UpdateDiscreteTC(*ti, x_loc);
|
||||
}
|
||||
@@ -586,7 +588,7 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &x) const
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
ati[j]->UpdateAfterMeshChange(x_loc);
|
||||
ati[j]->UpdateAfterMeshPositionChange(x_loc);
|
||||
ati[j]->ComputeFDh(x_loc, *pfesc);
|
||||
UpdateDiscreteTC(*ati[j], x_loc);
|
||||
}
|
||||
@@ -613,7 +615,7 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &x) const
|
||||
ti = dynamic_cast<TMOP_Integrator *>(integs[i]);
|
||||
if (ti)
|
||||
{
|
||||
ti->UpdateAfterMeshChange(x_loc);
|
||||
ti->UpdateAfterMeshPositionChange(x_loc);
|
||||
ti->ComputeFDh(x_loc, *fesc);
|
||||
UpdateDiscreteTC(*ti, x_loc);
|
||||
}
|
||||
@@ -623,7 +625,7 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &x) const
|
||||
Array<TMOP_Integrator *> ati = co->GetTMOPIntegrators();
|
||||
for (int j = 0; j < ati.Size(); j++)
|
||||
{
|
||||
ati[j]->UpdateAfterMeshChange(x_loc);
|
||||
ati[j]->UpdateAfterMeshPositionChange(x_loc);
|
||||
ati[j]->ComputeFDh(x_loc, *fesc);
|
||||
UpdateDiscreteTC(*ati[j], x_loc);
|
||||
}
|
||||
|
||||
@@ -339,6 +339,10 @@ inline bool operator!=(const Array<T> &LHS, const Array<T> &RHS)
|
||||
}
|
||||
|
||||
|
||||
/// Utility function similar to std::as_const in c++17.
|
||||
template <typename T> const T &AsConst(T &a) { return a; }
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array2D;
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ void mfem_backtrace(int mode, int depth)
|
||||
int err = unw_getcontext(&uc);
|
||||
err = err ? err : unw_init_local(&cursor, &uc);
|
||||
|
||||
Array<unw_word_t> addrs;
|
||||
Array<unw_word_t> addrs(MemoryType::HOST);
|
||||
while (unw_step(&cursor) > 0 && addrs.Size() != depth)
|
||||
{
|
||||
err = err ? err : unw_get_proc_name(&cursor, name, UNW_NAME_LEN, &offp);
|
||||
|
||||
+169
-79
@@ -45,6 +45,9 @@
|
||||
#endif
|
||||
#endif // MFEM_USE_UMPIRE
|
||||
|
||||
// Internal debug option, useful for tracking some memory manager operations.
|
||||
// #define MFEM_TRACK_MEM_MANAGER
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
@@ -63,6 +66,27 @@ MemoryType GetMemoryType(MemoryClass mc)
|
||||
}
|
||||
|
||||
|
||||
bool MemoryClassContainsType(MemoryClass mc, MemoryType mt)
|
||||
{
|
||||
switch (mc)
|
||||
{
|
||||
case MemoryClass::HOST: return IsHostMemory(mt);
|
||||
case MemoryClass::HOST_32:
|
||||
return (mt == MemoryType::HOST_32 ||
|
||||
mt == MemoryType::HOST_64 ||
|
||||
mt == MemoryType::HOST_DEBUG);
|
||||
case MemoryClass::HOST_64:
|
||||
return (mt == MemoryType::HOST_64 ||
|
||||
mt == MemoryType::HOST_DEBUG);
|
||||
case MemoryClass::DEVICE: return IsDeviceMemory(mt);
|
||||
case MemoryClass::MANAGED:
|
||||
return (mt == MemoryType::MANAGED);
|
||||
}
|
||||
MFEM_ABORT("invalid MemoryClass");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void MFEM_VERIFY_TYPES(const MemoryType h_mt, const MemoryType d_mt)
|
||||
{
|
||||
MFEM_VERIFY(IsHostMemory(h_mt), "h_mt = " << (int)h_mt);
|
||||
@@ -147,10 +171,12 @@ struct Memory
|
||||
/// Alias class that holds the base memory region and the offset
|
||||
struct Alias
|
||||
{
|
||||
Memory *const mem;
|
||||
const size_t offset, bytes;
|
||||
Memory *mem;
|
||||
size_t offset;
|
||||
size_t counter;
|
||||
const MemoryType h_mt;
|
||||
// 'h_mt' is already stored in 'mem', however, we use this field for type
|
||||
// checking since the alias may be dangling, i.e. 'mem' may be invalid.
|
||||
MemoryType h_mt;
|
||||
};
|
||||
|
||||
/// Maps for the Memory and the Alias classes
|
||||
@@ -558,7 +584,7 @@ public:
|
||||
#ifdef MFEM_USE_HIP
|
||||
return HipMemcpyHtoD(dst, src, bytes);
|
||||
#endif
|
||||
//rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
// rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
}
|
||||
void *DtoD(void* dst, const void* src, size_t bytes) override
|
||||
{
|
||||
@@ -568,7 +594,7 @@ public:
|
||||
#ifdef MFEM_USE_HIP
|
||||
return HipMemcpyDtoD(dst, src, bytes);
|
||||
#endif
|
||||
//rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
// rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
}
|
||||
void *DtoH(void *dst, const void *src, size_t bytes) override
|
||||
{
|
||||
@@ -578,7 +604,7 @@ public:
|
||||
#ifdef MFEM_USE_HIP
|
||||
return HipMemcpyDtoH(dst, src, bytes);
|
||||
#endif
|
||||
//rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
// rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
}
|
||||
};
|
||||
#else
|
||||
@@ -759,7 +785,7 @@ void *MemoryManager::New_(void *h_tmp, size_t bytes, MemoryType h_mt,
|
||||
// mm.InsertDevice(nullptr, h_ptr, bytes, h_mt, d_mt); // non-lazy dev alloc
|
||||
|
||||
// MFEM_VERIFY_TYPES(h_mt, mt); // done by mm.Insert() above
|
||||
CheckHostMemoryType_(h_mt, h_ptr);
|
||||
CheckHostMemoryType_(h_mt, h_ptr, false);
|
||||
|
||||
return h_ptr;
|
||||
}
|
||||
@@ -770,7 +796,7 @@ void *MemoryManager::Register_(void *ptr, void *h_tmp, size_t bytes,
|
||||
{
|
||||
MFEM_CONTRACT_VAR(alias);
|
||||
MFEM_ASSERT(exists, "Internal error!");
|
||||
MFEM_ASSERT(!alias, "Cannot register an alias!");
|
||||
MFEM_VERIFY(!alias, "Cannot register an alias!");
|
||||
const bool is_host_mem = IsHostMemory(mt);
|
||||
const MemType h_mt = is_host_mem ? mt : GetDualMemoryType(mt);
|
||||
const MemType d_mt = is_host_mem ? MemoryType::DEFAULT : mt;
|
||||
@@ -798,20 +824,21 @@ void *MemoryManager::Register_(void *ptr, void *h_tmp, size_t bytes,
|
||||
}
|
||||
else // DEVICE TYPES
|
||||
{
|
||||
MFEM_VERIFY(ptr, "cannot register NULL device pointer");
|
||||
MFEM_VERIFY(ptr || bytes == 0,
|
||||
"cannot register NULL device pointer with bytes = " << bytes);
|
||||
if (h_tmp == nullptr) { ctrl->Host(h_mt)->Alloc(&h_ptr, bytes); }
|
||||
else { h_ptr = h_tmp; }
|
||||
mm.InsertDevice(ptr, h_ptr, bytes, h_mt, d_mt);
|
||||
flags = own ? flags | Mem::OWNS_DEVICE : flags & ~Mem::OWNS_DEVICE;
|
||||
flags |= (Mem::OWNS_HOST | Mem::VALID_DEVICE);
|
||||
}
|
||||
CheckHostMemoryType_(h_mt, h_ptr);
|
||||
CheckHostMemoryType_(h_mt, h_ptr, alias);
|
||||
return h_ptr;
|
||||
}
|
||||
|
||||
void MemoryManager::Register_(void *h_ptr, void *d_ptr, size_t bytes,
|
||||
MemoryType h_mt, MemoryType d_mt,
|
||||
bool own, bool alias, unsigned &flags)
|
||||
void MemoryManager::Register2_(void *h_ptr, void *d_ptr, size_t bytes,
|
||||
MemoryType h_mt, MemoryType d_mt,
|
||||
bool own, bool alias, unsigned &flags)
|
||||
{
|
||||
MFEM_CONTRACT_VAR(alias);
|
||||
MFEM_ASSERT(exists, "Internal error!");
|
||||
@@ -826,12 +853,14 @@ void MemoryManager::Register_(void *h_ptr, void *d_ptr, size_t bytes,
|
||||
|
||||
flags |= Mem::REGISTERED | Mem::OWNS_INTERNAL;
|
||||
|
||||
MFEM_VERIFY(d_ptr || bytes == 0,
|
||||
"cannot register NULL device pointer with bytes = " << bytes);
|
||||
mm.InsertDevice(d_ptr, h_ptr, bytes, h_mt, d_mt);
|
||||
flags = (own ? flags | (Mem::OWNS_HOST | Mem::OWNS_DEVICE) :
|
||||
flags & ~(Mem::OWNS_HOST | Mem::OWNS_DEVICE)) |
|
||||
Mem::VALID_HOST;
|
||||
|
||||
CheckHostMemoryType_(h_mt, h_ptr);
|
||||
CheckHostMemoryType_(h_mt, h_ptr, alias);
|
||||
}
|
||||
|
||||
void MemoryManager::Alias_(void *base_h_ptr, size_t offset, size_t bytes,
|
||||
@@ -871,37 +900,40 @@ void MemoryManager::SetDeviceMemoryType_(void *h_ptr, unsigned flags,
|
||||
}
|
||||
}
|
||||
|
||||
MemoryType MemoryManager::Delete_(void *h_ptr, MemoryType mt, unsigned flags)
|
||||
MemoryType MemoryManager::Delete_(void *h_ptr, MemoryType h_mt, unsigned flags)
|
||||
{
|
||||
const bool alias = flags & Mem::ALIAS;
|
||||
const bool registered = flags & Mem::REGISTERED;
|
||||
const bool owns_host = flags & Mem::OWNS_HOST;
|
||||
const bool owns_device = flags & Mem::OWNS_DEVICE;
|
||||
const bool owns_internal = flags & Mem::OWNS_INTERNAL;
|
||||
MFEM_ASSERT(registered || IsHostMemory(mt),"");
|
||||
MFEM_ASSERT(IsHostMemory(h_mt), "invalid h_mt = " << (int)h_mt);
|
||||
// MFEM_ASSERT(registered || IsHostMemory(h_mt),"");
|
||||
MFEM_ASSERT(!owns_device || owns_internal, "invalid Memory state");
|
||||
if (!mm.exists || !registered) { return mt; }
|
||||
MFEM_ASSERT(registered || !(owns_host || owns_device || owns_internal),
|
||||
"invalid Memory state");
|
||||
if (!mm.exists || !registered) { return h_mt; }
|
||||
if (alias)
|
||||
{
|
||||
if (owns_internal)
|
||||
{
|
||||
const MemoryType h_mt = maps->aliases.at(h_ptr).h_mt;
|
||||
MFEM_ASSERT(mt == h_mt,"");
|
||||
MFEM_ASSERT(mm.IsAlias(h_ptr), "");
|
||||
MFEM_ASSERT(h_mt == maps->aliases.at(h_ptr).h_mt, "");
|
||||
mm.EraseAlias(h_ptr);
|
||||
return h_mt;
|
||||
}
|
||||
}
|
||||
else // Known
|
||||
{
|
||||
const MemoryType h_mt = mt;
|
||||
MFEM_ASSERT(!owns_internal ||
|
||||
mt == maps->memories.at(h_ptr).h_mt,"");
|
||||
if (owns_host && (h_mt != MemoryType::HOST))
|
||||
{ ctrl->Host(h_mt)->Dealloc(h_ptr); }
|
||||
if (owns_internal) { mm.Erase(h_ptr, owns_device); }
|
||||
return h_mt;
|
||||
if (owns_internal)
|
||||
{
|
||||
MFEM_ASSERT(mm.IsKnown(h_ptr), "");
|
||||
MFEM_ASSERT(h_mt == maps->memories.at(h_ptr).h_mt, "");
|
||||
mm.Erase(h_ptr, owns_device);
|
||||
}
|
||||
}
|
||||
return mt;
|
||||
return h_mt;
|
||||
}
|
||||
|
||||
void MemoryManager::DeleteDevice_(void *h_ptr, unsigned & flags)
|
||||
@@ -923,15 +955,19 @@ bool MemoryManager::MemoryClassCheck_(MemoryClass mc, void *h_ptr,
|
||||
MFEM_VERIFY(bytes == 0, "Trying to access NULL with size " << bytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool known = mm.IsKnown(h_ptr);
|
||||
const bool alias = mm.IsAlias(h_ptr);
|
||||
const bool check = known || ((flags & Mem::ALIAS) && alias);
|
||||
MFEM_VERIFY(check, "Unknown host pointer: " << h_ptr);
|
||||
const internal::Memory &mem =
|
||||
(flags & Mem::ALIAS) ?
|
||||
*maps->aliases.at(h_ptr).mem : maps->memories.at(h_ptr);
|
||||
MemoryType d_mt = mem.d_mt;
|
||||
MemoryType d_mt;
|
||||
if (!(flags & Mem::ALIAS))
|
||||
{
|
||||
auto iter = maps->memories.find(h_ptr);
|
||||
MFEM_VERIFY(iter != maps->memories.end(), "internal error");
|
||||
d_mt = iter->second.d_mt;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto iter = maps->aliases.find(h_ptr);
|
||||
MFEM_VERIFY(iter != maps->aliases.end(), "internal error");
|
||||
d_mt = iter->second.mem->d_mt;
|
||||
}
|
||||
if (d_mt == MemoryType::DEFAULT) { d_mt = GetDualMemoryType(h_mt); }
|
||||
switch (mc)
|
||||
{
|
||||
@@ -969,7 +1005,7 @@ bool MemoryManager::MemoryClassCheck_(MemoryClass mc, void *h_ptr,
|
||||
void *MemoryManager::ReadWrite_(void *h_ptr, MemoryType h_mt, MemoryClass mc,
|
||||
size_t bytes, unsigned &flags)
|
||||
{
|
||||
MemoryManager::CheckHostMemoryType_(h_mt, h_ptr);
|
||||
if (h_ptr) { CheckHostMemoryType_(h_mt, h_ptr, flags & Mem::ALIAS); }
|
||||
if (bytes > 0) { MFEM_VERIFY(flags & Mem::REGISTERED,""); }
|
||||
MFEM_ASSERT(MemoryClassCheck_(mc, h_ptr, h_mt, bytes, flags),"");
|
||||
if (IsHostMemory(GetMemoryType(mc)) && mc < MemoryClass::DEVICE)
|
||||
@@ -993,7 +1029,7 @@ void *MemoryManager::ReadWrite_(void *h_ptr, MemoryType h_mt, MemoryClass mc,
|
||||
const void *MemoryManager::Read_(void *h_ptr, MemoryType h_mt, MemoryClass mc,
|
||||
size_t bytes, unsigned &flags)
|
||||
{
|
||||
CheckHostMemoryType_(h_mt, h_ptr);
|
||||
if (h_ptr) { CheckHostMemoryType_(h_mt, h_ptr, flags & Mem::ALIAS); }
|
||||
if (bytes > 0) { MFEM_VERIFY(flags & Mem::REGISTERED,""); }
|
||||
MFEM_ASSERT(MemoryClassCheck_(mc, h_ptr, h_mt, bytes, flags),"");
|
||||
if (IsHostMemory(GetMemoryType(mc)) && mc < MemoryClass::DEVICE)
|
||||
@@ -1017,7 +1053,7 @@ const void *MemoryManager::Read_(void *h_ptr, MemoryType h_mt, MemoryClass mc,
|
||||
void *MemoryManager::Write_(void *h_ptr, MemoryType h_mt, MemoryClass mc,
|
||||
size_t bytes, unsigned &flags)
|
||||
{
|
||||
CheckHostMemoryType_(h_mt, h_ptr);
|
||||
if (h_ptr) { CheckHostMemoryType_(h_mt, h_ptr, flags & Mem::ALIAS); }
|
||||
if (bytes > 0) { MFEM_VERIFY(flags & Mem::REGISTERED,""); }
|
||||
MFEM_ASSERT(MemoryClassCheck_(mc, h_ptr, h_mt, bytes, flags),"");
|
||||
if (IsHostMemory(GetMemoryType(mc)) && mc < MemoryClass::DEVICE)
|
||||
@@ -1061,22 +1097,20 @@ void MemoryManager::SyncAlias_(const void *base_h_ptr, void *alias_h_ptr,
|
||||
(base_flags & (Mem::VALID_HOST | Mem::VALID_DEVICE));
|
||||
}
|
||||
|
||||
MemoryType MemoryManager::GetDeviceMemoryType_(void *h_ptr)
|
||||
MemoryType MemoryManager::GetDeviceMemoryType_(void *h_ptr, bool alias)
|
||||
{
|
||||
if (mm.exists)
|
||||
{
|
||||
const bool known = mm.IsKnown(h_ptr);
|
||||
if (known)
|
||||
if (!alias)
|
||||
{
|
||||
internal::Memory &mem = maps->memories.at(h_ptr);
|
||||
return mem.d_mt;
|
||||
}
|
||||
const bool alias = mm.IsAlias(h_ptr);
|
||||
if (alias)
|
||||
{
|
||||
internal::Memory *mem = maps->aliases.at(h_ptr).mem;
|
||||
return mem->d_mt;
|
||||
auto iter = maps->memories.find(h_ptr);
|
||||
MFEM_ASSERT(iter != maps->memories.end(), "internal error");
|
||||
return iter->second.d_mt;
|
||||
}
|
||||
// alias == true
|
||||
auto iter = maps->aliases.find(h_ptr);
|
||||
MFEM_ASSERT(iter != maps->aliases.end(), "internal error");
|
||||
return iter->second.mem->d_mt;
|
||||
}
|
||||
MFEM_ABORT("internal error");
|
||||
return MemoryManager::host_mem_type;
|
||||
@@ -1086,7 +1120,7 @@ MemoryType MemoryManager::GetHostMemoryType_(void *h_ptr)
|
||||
{
|
||||
if (!mm.exists) { return MemoryManager::host_mem_type; }
|
||||
if (mm.IsKnown(h_ptr)) { return maps->memories.at(h_ptr).h_mt; }
|
||||
if (mm.IsAlias(h_ptr)) { return maps->aliases.at(h_ptr).mem->h_mt; }
|
||||
if (mm.IsAlias(h_ptr)) { return maps->aliases.at(h_ptr).h_mt; }
|
||||
return MemoryManager::host_mem_type;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1171,7 @@ void MemoryManager::Copy_(void *dst_h_ptr, const void *src_h_ptr,
|
||||
{
|
||||
if (dst_h_ptr != src_d_ptr && bytes != 0)
|
||||
{
|
||||
internal::Memory &src_d_base = maps->memories.at(src_d_ptr);
|
||||
internal::Memory &src_d_base = maps->memories.at(src_h_ptr);
|
||||
MemoryType src_d_mt = src_d_base.d_mt;
|
||||
ctrl->Device(src_d_mt)->DtoH(dst_h_ptr, src_d_ptr, bytes);
|
||||
}
|
||||
@@ -1240,6 +1274,10 @@ bool MemoryManager::IsAlias_(const void *h_ptr)
|
||||
void MemoryManager::Insert(void *h_ptr, size_t bytes,
|
||||
MemoryType h_mt, MemoryType d_mt)
|
||||
{
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: registering h_ptr: " << h_ptr
|
||||
<< ", bytes: " << bytes << std::endl;
|
||||
#endif
|
||||
if (h_ptr == NULL)
|
||||
{
|
||||
MFEM_VERIFY(bytes == 0, "Trying to add NULL with size " << bytes);
|
||||
@@ -1254,8 +1292,14 @@ void MemoryManager::Insert(void *h_ptr, size_t bytes,
|
||||
if (res.second == false)
|
||||
{
|
||||
auto &m = res.first->second;
|
||||
MFEM_VERIFY(m.bytes >= bytes && m.h_mt == h_mt && m.d_mt == d_mt,
|
||||
MFEM_VERIFY(m.bytes >= bytes && m.h_mt == h_mt &&
|
||||
(m.d_mt == d_mt || (d_mt == MemoryType::DEFAULT &&
|
||||
m.d_mt == GetDualMemoryType(h_mt))),
|
||||
"Address already present with different attributes!");
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: repeated registration of h_ptr: "
|
||||
<< h_ptr << std::endl;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1267,7 +1311,7 @@ void MemoryManager::InsertDevice(void *d_ptr, void *h_ptr, size_t bytes,
|
||||
MFEM_ASSERT(h_ptr != NULL, "internal error");
|
||||
Insert(h_ptr, bytes, h_mt, d_mt);
|
||||
internal::Memory &mem = maps->memories.at(h_ptr);
|
||||
if (d_ptr == NULL) { ctrl->Device(d_mt)->Alloc(mem); }
|
||||
if (d_ptr == NULL && bytes != 0) { ctrl->Device(d_mt)->Alloc(mem); }
|
||||
else { mem.d_ptr = d_ptr; }
|
||||
}
|
||||
|
||||
@@ -1276,6 +1320,11 @@ void MemoryManager::InsertAlias(const void *base_ptr, void *alias_ptr,
|
||||
{
|
||||
size_t offset = static_cast<size_t>(static_cast<const char*>(alias_ptr) -
|
||||
static_cast<const char*>(base_ptr));
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: registering alias of base_ptr: "
|
||||
<< base_ptr << ", offset: " << offset << ", bytes: " << bytes
|
||||
<< ", base is alias: " << base_is_alias << std::endl;
|
||||
#endif
|
||||
if (!base_ptr)
|
||||
{
|
||||
MFEM_VERIFY(offset == 0,
|
||||
@@ -1288,26 +1337,33 @@ void MemoryManager::InsertAlias(const void *base_ptr, void *alias_ptr,
|
||||
MFEM_ASSERT(alias.mem,"");
|
||||
base_ptr = alias.mem->h_ptr;
|
||||
offset += alias.offset;
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: real base_ptr: " << base_ptr
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
internal::Memory &mem = maps->memories.at(base_ptr);
|
||||
MFEM_VERIFY(offset + bytes <= mem.bytes, "invalid alias");
|
||||
auto res =
|
||||
maps->aliases.emplace(alias_ptr,
|
||||
internal::Alias{&mem, offset, bytes, 1, mem.h_mt});
|
||||
internal::Alias{&mem, offset, 1, mem.h_mt});
|
||||
if (res.second == false) // alias_ptr was already in the map
|
||||
{
|
||||
if (res.first->second.mem != &mem || res.first->second.offset != offset)
|
||||
{
|
||||
mfem_error("alias already exists with different base/offset!");
|
||||
}
|
||||
else
|
||||
{
|
||||
res.first->second.counter++;
|
||||
}
|
||||
internal::Alias &alias = res.first->second;
|
||||
// Update the alias data in case the existing alias is dangling
|
||||
alias.mem = &mem;
|
||||
alias.offset = offset;
|
||||
alias.h_mt = mem.h_mt;
|
||||
alias.counter++;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryManager::Erase(void *h_ptr, bool free_dev_ptr)
|
||||
{
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: un-registering h_ptr: " << h_ptr
|
||||
<< std::endl;
|
||||
#endif
|
||||
if (!h_ptr) { return; }
|
||||
auto mem_map_iter = maps->memories.find(h_ptr);
|
||||
if (mem_map_iter == maps->memories.end()) { mfem_error("Unknown pointer!"); }
|
||||
@@ -1321,10 +1377,6 @@ void MemoryManager::EraseDevice(void *h_ptr)
|
||||
if (!h_ptr) { return; }
|
||||
auto mem_map_iter = maps->memories.find(h_ptr);
|
||||
if (mem_map_iter == maps->memories.end()) { mfem_error("Unknown pointer!"); }
|
||||
if (maps->aliases.find(h_ptr) != maps->aliases.end())
|
||||
{
|
||||
mfem_error("cannot delete aliased obj!");
|
||||
}
|
||||
internal::Memory &mem = mem_map_iter->second;
|
||||
if (mem.d_ptr) { ctrl->Device(mem.d_mt)->Dealloc(mem);}
|
||||
mem.d_ptr = nullptr;
|
||||
@@ -1332,6 +1384,10 @@ void MemoryManager::EraseDevice(void *h_ptr)
|
||||
|
||||
void MemoryManager::EraseAlias(void *alias_ptr)
|
||||
{
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
mfem::out << "[mfem memory manager]: un-registering alias_ptr: " << alias_ptr
|
||||
<< std::endl;
|
||||
#endif
|
||||
if (!alias_ptr) { return; }
|
||||
auto alias_map_iter = maps->aliases.find(alias_ptr);
|
||||
if (alias_map_iter == maps->aliases.end()) { mfem_error("Unknown alias!"); }
|
||||
@@ -1355,14 +1411,14 @@ void *MemoryManager::GetDevicePtr(const void *h_ptr, size_t bytes,
|
||||
if (!mem.d_ptr)
|
||||
{
|
||||
if (d_mt == MemoryType::DEFAULT) { d_mt = GetDualMemoryType(h_mt); }
|
||||
ctrl->Device(d_mt)->Alloc(mem);
|
||||
if (mem.bytes) { ctrl->Device(d_mt)->Alloc(mem); }
|
||||
}
|
||||
// Aliases might have done some protections
|
||||
ctrl->Device(d_mt)->Unprotect(mem);
|
||||
if (mem.d_ptr) { ctrl->Device(d_mt)->Unprotect(mem); }
|
||||
if (copy_data)
|
||||
{
|
||||
MFEM_ASSERT(bytes <= mem.bytes, "invalid copy size");
|
||||
ctrl->Device(d_mt)->HtoD(mem.d_ptr, h_ptr, bytes);
|
||||
if (bytes) { ctrl->Device(d_mt)->HtoD(mem.d_ptr, h_ptr, bytes); }
|
||||
}
|
||||
ctrl->Host(h_mt)->Protect(mem, bytes);
|
||||
return mem.d_ptr;
|
||||
@@ -1388,16 +1444,17 @@ void *MemoryManager::GetAliasDevicePtr(const void *alias_ptr, size_t bytes,
|
||||
if (!mem.d_ptr)
|
||||
{
|
||||
if (d_mt == MemoryType::DEFAULT) { d_mt = GetDualMemoryType(h_mt); }
|
||||
ctrl->Device(d_mt)->Alloc(mem);
|
||||
if (mem.bytes) { ctrl->Device(d_mt)->Alloc(mem); }
|
||||
}
|
||||
void *alias_h_ptr = static_cast<char*>(mem.h_ptr) + offset;
|
||||
void *alias_d_ptr = static_cast<char*>(mem.d_ptr) + offset;
|
||||
MFEM_ASSERT(alias_h_ptr == alias_ptr, "internal error");
|
||||
MFEM_ASSERT(bytes <= alias.bytes, "internal error");
|
||||
MFEM_ASSERT(offset + bytes <= mem.bytes, "internal error");
|
||||
mem.d_rw = mem.h_rw = false;
|
||||
ctrl->Device(d_mt)->AliasUnprotect(alias_d_ptr, bytes);
|
||||
if (mem.d_ptr) { ctrl->Device(d_mt)->AliasUnprotect(alias_d_ptr, bytes); }
|
||||
ctrl->Host(h_mt)->AliasUnprotect(alias_ptr, bytes);
|
||||
if (copy) { ctrl->Device(d_mt)->HtoD(alias_d_ptr, alias_h_ptr, bytes); }
|
||||
if (copy && mem.d_ptr)
|
||||
{ ctrl->Device(d_mt)->HtoD(alias_d_ptr, alias_h_ptr, bytes); }
|
||||
ctrl->Host(h_mt)->AliasProtect(alias_ptr, bytes);
|
||||
return alias_d_ptr;
|
||||
}
|
||||
@@ -1504,6 +1561,23 @@ void MemoryManager::Configure(const MemoryType host_mt,
|
||||
void MemoryManager::Destroy()
|
||||
{
|
||||
MFEM_VERIFY(exists, "MemoryManager has already been destroyed!");
|
||||
#ifdef MFEM_TRACK_MEM_MANAGER
|
||||
size_t num_memories = maps->memories.size();
|
||||
size_t num_aliases = maps->aliases.size();
|
||||
if (num_memories != 0 || num_aliases != 0)
|
||||
{
|
||||
MFEM_WARNING("...\n\t number of registered pointers: " << num_memories
|
||||
<< "\n\t number of registered aliases : " << num_aliases);
|
||||
}
|
||||
#endif
|
||||
// Keep for debugging purposes:
|
||||
#if 0
|
||||
mfem::out << "Destroying the MemoryManager ...\n"
|
||||
<< "remaining registered pointers : "
|
||||
<< maps->memories.size() << '\n'
|
||||
<< "remaining registered aliases : "
|
||||
<< maps->aliases.size() << '\n';
|
||||
#endif
|
||||
for (auto& n : maps->memories)
|
||||
{
|
||||
internal::Memory &mem = n.second;
|
||||
@@ -1554,7 +1628,6 @@ int MemoryManager::PrintAliases(std::ostream &out)
|
||||
out << "\nalias: key " << n.first << ", "
|
||||
<< "h_ptr " << alias.mem->h_ptr << ", "
|
||||
<< "offset " << alias.offset << ", "
|
||||
<< "bytes " << alias.bytes << ", "
|
||||
<< "counter " << alias.counter;
|
||||
n_out++;
|
||||
}
|
||||
@@ -1569,7 +1642,13 @@ int MemoryManager::CompareHostAndDevice_(void *h_ptr, size_t size,
|
||||
mm.GetAliasDevicePtr(h_ptr, size, false) :
|
||||
mm.GetDevicePtr(h_ptr, size, false);
|
||||
char *h_buf = new char[size];
|
||||
#ifdef MFEM_USE_CUDA
|
||||
CuMemcpyDtoH(h_buf, d_ptr, size);
|
||||
#elif MFE_USE_HIP
|
||||
HipMemcpyDtoH(h_buf, d_ptr, size);
|
||||
#else
|
||||
std::memcpy(h_buf, d_ptr, size);
|
||||
#endif
|
||||
int res = std::memcmp(h_ptr, h_buf, size);
|
||||
delete [] h_buf;
|
||||
return res;
|
||||
@@ -1591,13 +1670,24 @@ void MemoryPrintFlags(unsigned flags)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void MemoryManager::CheckHostMemoryType_(MemoryType h_mt, void *h_ptr)
|
||||
void MemoryManager::CheckHostMemoryType_(MemoryType h_mt, void *h_ptr,
|
||||
bool alias)
|
||||
{
|
||||
if (!mm.exists) {return;}
|
||||
const bool known = mm.IsKnown(h_ptr);
|
||||
const bool alias = mm.IsAlias(h_ptr);
|
||||
if (known) { MFEM_VERIFY(h_mt == maps->memories.at(h_ptr).h_mt,""); }
|
||||
if (alias) { MFEM_VERIFY(h_mt == maps->aliases.at(h_ptr).mem->h_mt,""); }
|
||||
if (!alias)
|
||||
{
|
||||
auto it = maps->memories.find(h_ptr);
|
||||
MFEM_VERIFY(it != maps->memories.end(),
|
||||
"host pointer is not registered: h_ptr = " << h_ptr);
|
||||
MFEM_VERIFY(h_mt == it->second.h_mt, "host pointer MemoryType mismatch");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = maps->aliases.find(h_ptr);
|
||||
MFEM_VERIFY(it != maps->aliases.end(),
|
||||
"alias pointer is not registered: h_ptr = " << h_ptr);
|
||||
MFEM_VERIFY(h_mt == it->second.h_mt, "alias pointer MemoryType mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
MemoryManager mm;
|
||||
|
||||
+81
-18
@@ -17,6 +17,9 @@
|
||||
#include <cstring> // std::memcpy
|
||||
#include <type_traits> // std::is_const
|
||||
#include <cstddef> // std::max_align_t
|
||||
#ifdef MFEM_USE_MPI
|
||||
#include <HYPRE_config.h> // HYPRE_USING_CUDA
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
@@ -90,6 +93,9 @@ inline bool IsDeviceMemory(MemoryType mt)
|
||||
/// Return a suitable MemoryType for a given MemoryClass.
|
||||
MemoryType GetMemoryType(MemoryClass mc);
|
||||
|
||||
/// Return true iff the MemoryType @a mt is contained in the MemoryClass @a mc.
|
||||
bool MemoryClassContainsType(MemoryClass mc, MemoryType mt);
|
||||
|
||||
/// Return a suitable MemoryClass from a pair of MemoryClass%es.
|
||||
/** Note: this operation is commutative, i.e. a*b = b*a, associative, i.e.
|
||||
(a*b)*c = a*(b*c), and has an identity element: MemoryClass::HOST.
|
||||
@@ -463,6 +469,13 @@ public:
|
||||
returned. */
|
||||
inline MemoryType GetMemoryType() const;
|
||||
|
||||
/// Return the host MemoryType of the Memory object.
|
||||
inline MemoryType GetHostMemoryType() const { return h_mt; }
|
||||
|
||||
/** @brief Return the device MemoryType of the Memory object. If the device
|
||||
MemoryType is not set, return MemoryType::DEFAULT. */
|
||||
inline MemoryType GetDeviceMemoryType() const;
|
||||
|
||||
/** @brief Return true if host pointer is valid */
|
||||
inline bool HostIsValid() const;
|
||||
|
||||
@@ -481,8 +494,7 @@ public:
|
||||
/// Copy @a size entries from @a *this to @a dest.
|
||||
/** The given @a size should not exceed the Capacity() of @a *this and the
|
||||
destination, @a dest. */
|
||||
inline void CopyTo(Memory &dest, int size) const
|
||||
{ dest.CopyFrom(*this, size); }
|
||||
inline void CopyTo(Memory &dest, int size) const;
|
||||
|
||||
/// Copy @a size entries from @a *this to the host pointer @a dest.
|
||||
/** The given @a size should not exceed the Capacity() of @a *this. */
|
||||
@@ -596,9 +608,9 @@ private: // Static methods used by the Memory<T> class
|
||||
bool own, bool alias, unsigned &flags);
|
||||
|
||||
/// Register a pair of external host and device pointers
|
||||
static void Register_(void *h_ptr, void *d_ptr, size_t bytes,
|
||||
MemoryType h_mt, MemoryType d_mt,
|
||||
bool own, bool alias, unsigned &flags);
|
||||
static void Register2_(void *h_ptr, void *d_ptr, size_t bytes,
|
||||
MemoryType h_mt, MemoryType d_mt,
|
||||
bool own, bool alias, unsigned &flags);
|
||||
|
||||
/// Register an alias. Note: base_h_ptr may be an alias.
|
||||
static void Alias_(void *base_h_ptr, size_t offset, size_t bytes,
|
||||
@@ -635,13 +647,13 @@ private: // Static methods used by the Memory<T> class
|
||||
|
||||
/// Return the type the of the currently valid memory.
|
||||
/// If more than one types are valid, return a device type.
|
||||
static MemoryType GetDeviceMemoryType_(void *h_ptr);
|
||||
static MemoryType GetDeviceMemoryType_(void *h_ptr, bool alias);
|
||||
|
||||
/// Return the type the of the host memory.
|
||||
static MemoryType GetHostMemoryType_(void *h_ptr);
|
||||
|
||||
/// Verify that h_mt and h_ptr's h_mt (memory or alias) are equal.
|
||||
static void CheckHostMemoryType_(MemoryType h_mt, void *h_ptr);
|
||||
static void CheckHostMemoryType_(MemoryType h_mt, void *h_ptr, bool alias);
|
||||
|
||||
/// Copy entries from valid memory type to valid memory type.
|
||||
/// Both dest_h_ptr and src_h_ptr are registered host pointers.
|
||||
@@ -851,15 +863,21 @@ inline void Memory<T>::Wrap(T *ptr, int size, bool own)
|
||||
{
|
||||
h_ptr = ptr;
|
||||
capacity = size;
|
||||
const size_t bytes = size*sizeof(T);
|
||||
flags = (own ? OWNS_HOST : 0) | VALID_HOST;
|
||||
h_mt = MemoryManager::GetHostMemoryType();
|
||||
#ifdef MFEM_DEBUG
|
||||
if (own && MemoryManager::Exists())
|
||||
{ MFEM_VERIFY(h_mt == MemoryManager::GetHostMemoryType_(h_ptr),""); }
|
||||
{
|
||||
MemoryType h_ptr_mt = MemoryManager::GetHostMemoryType_(h_ptr);
|
||||
MFEM_VERIFY(h_mt == h_ptr_mt,
|
||||
"h_mt = " << (int)h_mt << ", h_ptr_mt = " << (int)h_ptr_mt);
|
||||
}
|
||||
#endif
|
||||
if (own && h_mt != MemoryType::HOST)
|
||||
{ MemoryManager::Register_(ptr, ptr, bytes, h_mt, own, false, flags); }
|
||||
{
|
||||
const size_t bytes = size*sizeof(T);
|
||||
MemoryManager::Register_(ptr, ptr, bytes, h_mt, own, false, flags);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -880,7 +898,7 @@ inline void Memory<T>::Wrap(T *ptr, int size, MemoryType mt, bool own)
|
||||
else
|
||||
{
|
||||
h_mt = MemoryManager::GetDualMemoryType(mt);
|
||||
h_ptr = (h_mt == MemoryType::HOST) ? new T[size] : nullptr;
|
||||
h_ptr = (h_mt == MemoryType::HOST) ? NewHOST(size) : nullptr;
|
||||
}
|
||||
flags = 0;
|
||||
h_ptr = (T*)MemoryManager::Register_(ptr, h_ptr, size*sizeof(T), mt,
|
||||
@@ -897,23 +915,51 @@ inline void Memory<T>::Wrap(T *ptr, T *d_ptr, int size, MemoryType mt, bool own)
|
||||
MFEM_ASSERT(IsHostMemory(h_mt),"");
|
||||
const size_t bytes = size*sizeof(T);
|
||||
const MemoryType d_mt = MemoryManager::GetDualMemoryType(h_mt);
|
||||
MemoryManager::Register_(h_ptr, d_ptr, bytes, h_mt, d_mt, own, false, flags);
|
||||
MemoryManager::Register2_(h_ptr, d_ptr, bytes, h_mt, d_mt,
|
||||
own, false, flags);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Memory<T>::MakeAlias(const Memory &base, int offset, int size)
|
||||
{
|
||||
MFEM_ASSERT(0 <= offset, "invalid offset = " << offset);
|
||||
MFEM_ASSERT(0 <= size, "invalid size = " << size);
|
||||
MFEM_ASSERT(offset + size <= base.capacity,
|
||||
"invalid offset + size = " << offset + size
|
||||
<< " > base capacity = " << base.capacity);
|
||||
capacity = size;
|
||||
h_mt = base.h_mt;
|
||||
h_ptr = base.h_ptr + offset;
|
||||
if (!(base.flags & REGISTERED))
|
||||
{ flags = (base.flags | ALIAS) & ~(OWNS_HOST | OWNS_DEVICE); }
|
||||
else
|
||||
{
|
||||
const size_t s_bytes = size*sizeof(T);
|
||||
const size_t o_bytes = offset*sizeof(T);
|
||||
MemoryManager::Alias_(base.h_ptr, o_bytes, s_bytes, base.flags, flags);
|
||||
if (
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
// If the following condition is true then MemoryManager::Exists()
|
||||
// should also be true:
|
||||
IsDeviceMemory(MemoryManager::GetDeviceMemoryType())
|
||||
#else
|
||||
// When HYPRE_USING_CUDA is defined we always register the 'base' if
|
||||
// the MemoryManager::Exists():
|
||||
MemoryManager::Exists()
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// Register 'base':
|
||||
MemoryManager::Register_(base.h_ptr, nullptr, base.capacity*sizeof(T),
|
||||
base.h_mt, base.flags & OWNS_HOST,
|
||||
base.flags & ALIAS, base.flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the flags from 'base', setting the ALIAS flag to true, and
|
||||
// setting both OWNS_HOST and OWNS_DEVICE to false:
|
||||
flags = (base.flags | ALIAS) & ~(OWNS_HOST | OWNS_DEVICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const size_t s_bytes = size*sizeof(T);
|
||||
const size_t o_bytes = offset*sizeof(T);
|
||||
MemoryManager::Alias_(base.h_ptr, o_bytes, s_bytes, base.flags, flags);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -1069,7 +1115,14 @@ template <typename T>
|
||||
inline MemoryType Memory<T>::GetMemoryType() const
|
||||
{
|
||||
if (!(flags & VALID_DEVICE)) { return h_mt; }
|
||||
return MemoryManager::GetDeviceMemoryType_(h_ptr);
|
||||
return MemoryManager::GetDeviceMemoryType_(h_ptr, flags & ALIAS);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline MemoryType Memory<T>::GetDeviceMemoryType() const
|
||||
{
|
||||
if (!(flags & REGISTERED)) { return MemoryType::DEFAULT; }
|
||||
return MemoryManager::GetDeviceMemoryType_(h_ptr, flags & ALIAS);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -1087,6 +1140,7 @@ inline bool Memory<T>::DeviceIsValid() const
|
||||
template <typename T>
|
||||
inline void Memory<T>::CopyFrom(const Memory &src, int size)
|
||||
{
|
||||
MFEM_VERIFY(src.capacity>=size && capacity>=size, "Incorrect size");
|
||||
if (!(flags & REGISTERED) && !(src.flags & REGISTERED))
|
||||
{
|
||||
if (h_ptr != src.h_ptr && size != 0)
|
||||
@@ -1106,6 +1160,7 @@ inline void Memory<T>::CopyFrom(const Memory &src, int size)
|
||||
template <typename T>
|
||||
inline void Memory<T>::CopyFromHost(const T *src, int size)
|
||||
{
|
||||
MFEM_VERIFY(capacity>=size, "Incorrect size");
|
||||
if (!(flags & REGISTERED))
|
||||
{
|
||||
if (h_ptr != src && size != 0)
|
||||
@@ -1122,9 +1177,17 @@ inline void Memory<T>::CopyFromHost(const T *src, int size)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Memory<T>::CopyTo(Memory &dest, int size) const
|
||||
{
|
||||
MFEM_VERIFY(capacity>=size, "Incorrect size");
|
||||
dest.CopyFrom(*this, size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Memory<T>::CopyToHost(T *dest, int size) const
|
||||
{
|
||||
MFEM_VERIFY(capacity>=size, "Incorrect size");
|
||||
if (!(flags & REGISTERED))
|
||||
{
|
||||
if (h_ptr != dest && size != 0)
|
||||
|
||||
@@ -97,11 +97,6 @@ void BlockOperator::Mult (const Vector & x, Vector & y) const
|
||||
{
|
||||
yblock.GetBlock(iRow).SyncAliasMemory(y);
|
||||
}
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
for (int i=0; i < xblock.NumBlocks(); ++i) { xblock.GetBlock(i).Destroy(); }
|
||||
for (int i=0; i < yblock.NumBlocks(); ++i) { yblock.GetBlock(i).Destroy(); }
|
||||
}
|
||||
|
||||
// Action of the transpose operator
|
||||
@@ -133,11 +128,6 @@ void BlockOperator::MultTranspose (const Vector & x, Vector & y) const
|
||||
{
|
||||
yblock.GetBlock(iRow).SyncAliasMemory(y);
|
||||
}
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
for (int i=0; i < xblock.NumBlocks(); ++i) { xblock.GetBlock(i).Destroy(); }
|
||||
for (int i=0; i < yblock.NumBlocks(); ++i) { yblock.GetBlock(i).Destroy(); }
|
||||
}
|
||||
|
||||
BlockOperator::~BlockOperator()
|
||||
@@ -208,11 +198,6 @@ void BlockDiagonalPreconditioner::Mult (const Vector & x, Vector & y) const
|
||||
{
|
||||
yblock.GetBlock(i).SyncAliasMemory(y);
|
||||
}
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
for (int i=0; i < xblock.NumBlocks(); ++i) { xblock.GetBlock(i).Destroy(); }
|
||||
for (int i=0; i < yblock.NumBlocks(); ++i) { yblock.GetBlock(i).Destroy(); }
|
||||
}
|
||||
|
||||
// Action of the transpose operator
|
||||
@@ -244,11 +229,6 @@ void BlockDiagonalPreconditioner::MultTranspose (const Vector & x,
|
||||
{
|
||||
yblock.GetBlock(i).SyncAliasMemory(y);
|
||||
}
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
for (int i=0; i < xblock.NumBlocks(); ++i) { xblock.GetBlock(i).Destroy(); }
|
||||
for (int i=0; i < yblock.NumBlocks(); ++i) { yblock.GetBlock(i).Destroy(); }
|
||||
}
|
||||
|
||||
BlockDiagonalPreconditioner::~BlockDiagonalPreconditioner()
|
||||
|
||||
@@ -51,6 +51,12 @@ public:
|
||||
*/
|
||||
BlockOperator(const Array<int> & row_offsets, const Array<int> & col_offsets);
|
||||
|
||||
/// Copy assignment is not supported
|
||||
BlockOperator &operator=(const BlockOperator &) = delete;
|
||||
|
||||
/// Move assignment is not supported
|
||||
BlockOperator &operator=(BlockOperator &&) = delete;
|
||||
|
||||
//! Add block op in the block-entry (iblock, iblock).
|
||||
/**
|
||||
* iblock: The block will be inserted in location (iblock, iblock).
|
||||
|
||||
+28
-6
@@ -20,9 +20,7 @@ void BlockVector::SetBlocks()
|
||||
{
|
||||
for (int i = 0; i < numBlocks; ++i)
|
||||
{
|
||||
blocks[i].NewMemoryAndSize(
|
||||
Memory<double>(data, blockOffsets[i], BlockSize(i)),
|
||||
BlockSize(i), true);
|
||||
blocks[i].MakeRef(*this, blockOffsets[i], BlockSize(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +72,16 @@ BlockVector::BlockVector(double *data, const Array<int> & bOffsets):
|
||||
SetBlocks();
|
||||
}
|
||||
|
||||
BlockVector::BlockVector(Vector &v, const Array<int> &bOffsets)
|
||||
: Vector(),
|
||||
numBlocks(bOffsets.Size()-1),
|
||||
blockOffsets(bOffsets.GetData())
|
||||
{
|
||||
MakeRef(v, 0, blockOffsets[numBlocks]);
|
||||
blocks = new Vector[numBlocks];
|
||||
SetBlocks();
|
||||
}
|
||||
|
||||
void BlockVector::Update(double *data, const Array<int> & bOffsets)
|
||||
{
|
||||
NewDataAndSize(data, bOffsets.Last());
|
||||
@@ -178,9 +186,23 @@ BlockVector::~BlockVector()
|
||||
|
||||
void BlockVector::GetBlockView(int i, Vector & blockView)
|
||||
{
|
||||
blockView.NewMemoryAndSize(
|
||||
Memory<double>(data, blockOffsets[i], BlockSize(i)),
|
||||
BlockSize(i), true);
|
||||
blockView.MakeRef(*this, blockOffsets[i], BlockSize(i));
|
||||
}
|
||||
|
||||
void BlockVector::SyncToBlocks() const
|
||||
{
|
||||
for (int i = 0; i < numBlocks; ++i)
|
||||
{
|
||||
blocks[i].SyncMemory(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void BlockVector::SyncFromBlocks() const
|
||||
{
|
||||
for (int i = 0; i < numBlocks; ++i)
|
||||
{
|
||||
blocks[i].SyncAliasMemory(*this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
*/
|
||||
BlockVector(double *data, const Array<int> & bOffsets);
|
||||
|
||||
/// Wrap a Vector as a BlockVector
|
||||
BlockVector(Vector &v, const Array<int> &bOffsets);
|
||||
|
||||
//! Return the number of blocks
|
||||
int NumBlocks() const { return numBlocks; }
|
||||
|
||||
@@ -117,6 +120,21 @@ public:
|
||||
- currently, the block-vector does not own its data, or
|
||||
- currently, the block-vector does not use MemoryType @a mt. */
|
||||
void Update(const Array<int> &bOffsets, MemoryType mt);
|
||||
|
||||
/** @brief Synchronize the memory location flags (i.e. the memory validity
|
||||
flags) of the big/monolithic block-vector with its sub-vector blocks. The
|
||||
big/monolithic vector has the correct memory location flags. */
|
||||
/** This method will copy the data validity flags from the big/monolithic
|
||||
block-vector to its sub-vector block. */
|
||||
void SyncToBlocks() const;
|
||||
|
||||
/** @brief Synchronize the memory location flags (i.e. the memory validity
|
||||
flags) of the big/monolithic block-vector with its sub-vector blocks. The
|
||||
sub-vector blocks have the correct memory location flags. */
|
||||
/** This method will copy/move the data of the sub-vector blocks (if
|
||||
necessary) so that each block matches the memory location flags of the
|
||||
big/monolithic block-vector. */
|
||||
void SyncFromBlocks() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+18
-32
@@ -81,13 +81,6 @@ void ComplexOperator::Mult(const Vector &x, Vector &y) const
|
||||
|
||||
y_r_.SyncAliasMemory(y);
|
||||
y_i_.SyncAliasMemory(y);
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
x_r_.Destroy();
|
||||
x_i_.Destroy();
|
||||
y_r_.Destroy();
|
||||
y_i_.Destroy();
|
||||
}
|
||||
|
||||
void ComplexOperator::Mult(const Vector &x_r, const Vector &x_i,
|
||||
@@ -137,13 +130,6 @@ void ComplexOperator::MultTranspose(const Vector &x, Vector &y) const
|
||||
|
||||
y_r_.SyncAliasMemory(y);
|
||||
y_i_.SyncAliasMemory(y);
|
||||
|
||||
// Destroy alias vectors to prevent dangling aliases when the base vectors
|
||||
// are deleted
|
||||
x_r_.Destroy();
|
||||
x_i_.Destroy();
|
||||
y_r_.Destroy();
|
||||
y_i_.Destroy();
|
||||
}
|
||||
|
||||
void ComplexOperator::MultTranspose(const Vector &x_r, const Vector &x_i,
|
||||
@@ -584,10 +570,10 @@ HypreParMatrix * ComplexHypreParMatrix::GetSystemMatrix() const
|
||||
global_num_cols_i);
|
||||
|
||||
int row_starts_size = (HYPRE_AssumedPartitionCheck()) ? 2 : nranks_ + 1;
|
||||
HYPRE_BigInt * row_starts = mfem_hypre_CTAlloc(HYPRE_BigInt,
|
||||
row_starts_size);
|
||||
HYPRE_BigInt * col_starts = mfem_hypre_CTAlloc(HYPRE_BigInt,
|
||||
row_starts_size);
|
||||
HYPRE_BigInt * row_starts = mfem_hypre_CTAlloc_host(HYPRE_BigInt,
|
||||
row_starts_size);
|
||||
HYPRE_BigInt * col_starts = mfem_hypre_CTAlloc_host(HYPRE_BigInt,
|
||||
row_starts_size);
|
||||
|
||||
const HYPRE_BigInt * row_starts_z = (A_r) ? A_r->RowPart() :
|
||||
((A_i) ? A_i->RowPart() : NULL);
|
||||
@@ -665,14 +651,15 @@ HypreParMatrix * ComplexHypreParMatrix::GetSystemMatrix() const
|
||||
int offd_nnz = 2 * (offd_r_nnz + offd_i_nnz);
|
||||
|
||||
// Allocate CSR arrays for the combined matrix
|
||||
HYPRE_Int * diag_I = mfem_hypre_CTAlloc(HYPRE_Int, 2 * nrows + 1);
|
||||
HYPRE_Int * diag_J = mfem_hypre_CTAlloc(HYPRE_Int, diag_nnz);
|
||||
double * diag_D = mfem_hypre_CTAlloc(double, diag_nnz);
|
||||
HYPRE_Int * diag_I = mfem_hypre_CTAlloc_host(HYPRE_Int, 2 * nrows + 1);
|
||||
HYPRE_Int * diag_J = mfem_hypre_CTAlloc_host(HYPRE_Int, diag_nnz);
|
||||
double * diag_D = mfem_hypre_CTAlloc_host(double, diag_nnz);
|
||||
|
||||
HYPRE_Int * offd_I = mfem_hypre_CTAlloc(HYPRE_Int, 2 * nrows + 1);
|
||||
HYPRE_Int * offd_J = mfem_hypre_CTAlloc(HYPRE_Int, offd_nnz);
|
||||
double * offd_D = mfem_hypre_CTAlloc(double, offd_nnz);
|
||||
HYPRE_BigInt * cmap = mfem_hypre_CTAlloc(HYPRE_BigInt, 2 * num_cols_offd);
|
||||
HYPRE_Int * offd_I = mfem_hypre_CTAlloc_host(HYPRE_Int, 2 * nrows + 1);
|
||||
HYPRE_Int * offd_J = mfem_hypre_CTAlloc_host(HYPRE_Int, offd_nnz);
|
||||
double * offd_D = mfem_hypre_CTAlloc_host(double, offd_nnz);
|
||||
HYPRE_BigInt * cmap = mfem_hypre_CTAlloc_host(HYPRE_BigInt,
|
||||
2 * num_cols_offd);
|
||||
|
||||
// Fill the CSR arrays for the diagonal portion of the matrix
|
||||
const double factor = (convention_ == HERMITIAN) ? 1.0 : -1.0;
|
||||
@@ -797,14 +784,13 @@ HypreParMatrix * ComplexHypreParMatrix::GetSystemMatrix() const
|
||||
row_starts, col_starts,
|
||||
diag_I, diag_J, diag_D,
|
||||
offd_I, offd_J, offd_D,
|
||||
2 * num_cols_offd, cmap);
|
||||
2 * num_cols_offd, cmap,
|
||||
true);
|
||||
|
||||
// Give the new matrix ownership of its internal arrays
|
||||
A->SetOwnerFlags(-1,-1,-1);
|
||||
hypre_CSRMatrixSetDataOwner(((hypre_ParCSRMatrix*)(*A))->diag,1);
|
||||
hypre_CSRMatrixSetDataOwner(((hypre_ParCSRMatrix*)(*A))->offd,1);
|
||||
hypre_ParCSRMatrixSetRowStartsOwner((hypre_ParCSRMatrix*)(*A),1);
|
||||
hypre_ParCSRMatrixSetColStartsOwner((hypre_ParCSRMatrix*)(*A),1);
|
||||
// Give the new matrix ownership of row_starts and col_starts
|
||||
hypre_ParCSRMatrix *hA = (hypre_ParCSRMatrix*)(*A);
|
||||
hypre_ParCSRMatrixSetRowStartsOwner(hA,1);
|
||||
hypre_ParCSRMatrixSetColStartsOwner(hA,1);
|
||||
|
||||
return A;
|
||||
}
|
||||
|
||||
+1084
-296
File diff suppressed because it is too large
Load Diff
+218
-40
@@ -32,6 +32,10 @@
|
||||
#error "MFEM does not work with HYPRE's complex numbers support"
|
||||
#endif
|
||||
|
||||
#if defined(HYPRE_USING_CUDA) && !defined(MFEM_USE_CUDA)
|
||||
#error "MFEM_USE_CUDA=YES is required when HYPRE is built with CUDA!"
|
||||
#endif
|
||||
|
||||
#include "sparsemat.hpp"
|
||||
#include "hypre_parcsr.hpp"
|
||||
|
||||
@@ -64,6 +68,31 @@ inline int to_int(HYPRE_Int i)
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
/// The MemoryClass used by Hypre objects.
|
||||
inline constexpr MemoryClass GetHypreMemoryClass()
|
||||
{
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
return MemoryClass::HOST;
|
||||
#elif defined(HYPRE_USING_UNIFIED_MEMORY)
|
||||
return MemoryClass::MANAGED;
|
||||
#else
|
||||
return MemoryClass::DEVICE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// The MemoryType used by MFEM when allocating arrays for Hypre objects.
|
||||
inline MemoryType GetHypreMemoryType()
|
||||
{
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
return Device::GetHostMemoryType();
|
||||
#elif defined(HYPRE_USING_UNIFIED_MEMORY)
|
||||
return MemoryType::MANAGED;
|
||||
#else
|
||||
return MemoryType::DEVICE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Wrapper for hypre's parallel vector class
|
||||
@@ -106,9 +135,12 @@ public:
|
||||
columns, and data. */
|
||||
/** The data must be allocated and destroyed outside. If @a data_ is NULL, a
|
||||
dummy vector without a valid data array will be created. See @ref
|
||||
hypre_partitioning_descr "here" for a description of the @a col array. */
|
||||
hypre_partitioning_descr "here" for a description of the @a col array.
|
||||
|
||||
If @a is_device_ptr is true, the pointer @a data_ is assumed to be
|
||||
allocated in the memory location HYPRE_MEMORY_DEVICE. */
|
||||
HypreParVector(MPI_Comm comm, HYPRE_BigInt glob_size, double *data_,
|
||||
HYPRE_BigInt *col);
|
||||
HYPRE_BigInt *col, bool is_device_ptr = false);
|
||||
/// Creates vector compatible with y
|
||||
HypreParVector(const HypreParVector &y);
|
||||
/// Creates vector compatible with (i.e. in the domain of) A or A^T
|
||||
@@ -144,7 +176,7 @@ public:
|
||||
/// Typecasting to hypre's HYPRE_ParVector, a.k.a. void *
|
||||
operator HYPRE_ParVector() const { return (HYPRE_ParVector) x; }
|
||||
#endif
|
||||
/// Changes the ownership of the the vector
|
||||
/// Changes the ownership of the vector
|
||||
hypre_ParVector *StealParVector() { own_ParVector = 0; return x; }
|
||||
|
||||
/// Sets ownership of the internal hypre_ParVector
|
||||
@@ -161,12 +193,59 @@ public:
|
||||
/// Define '=' for hypre vectors.
|
||||
HypreParVector& operator= (const HypreParVector &y);
|
||||
|
||||
using Vector::Read;
|
||||
|
||||
/// Sets the data of the Vector and the hypre_ParVector to @a data_.
|
||||
/** Must be used only for HypreParVector%s that do not own the data,
|
||||
e.g. created with the constructor:
|
||||
HypreParVector(MPI_Comm, HYPRE_BigInt, double *, HYPRE_BigInt *). */
|
||||
void SetData(double *data_);
|
||||
|
||||
/** @brief Prepare the HypreParVector for read access in hypre's device
|
||||
memory space, HYPRE_MEMORY_DEVICE. */
|
||||
void HypreRead() const;
|
||||
|
||||
/** @brief Prepare the HypreParVector for read and write access in hypre's
|
||||
device memory space, HYPRE_MEMORY_DEVICE. */
|
||||
void HypreReadWrite();
|
||||
|
||||
/** @brief Prepare the HypreParVector for write access in hypre's device
|
||||
memory space, HYPRE_MEMORY_DEVICE. */
|
||||
void HypreWrite();
|
||||
|
||||
/** @brief Replace the HypreParVector's data with the given Memory, @a mem,
|
||||
and prepare the vector for read access in hypre's device memory space,
|
||||
HYPRE_MEMORY_DEVICE. */
|
||||
/** This method must be used with HypreParVector%s that do not own the data,
|
||||
e.g. created with the constructor:
|
||||
HypreParVector(MPI_Comm, HYPRE_BigInt, double *, HYPRE_BigInt *).
|
||||
|
||||
The Memory @a mem must be accessible with the hypre MemoryClass defined
|
||||
by GetHypreMemoryClass(). */
|
||||
void WrapMemoryRead(const Memory<double> &mem);
|
||||
|
||||
/** @brief Replace the HypreParVector's data with the given Memory, @a mem,
|
||||
and prepare the vector for read and write access in hypre's device memory
|
||||
space, HYPRE_MEMORY_DEVICE. */
|
||||
/** This method must be used with HypreParVector%s that do not own the data,
|
||||
e.g. created with the constructor:
|
||||
HypreParVector(MPI_Comm, HYPRE_BigInt, double *, HYPRE_BigInt *).
|
||||
|
||||
The Memory @a mem must be accessible with the hypre MemoryClass defined
|
||||
by GetHypreMemoryClass(). */
|
||||
void WrapMemoryReadWrite(Memory<double> &mem);
|
||||
|
||||
/** @brief Replace the HypreParVector's data with the given Memory, @a mem,
|
||||
and prepare the vector for write access in hypre's device memory space,
|
||||
HYPRE_MEMORY_DEVICE. */
|
||||
/** This method must be used with HypreParVector%s that do not own the data,
|
||||
e.g. created with the constructor:
|
||||
HypreParVector(MPI_Comm, HYPRE_BigInt, double *, HYPRE_BigInt *).
|
||||
|
||||
The Memory @a mem must be accessible with the hypre MemoryClass defined
|
||||
by GetHypreMemoryClass(). */
|
||||
void WrapMemoryWrite(Memory<double> &mem);
|
||||
|
||||
/// Set random values
|
||||
HYPRE_Int Randomize(HYPRE_Int seed);
|
||||
|
||||
@@ -203,15 +282,23 @@ private:
|
||||
|
||||
/// Auxiliary vectors for typecasting
|
||||
mutable HypreParVector *X, *Y;
|
||||
/** @brief Auxiliary buffers for the case when the input or output arrays in
|
||||
methods like Mult(double, const Vector &, double, Vector &) need to be
|
||||
deep copied in order to be used by hypre. */
|
||||
mutable Memory<double> auxX, auxY;
|
||||
|
||||
// Flags indicating ownership of A->diag->{i,j,data}, A->offd->{i,j,data},
|
||||
// and A->col_map_offd.
|
||||
// The possible values for diagOwner are:
|
||||
// -1: no special treatment of A->diag (default)
|
||||
// when hypre is built with CUDA support, A->diag owns the "host"
|
||||
// pointers (according to A->diag->owns_data)
|
||||
// -2: used when hypre is built with CUDA support, A->diag owns the "hypre"
|
||||
// pointers (according to A->diag->owns_data)
|
||||
// 0: prevent hypre from destroying A->diag->{i,j,data}
|
||||
// 1: same as 0, plus take ownership of A->diag->{i,j}
|
||||
// 2: same as 0, plus take ownership of A->diag->data
|
||||
// 3: same as 0, plus take ownership of A->diag->{i,j,data}
|
||||
// 1: same as 0, plus own the "host" A->diag->{i,j}
|
||||
// 2: same as 0, plus own the "host" A->diag->data
|
||||
// 3: same as 0, plus own the "host" A->diag->{i,j,data}
|
||||
// The same values and rules apply to offdOwner and A->offd.
|
||||
// The possible values for colMapOwner are:
|
||||
// -1: no special treatment of A->col_map_offd (default)
|
||||
@@ -223,39 +310,54 @@ private:
|
||||
// Does the object own the pointer A?
|
||||
signed char ParCSROwner;
|
||||
|
||||
MemoryIJData mem_diag, mem_offd;
|
||||
|
||||
// Initialize with defaults. Does not initialize inherited members.
|
||||
void Init();
|
||||
|
||||
// Delete all owned data. Does not perform re-initialization with defaults.
|
||||
void Destroy();
|
||||
|
||||
void Read(MemoryClass mc) const;
|
||||
void ReadWrite(MemoryClass mc);
|
||||
// The Boolean flags are used in Destroy().
|
||||
void Write(MemoryClass mc, bool set_diag = true, bool set_offd = true);
|
||||
|
||||
// Copy (shallow/deep, based on HYPRE_BIGINT) the I and J arrays from csr to
|
||||
// hypre_csr. Shallow copy the data. Return the appropriate ownership flag.
|
||||
static char CopyCSR(SparseMatrix *csr, hypre_CSRMatrix *hypre_csr);
|
||||
// The CSR arrays are wrapped in the mem_csr struct which is used to move
|
||||
// these arrays to device, if necessary.
|
||||
static signed char CopyCSR(SparseMatrix *csr,
|
||||
MemoryIJData &mem_csr,
|
||||
hypre_CSRMatrix *hypre_csr,
|
||||
bool mem_owner);
|
||||
// Copy (shallow or deep, based on HYPRE_BIGINT) the I and J arrays from
|
||||
// bool_csr to hypre_csr. Allocate the data array and set it to all ones.
|
||||
// Return the appropriate ownership flag.
|
||||
static char CopyBoolCSR(Table *bool_csr, hypre_CSRMatrix *hypre_csr);
|
||||
// Return the appropriate ownership flag. The CSR arrays are wrapped in the
|
||||
// mem_csr struct which is used to move these arrays to device, if necessary.
|
||||
static signed char CopyBoolCSR(Table *bool_csr,
|
||||
MemoryIJData &mem_csr,
|
||||
hypre_CSRMatrix *hypre_csr);
|
||||
|
||||
// Copy the j array of a hypre_CSRMatrix to the given J array, converting
|
||||
// the indices from HYPRE_Int/HYPRE_BigInt to int.
|
||||
static void CopyCSR_J(hypre_CSRMatrix *hypre_csr, int *J);
|
||||
|
||||
// Wrap the data from h_mat into mem with the given ownership flag.
|
||||
// If the new Memory arrays in mem are not suitable to be accessed via
|
||||
// GetHypreMemoryClass(), then mem will be re-allocated using the memory type
|
||||
// returned by GetHypreMemoryType(), the data will be deep copied, and h_mat
|
||||
// will be updated with the new pointers.
|
||||
static signed char HypreCsrToMem(hypre_CSRMatrix *h_mat, MemoryType h_mat_mt,
|
||||
bool own_ija, MemoryIJData &mem);
|
||||
|
||||
public:
|
||||
/// An empty matrix to be used as a reference to an existing matrix
|
||||
HypreParMatrix();
|
||||
|
||||
/// Converts hypre's format to HypreParMatrix
|
||||
/** If @a owner is false, ownership of @a a is not transferred */
|
||||
void WrapHypreParCSRMatrix(hypre_ParCSRMatrix *a, bool owner = true)
|
||||
{
|
||||
Destroy();
|
||||
Init();
|
||||
A = a;
|
||||
ParCSROwner = owner;
|
||||
height = GetNumRows();
|
||||
width = GetNumCols();
|
||||
}
|
||||
void WrapHypreParCSRMatrix(hypre_ParCSRMatrix *a, bool owner = true);
|
||||
|
||||
/// Converts hypre's format to HypreParMatrix
|
||||
/** If @a owner is false, ownership of @a a is not transferred */
|
||||
@@ -274,7 +376,8 @@ public:
|
||||
@warning The ordering of the columns in each row in @a *diag may be
|
||||
changed by this constructor to ensure that the first entry in each row is
|
||||
the diagonal one. This is expected by most hypre functions. */
|
||||
HypreParMatrix(MPI_Comm comm, HYPRE_BigInt glob_size, HYPRE_BigInt *row_starts,
|
||||
HypreParMatrix(MPI_Comm comm, HYPRE_BigInt glob_size,
|
||||
HYPRE_BigInt *row_starts,
|
||||
SparseMatrix *diag); // constructor with 4 arguments, v1
|
||||
|
||||
/// Creates block-diagonal rectangular parallel matrix.
|
||||
@@ -289,25 +392,36 @@ public:
|
||||
|
||||
/// Creates general (rectangular) parallel matrix.
|
||||
/** The new HypreParMatrix does not take ownership of any of the input
|
||||
arrays. See @ref hypre_partitioning_descr "here" for a description of the
|
||||
arrays, if @a own_diag_offd is false (default). If @a own_diag_offd is
|
||||
true, ownership of @a diag and @a offd is transferred to the
|
||||
HypreParMatrix.
|
||||
|
||||
See @ref hypre_partitioning_descr "here" for a description of the
|
||||
partitioning arrays @a row_starts and @a col_starts. */
|
||||
HypreParMatrix(MPI_Comm comm, HYPRE_BigInt global_num_rows,
|
||||
HYPRE_BigInt global_num_cols, HYPRE_BigInt *row_starts,
|
||||
HYPRE_BigInt *col_starts, SparseMatrix *diag, SparseMatrix *offd,
|
||||
HYPRE_BigInt *cmap); // constructor with 8 arguments
|
||||
HYPRE_BigInt *col_starts, SparseMatrix *diag,
|
||||
SparseMatrix *offd, HYPRE_BigInt *cmap,
|
||||
bool own_diag_offd = false); // constructor with 8+1 arguments
|
||||
|
||||
/// Creates general (rectangular) parallel matrix.
|
||||
/** The new HypreParMatrix takes ownership of all input arrays, except
|
||||
@a col_starts and @a row_starts. See @ref hypre_partitioning_descr "here"
|
||||
for a description of the partitioning arrays @a row_starts and @a
|
||||
col_starts. */
|
||||
col_starts.
|
||||
|
||||
If @a hypre_arrays is false, all arrays (except @a row_starts and
|
||||
@a col_starts) are assumed to be allocated according to the MemoryType
|
||||
returned by Device::GetHostMemoryType(). If @a hypre_arrays is true, then
|
||||
the same arrays are assumed to be allocated by hypre as host arrays. */
|
||||
HypreParMatrix(MPI_Comm comm,
|
||||
HYPRE_BigInt global_num_rows, HYPRE_BigInt global_num_cols,
|
||||
HYPRE_BigInt *row_starts, HYPRE_BigInt *col_starts,
|
||||
HYPRE_Int *diag_i, HYPRE_Int *diag_j, double *diag_data,
|
||||
HYPRE_Int *offd_i, HYPRE_Int *offd_j, double *offd_data,
|
||||
HYPRE_Int offd_num_cols,
|
||||
HYPRE_BigInt *offd_col_map); // constructor with 13 arguments
|
||||
HYPRE_BigInt *offd_col_map,
|
||||
bool hypre_arrays = false); // constructor with 13+1 arguments
|
||||
|
||||
/// Creates a parallel matrix from SparseMatrix on processor 0.
|
||||
/** See @ref hypre_partitioning_descr "here" for a description of the
|
||||
@@ -363,12 +477,11 @@ public:
|
||||
/// Typecasting to hypre's HYPRE_ParCSRMatrix, a.k.a. void *
|
||||
operator HYPRE_ParCSRMatrix() { return (HYPRE_ParCSRMatrix) A; }
|
||||
#endif
|
||||
/// Changes the ownership of the the matrix
|
||||
/// Changes the ownership of the matrix
|
||||
hypre_ParCSRMatrix* StealData();
|
||||
|
||||
/// Explicitly set the three ownership flags, see docs for diagOwner etc.
|
||||
void SetOwnerFlags(signed char diag, signed char offd, signed char colmap)
|
||||
{ diagOwner = diag, offdOwner = offd, colMapOwner = colmap; }
|
||||
void SetOwnerFlags(signed char diag, signed char offd, signed char colmap);
|
||||
|
||||
/// Get diag ownership flag
|
||||
signed char OwnsDiag() const { return diagOwner; }
|
||||
@@ -439,7 +552,7 @@ public:
|
||||
with relative size > @a threshold in *this. */
|
||||
#if MFEM_HYPRE_VERSION >= 21800
|
||||
HypreParMatrix *ExtractSubmatrix(const Array<int> &indices,
|
||||
double threshhold=0.0) const;
|
||||
double threshold=0.0) const;
|
||||
#endif
|
||||
|
||||
/// Returns the number of rows in the diagonal block of the ParCSRMatrix
|
||||
@@ -474,6 +587,8 @@ public:
|
||||
partitioning array. */
|
||||
HYPRE_BigInt *GetColStarts() const { return hypre_ParCSRMatrixColStarts(A); }
|
||||
|
||||
virtual MemoryClass GetMemoryClass() const { return GetHypreMemoryClass(); }
|
||||
|
||||
/// Computes y = alpha * A * x + beta * y
|
||||
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y,
|
||||
double alpha = 1.0, double beta = 0.0) const;
|
||||
@@ -492,26 +607,32 @@ public:
|
||||
virtual void MultTranspose(const Vector &x, Vector &y) const
|
||||
{ MultTranspose(1.0, x, 0.0, y); }
|
||||
|
||||
/// Computes y = a * |A| * x + b * y, using entry-wise absolute values of matrix A
|
||||
/** @brief Computes y = a * |A| * x + b * y, using entry-wise absolute values
|
||||
of the matrix A. */
|
||||
void AbsMult(double a, const Vector &x, double b, Vector &y) const;
|
||||
|
||||
/// Computes y = a * |At| * x + b * y, using entry-wise absolute values of the transpose of matrix A
|
||||
/** @brief Computes y = a * |At| * x + b * y, using entry-wise absolute
|
||||
values of the transpose of the matrix A. */
|
||||
void AbsMultTranspose(double a, const Vector &x, double b, Vector &y) const;
|
||||
|
||||
/** The "Boolean" analog of y = alpha * A * x + beta * y, where elements in
|
||||
the sparsity pattern of the matrix are treated as "true". */
|
||||
/** @brief The "Boolean" analog of y = alpha * A * x + beta * y, where
|
||||
elements in the sparsity pattern of the matrix are treated as "true". */
|
||||
void BooleanMult(int alpha, const int *x, int beta, int *y)
|
||||
{
|
||||
HostRead();
|
||||
internal::hypre_ParCSRMatrixBooleanMatvec(A, alpha, const_cast<int*>(x),
|
||||
beta, y);
|
||||
HypreRead();
|
||||
}
|
||||
|
||||
/** The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in
|
||||
the sparsity pattern of the matrix are treated as "true". */
|
||||
/** @brief The "Boolean" analog of y = alpha * A^T * x + beta * y, where
|
||||
elements in the sparsity pattern of the matrix are treated as "true". */
|
||||
void BooleanMultTranspose(int alpha, const int *x, int beta, int *y)
|
||||
{
|
||||
HostRead();
|
||||
internal::hypre_ParCSRMatrixBooleanMatvecT(A, alpha, const_cast<int*>(x),
|
||||
beta, y);
|
||||
HypreRead();
|
||||
}
|
||||
|
||||
/// Initialize all entries with value.
|
||||
@@ -592,6 +713,49 @@ public:
|
||||
/// Eliminate rows from the diagonal and off-diagonal blocks of the matrix.
|
||||
void EliminateRows(const Array<int> &rows);
|
||||
|
||||
/** @brief Eliminate essential BC specified by @a ess_dof_list from the
|
||||
solution @a X to the r.h.s. @a B. */
|
||||
/** This matrix is the matrix with eliminated BC, while @a Ae is such that
|
||||
(A+Ae) is the original (Neumann) matrix before elimination. */
|
||||
void EliminateBC(const HypreParMatrix &Ae, const Array<int> &ess_dof_list,
|
||||
const Vector &X, Vector &B) const;
|
||||
|
||||
/// Update the internal hypre_ParCSRMatrix object, A, to be on host.
|
||||
/** After this call A's diagonal and off-diagonal should not be modified
|
||||
until after a suitable call to {Host,Hypre}{Write,ReadWrite}. */
|
||||
void HostRead() const { Read(Device::GetHostMemoryClass()); }
|
||||
|
||||
/// Update the internal hypre_ParCSRMatrix object, A, to be on host.
|
||||
/** After this call A's diagonal and off-diagonal can be modified on host
|
||||
and subsequent calls to Hypre{Read,Write,ReadWrite} will require a deep
|
||||
copy of the data if hypre is built with device support. */
|
||||
void HostReadWrite() { ReadWrite(Device::GetHostMemoryClass()); }
|
||||
|
||||
/// Update the internal hypre_ParCSRMatrix object, A, to be on host.
|
||||
/** Similar to HostReadWrite(), except that the data will never be copied
|
||||
from device to host to ensure host contains the correct current data. */
|
||||
void HostWrite() { Write(Device::GetHostMemoryClass()); }
|
||||
|
||||
/** @brief Update the internal hypre_ParCSRMatrix object, A, to be in hypre
|
||||
memory space. */
|
||||
/** After this call A's diagonal and off-diagonal should not be modified
|
||||
until after a suitable call to {Host,Hypre}{Write,ReadWrite}. */
|
||||
void HypreRead() const { Read(GetHypreMemoryClass()); }
|
||||
|
||||
/** @brief Update the internal hypre_ParCSRMatrix object, A, to be in hypre
|
||||
memory space. */
|
||||
/** After this call A's diagonal and off-diagonal can be modified in hypre
|
||||
memory space and subsequent calls to Host{Read,Write,ReadWrite} will
|
||||
require a deep copy of the data if hypre is built with device support. */
|
||||
void HypreReadWrite() { ReadWrite(GetHypreMemoryClass()); }
|
||||
|
||||
/** @brief Update the internal hypre_ParCSRMatrix object, A, to be in hypre
|
||||
memory space. */
|
||||
/** Similar to HostReadWrite(), except that the data will never be copied
|
||||
from host to hypre memory space to ensure the latter contains the correct
|
||||
current data. */
|
||||
void HypreWrite() { Write(GetHypreMemoryClass()); }
|
||||
|
||||
/// Prints the locally owned rows in parallel
|
||||
void Print(const char *fname, HYPRE_Int offi = 0, HYPRE_Int offj = 0) const;
|
||||
/// Reads the matrix from a file
|
||||
@@ -664,10 +828,11 @@ HypreParMatrix * RAP(const HypreParMatrix * Rt, const HypreParMatrix *A,
|
||||
HypreParMatrix * HypreParMatrixFromBlocks(Array2D<HypreParMatrix*> &blocks,
|
||||
Array2D<double> *blockCoeff=NULL);
|
||||
|
||||
/** Eliminate essential BC specified by 'ess_dof_list' from the solution X to
|
||||
the r.h.s. B. Here A is a matrix with eliminated BC, while Ae is such that
|
||||
(A+Ae) is the original (Neumann) matrix before elimination. */
|
||||
void EliminateBC(HypreParMatrix &A, HypreParMatrix &Ae,
|
||||
/** @brief Eliminate essential BC specified by @a ess_dof_list from the solution
|
||||
@a X to the r.h.s. @a B. */
|
||||
/** Here @a A is a matrix with eliminated BC, while @a Ae is such that (A+Ae) is
|
||||
the original (Neumann) matrix before elimination. */
|
||||
void EliminateBC(const HypreParMatrix &A, const HypreParMatrix &Ae,
|
||||
const Array<int> &ess_dof_list, const Vector &X, Vector &B);
|
||||
|
||||
|
||||
@@ -679,6 +844,10 @@ protected:
|
||||
HypreParMatrix *A;
|
||||
/// Right-hand side and solution vectors
|
||||
mutable HypreParVector *B, *X;
|
||||
/** @brief Auxiliary buffers for the case when the input or output arrays in
|
||||
methods like Mult(const Vector &, Vector &) need to be deep copied in
|
||||
order to be used by hypre. */
|
||||
mutable Memory<double> auxB, auxX;
|
||||
/// Temporary vectors
|
||||
mutable HypreParVector *V, *Z;
|
||||
/// FIR Filter Temporary Vectors
|
||||
@@ -739,10 +908,15 @@ public:
|
||||
enum Type { Jacobi = 0, l1Jacobi = 1, l1GS = 2, l1GStr = 4, lumpedJacobi = 5,
|
||||
GS = 6, OPFS = 10, Chebyshev = 16, Taubin = 1001, FIR = 1002
|
||||
};
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
static constexpr Type default_type = l1GS;
|
||||
#else
|
||||
static constexpr Type default_type = l1Jacobi;
|
||||
#endif
|
||||
|
||||
HypreSmoother();
|
||||
|
||||
HypreSmoother(const HypreParMatrix &A_, int type = l1GS,
|
||||
HypreSmoother(const HypreParMatrix &A_, int type = default_type,
|
||||
int relax_times = 1, double relax_weight = 1.0,
|
||||
double omega = 1.0, int poly_order = 2,
|
||||
double poly_fraction = .3, int eig_est_cg_iter = 10);
|
||||
@@ -811,6 +985,8 @@ protected:
|
||||
/// Right-hand side and solution vector
|
||||
mutable HypreParVector *B, *X;
|
||||
|
||||
mutable Memory<double> auxB, auxX;
|
||||
|
||||
/// Was hypre's Setup function called already?
|
||||
mutable int setup_called;
|
||||
|
||||
@@ -833,6 +1009,8 @@ public:
|
||||
virtual void SetOperator(const Operator &op)
|
||||
{ mfem_error("HypreSolvers do not support SetOperator!"); }
|
||||
|
||||
virtual MemoryClass GetMemoryClass() const { return GetHypreMemoryClass(); }
|
||||
|
||||
/// Solve the linear system Ax=b
|
||||
virtual void Mult(const HypreParVector &b, HypreParVector &x) const;
|
||||
virtual void Mult(const Vector &b, Vector &x) const;
|
||||
@@ -1251,7 +1429,7 @@ public:
|
||||
See "Nonsymmetric Algebraic Multigrid Based on Local Approximate Ideal
|
||||
Restriction (AIR)," Manteuffel, Ruge, Southworth, SISC (2018),
|
||||
DOI:/10.1137/17M1144350. Options: "distanceR" -> distance of neighbor
|
||||
DOFs to buld restriction operator; options include 1, 2, and 15 (1.5).
|
||||
DOFs for the restriction operator; options include 1, 2, and 15 (1.5).
|
||||
Strings "prerelax" and "postrelax" indicate points to relax on:
|
||||
F = F-points, C = C-points, A = all points. E.g., FFC -> relax on
|
||||
F-points, relax again on F-points, then relax on C-points. */
|
||||
|
||||
+109
-87
@@ -11,10 +11,12 @@
|
||||
|
||||
#include "../config/config.hpp"
|
||||
#include "../general/error.hpp"
|
||||
#include "../general/forall.hpp"
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
|
||||
#include "hypre_parcsr.hpp"
|
||||
#include "hypre.hpp"
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
|
||||
@@ -208,8 +210,8 @@ void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
|
||||
HYPRE_Int index, start;
|
||||
HYPRE_Int i, j, k, irow;
|
||||
|
||||
HYPRE_Real *eliminate_row = mfem_hypre_CTAlloc(HYPRE_Real, diag_nrows);
|
||||
HYPRE_Real *eliminate_col = mfem_hypre_CTAlloc(HYPRE_Real, offd_ncols);
|
||||
HYPRE_Real *eliminate_row = mfem_hypre_CTAlloc_host(HYPRE_Real, diag_nrows);
|
||||
HYPRE_Real *eliminate_col = mfem_hypre_CTAlloc_host(HYPRE_Real, offd_ncols);
|
||||
HYPRE_Real *buf_data, coef;
|
||||
|
||||
/* make sure A has a communication package */
|
||||
@@ -236,9 +238,9 @@ void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
|
||||
/* use a Matvec communication pattern to find (in eliminate_col)
|
||||
which of the local offd columns are to be eliminated */
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
buf_data = mfem_hypre_CTAlloc(HYPRE_Real,
|
||||
hypre_ParCSRCommPkgSendMapStart(comm_pkg,
|
||||
num_sends));
|
||||
buf_data = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Real,
|
||||
hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
index = 0;
|
||||
for (i = 0; i < num_sends; i++)
|
||||
{
|
||||
@@ -270,8 +272,9 @@ void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
offd_cols_to_elim = mfem_hypre_CTAlloc(HYPRE_Int, num_offd_cols_to_elim);
|
||||
eliminate_coefs = mfem_hypre_CTAlloc(HYPRE_Real, num_offd_cols_to_elim);
|
||||
offd_cols_to_elim = mfem_hypre_CTAlloc_host(HYPRE_Int,
|
||||
num_offd_cols_to_elim);
|
||||
eliminate_coefs = mfem_hypre_CTAlloc_host(HYPRE_Real, num_offd_cols_to_elim);
|
||||
|
||||
/* get a list of offd column indices and coefs */
|
||||
num_offd_cols_to_elim = 0;
|
||||
@@ -286,9 +289,9 @@ void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(buf_data);
|
||||
mfem_hypre_TFree(eliminate_col);
|
||||
mfem_hypre_TFree(eliminate_row);
|
||||
mfem_hypre_TFree_host(buf_data);
|
||||
mfem_hypre_TFree_host(eliminate_col);
|
||||
mfem_hypre_TFree_host(eliminate_row);
|
||||
|
||||
/* eliminate the off-diagonal part */
|
||||
hypre_CSRMatrixEliminateOffdColsAXB(offd, num_offd_cols_to_elim,
|
||||
@@ -305,8 +308,8 @@ void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
|
||||
Bdata[irow] = Xdata[irow];
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(offd_cols_to_elim);
|
||||
mfem_hypre_TFree(eliminate_coefs);
|
||||
mfem_hypre_TFree_host(offd_cols_to_elim);
|
||||
mfem_hypre_TFree_host(eliminate_coefs);
|
||||
}
|
||||
|
||||
|
||||
@@ -332,7 +335,7 @@ void hypre_CSRMatrixElimCreate(hypre_CSRMatrix *A,
|
||||
HYPRE_Int *A_j = hypre_CSRMatrixJ(A);
|
||||
HYPRE_Int A_rows = hypre_CSRMatrixNumRows(A);
|
||||
|
||||
hypre_CSRMatrixI(Ae) = mfem_hypre_TAlloc(HYPRE_Int, A_rows+1);
|
||||
hypre_CSRMatrixI(Ae) = mfem_hypre_TAlloc_host(HYPRE_Int, A_rows+1);
|
||||
|
||||
HYPRE_Int *Ae_i = hypre_CSRMatrixI(Ae);
|
||||
HYPRE_Int nnz = 0;
|
||||
@@ -373,9 +376,12 @@ void hypre_CSRMatrixElimCreate(hypre_CSRMatrix *A,
|
||||
}
|
||||
Ae_i[A_rows] = nnz;
|
||||
|
||||
hypre_CSRMatrixJ(Ae) = mfem_hypre_TAlloc(HYPRE_Int, nnz);
|
||||
hypre_CSRMatrixData(Ae) = mfem_hypre_TAlloc(HYPRE_Real, nnz);
|
||||
hypre_CSRMatrixJ(Ae) = mfem_hypre_TAlloc_host(HYPRE_Int, nnz);
|
||||
hypre_CSRMatrixData(Ae) = mfem_hypre_TAlloc_host(HYPRE_Real, nnz);
|
||||
hypre_CSRMatrixNumNonzeros(Ae) = nnz;
|
||||
#if MFEM_HYPRE_VERSION >= 21800
|
||||
hypre_CSRMatrixMemoryLocation(Ae) = HYPRE_MEMORY_HOST;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -481,6 +487,7 @@ void hypre_CSRMatrixEliminateRows(hypre_CSRMatrix *A,
|
||||
\ A_bi | A_bb - I /
|
||||
|
||||
*/
|
||||
|
||||
void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
hypre_ParCSRMatrix **Ae,
|
||||
HYPRE_Int num_rowscols_to_elim,
|
||||
@@ -524,8 +531,10 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
HYPRE_Int num_sends, *int_buf_data;
|
||||
HYPRE_Int index, start;
|
||||
|
||||
HYPRE_Int *eliminate_diag_col = mfem_hypre_CTAlloc(HYPRE_Int, A_diag_ncols);
|
||||
HYPRE_Int *eliminate_offd_col = mfem_hypre_CTAlloc(HYPRE_Int, A_offd_ncols);
|
||||
HYPRE_Int *eliminate_diag_col = mfem_hypre_CTAlloc_host(HYPRE_Int,
|
||||
A_diag_ncols);
|
||||
HYPRE_Int *eliminate_offd_col = mfem_hypre_CTAlloc_host(HYPRE_Int,
|
||||
A_offd_ncols);
|
||||
|
||||
/* make sure A has a communication package */
|
||||
comm_pkg = hypre_ParCSRMatrixCommPkg(A);
|
||||
@@ -548,7 +557,7 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
/* use a Matvec communication pattern to find (in eliminate_col)
|
||||
which of the local offd columns are to be eliminated */
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
int_buf_data = mfem_hypre_CTAlloc(
|
||||
int_buf_data = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Int,
|
||||
hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
index = 0;
|
||||
@@ -562,7 +571,8 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
comm_handle = hypre_ParCSRCommHandleCreate(11, comm_pkg,
|
||||
int_buf_data, eliminate_offd_col);
|
||||
int_buf_data,
|
||||
eliminate_offd_col);
|
||||
|
||||
/* eliminate diagonal part, overlapping it with communication */
|
||||
if (ignore_rows)
|
||||
@@ -602,7 +612,8 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
if (eliminate_offd_col[i]) { num_offd_cols_to_elim++; }
|
||||
}
|
||||
|
||||
offd_cols_to_elim = mfem_hypre_CTAlloc(HYPRE_Int, num_offd_cols_to_elim);
|
||||
offd_cols_to_elim = mfem_hypre_CTAlloc_host(HYPRE_Int,
|
||||
num_offd_cols_to_elim);
|
||||
|
||||
/* get a list of offd column indices and coefs */
|
||||
num_offd_cols_to_elim = 0;
|
||||
@@ -614,14 +625,14 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(int_buf_data);
|
||||
mfem_hypre_TFree(eliminate_offd_col);
|
||||
mfem_hypre_TFree(eliminate_diag_col);
|
||||
mfem_hypre_TFree_host(int_buf_data);
|
||||
mfem_hypre_TFree_host(eliminate_offd_col);
|
||||
mfem_hypre_TFree_host(eliminate_diag_col);
|
||||
}
|
||||
|
||||
/* eliminate the off-diagonal part */
|
||||
col_mark = mfem_hypre_CTAlloc(HYPRE_Int, A_offd_ncols);
|
||||
col_remap = mfem_hypre_CTAlloc(HYPRE_Int, A_offd_ncols);
|
||||
col_mark = mfem_hypre_CTAlloc_host(HYPRE_Int, A_offd_ncols);
|
||||
col_remap = mfem_hypre_CTAlloc_host(HYPRE_Int, A_offd_ncols);
|
||||
|
||||
if (ignore_rows)
|
||||
{
|
||||
@@ -665,7 +676,7 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
if (col_mark[i]) { Ae_offd_ncols++; }
|
||||
}
|
||||
|
||||
Ae_col_map_offd = mfem_hypre_CTAlloc(HYPRE_BigInt, Ae_offd_ncols);
|
||||
Ae_col_map_offd = mfem_hypre_CTAlloc_host(HYPRE_BigInt, Ae_offd_ncols);
|
||||
|
||||
Ae_offd_ncols = 0;
|
||||
for (i = 0; i < A_offd_ncols; i++)
|
||||
@@ -679,9 +690,9 @@ void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
|
||||
hypre_ParCSRMatrixColMapOffd(*Ae) = Ae_col_map_offd;
|
||||
hypre_CSRMatrixNumCols(Ae_offd) = Ae_offd_ncols;
|
||||
|
||||
mfem_hypre_TFree(col_remap);
|
||||
mfem_hypre_TFree(col_mark);
|
||||
mfem_hypre_TFree(offd_cols_to_elim);
|
||||
mfem_hypre_TFree_host(col_remap);
|
||||
mfem_hypre_TFree_host(col_mark);
|
||||
mfem_hypre_TFree_host(offd_cols_to_elim);
|
||||
|
||||
hypre_ParCSRMatrixSetNumNonzeros(*Ae);
|
||||
hypre_MatvecCommPkgCreate(*Ae);
|
||||
@@ -718,11 +729,11 @@ void hypre_CSRMatrixSplit(hypre_CSRMatrix *A,
|
||||
HYPRE_Int A_rows = hypre_CSRMatrixNumRows(A);
|
||||
HYPRE_Int A_cols = hypre_CSRMatrixNumCols(A);
|
||||
|
||||
HYPRE_Int *num_rows = mfem_hypre_CTAlloc(HYPRE_Int, nr);
|
||||
HYPRE_Int *num_cols = mfem_hypre_CTAlloc(HYPRE_Int, nc);
|
||||
HYPRE_Int *num_rows = mfem_hypre_CTAlloc_host(HYPRE_Int, nr);
|
||||
HYPRE_Int *num_cols = mfem_hypre_CTAlloc_host(HYPRE_Int, nc);
|
||||
|
||||
HYPRE_Int *block_row = mfem_hypre_TAlloc(HYPRE_Int, A_rows);
|
||||
HYPRE_Int *block_col = mfem_hypre_TAlloc(HYPRE_Int, A_cols);
|
||||
HYPRE_Int *block_row = mfem_hypre_TAlloc_host(HYPRE_Int, A_rows);
|
||||
HYPRE_Int *block_col = mfem_hypre_TAlloc_host(HYPRE_Int, A_cols);
|
||||
|
||||
for (i = 0; i < A_rows; i++)
|
||||
{
|
||||
@@ -738,8 +749,13 @@ void hypre_CSRMatrixSplit(hypre_CSRMatrix *A,
|
||||
{
|
||||
for (j = 0; j < nc; j++)
|
||||
{
|
||||
hypre_CSRMatrix *B = hypre_CSRMatrixCreate(num_rows[i], num_cols[j], 0);
|
||||
hypre_CSRMatrixI(B) = mfem_hypre_CTAlloc(HYPRE_Int, num_rows[i] + 1);
|
||||
hypre_CSRMatrix *B = hypre_CSRMatrixCreate(num_rows[i],
|
||||
num_cols[j], 0);
|
||||
hypre_CSRMatrixI(B) = mfem_hypre_CTAlloc_host(HYPRE_Int,
|
||||
num_rows[i] + 1);
|
||||
#if MFEM_HYPRE_VERSION >= 21800
|
||||
hypre_CSRMatrixMemoryLocation(B) = HYPRE_MEMORY_HOST;
|
||||
#endif
|
||||
blocks[i*nc + j] = B;
|
||||
}
|
||||
}
|
||||
@@ -768,8 +784,8 @@ void hypre_CSRMatrixSplit(hypre_CSRMatrix *A,
|
||||
rs = B_i[k], B_i[k] = nnz, nnz += rs;
|
||||
}
|
||||
|
||||
hypre_CSRMatrixJ(B) = mfem_hypre_TAlloc(HYPRE_Int, nnz);
|
||||
hypre_CSRMatrixData(B) = mfem_hypre_TAlloc(HYPRE_Complex, nnz);
|
||||
hypre_CSRMatrixJ(B) = mfem_hypre_TAlloc_host(HYPRE_Int, nnz);
|
||||
hypre_CSRMatrixData(B) = mfem_hypre_TAlloc_host(HYPRE_Complex, nnz);
|
||||
hypre_CSRMatrixNumNonzeros(B) = nnz;
|
||||
}
|
||||
|
||||
@@ -789,11 +805,11 @@ void hypre_CSRMatrixSplit(hypre_CSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(block_col);
|
||||
mfem_hypre_TFree(block_row);
|
||||
mfem_hypre_TFree_host(block_col);
|
||||
mfem_hypre_TFree_host(block_row);
|
||||
|
||||
mfem_hypre_TFree(num_cols);
|
||||
mfem_hypre_TFree(num_rows);
|
||||
mfem_hypre_TFree_host(num_cols);
|
||||
mfem_hypre_TFree_host(num_rows);
|
||||
}
|
||||
|
||||
|
||||
@@ -824,8 +840,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
HYPRE_Int num_blocks = nr * nc;
|
||||
|
||||
/* mark local rows and columns with block number */
|
||||
HYPRE_Int *row_block_num = mfem_hypre_TAlloc(HYPRE_Int, local_rows);
|
||||
HYPRE_Int *col_block_num = mfem_hypre_TAlloc(HYPRE_Int, local_cols);
|
||||
HYPRE_Int *row_block_num = mfem_hypre_TAlloc_host(HYPRE_Int, local_rows);
|
||||
HYPRE_Int *col_block_num = mfem_hypre_TAlloc_host(HYPRE_Int, local_cols);
|
||||
|
||||
for (i = 0; i < local_rows; i++)
|
||||
{
|
||||
@@ -837,7 +853,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
/* determine the block numbers for offd columns */
|
||||
HYPRE_BigInt* offd_col_block_num = mfem_hypre_TAlloc(HYPRE_BigInt, offd_cols);
|
||||
HYPRE_BigInt *offd_col_block_num = mfem_hypre_TAlloc_host(HYPRE_BigInt,
|
||||
offd_cols);
|
||||
hypre_ParCSRCommHandle *comm_handle;
|
||||
HYPRE_BigInt *int_buf_data;
|
||||
{
|
||||
@@ -850,18 +867,19 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
/* calculate the final global column numbers for each block */
|
||||
HYPRE_Int *count = mfem_hypre_CTAlloc(HYPRE_Int, nc);
|
||||
HYPRE_BigInt *block_global_col = mfem_hypre_TAlloc(HYPRE_BigInt, local_cols);
|
||||
HYPRE_Int *count = mfem_hypre_CTAlloc_host(HYPRE_Int, nc);
|
||||
HYPRE_BigInt *block_global_col = mfem_hypre_TAlloc_host(HYPRE_BigInt,
|
||||
local_cols);
|
||||
HYPRE_BigInt first_col = hypre_ParCSRMatrixFirstColDiag(A) / nc;
|
||||
for (i = 0; i < local_cols; i++)
|
||||
{
|
||||
block_global_col[i] = first_col + count[col_block_num[i]]++;
|
||||
}
|
||||
mfem_hypre_TFree(count);
|
||||
mfem_hypre_TFree_host(count);
|
||||
|
||||
/* use a Matvec communication pattern to determine offd_col_block_num */
|
||||
HYPRE_Int num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
int_buf_data = mfem_hypre_CTAlloc(
|
||||
int_buf_data = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_BigInt,
|
||||
hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
HYPRE_Int start, index = 0;
|
||||
@@ -874,7 +892,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
int_buf_data[index++] = col_block_num[k] + nc*block_global_col[k];
|
||||
}
|
||||
}
|
||||
mfem_hypre_TFree(block_global_col);
|
||||
|
||||
mfem_hypre_TFree_host(block_global_col);
|
||||
|
||||
#if MFEM_HYPRE_VERSION < 21600
|
||||
const int job = 11;
|
||||
@@ -892,8 +911,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
hypre_MPI_Comm_size(comm, &num_procs);
|
||||
}
|
||||
|
||||
HYPRE_BigInt *row_starts = mfem_hypre_TAlloc(HYPRE_BigInt, num_procs+1);
|
||||
HYPRE_BigInt *col_starts = mfem_hypre_TAlloc(HYPRE_BigInt, num_procs+1);
|
||||
HYPRE_BigInt *row_starts = mfem_hypre_TAlloc_host(HYPRE_BigInt, num_procs+1);
|
||||
HYPRE_BigInt *col_starts = mfem_hypre_TAlloc_host(HYPRE_BigInt, num_procs+1);
|
||||
for (i = 0; i <= num_procs; i++)
|
||||
{
|
||||
row_starts[i] = hypre_ParCSRMatrixRowStarts(A)[i] / nr;
|
||||
@@ -908,30 +927,33 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
/* split diag part */
|
||||
hypre_CSRMatrix **csr_blocks = mfem_hypre_TAlloc(hypre_CSRMatrix*, nr*nc);
|
||||
hypre_CSRMatrix **csr_blocks = mfem_hypre_TAlloc_host(hypre_CSRMatrix*,
|
||||
nr*nc);
|
||||
hypre_CSRMatrixSplit(Adiag, nr, nc, row_block_num, col_block_num,
|
||||
csr_blocks);
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
mfem_hypre_TFree(hypre_ParCSRMatrixDiag(blocks[i]));
|
||||
mfem_hypre_TFree_host(hypre_ParCSRMatrixDiag(blocks[i]));
|
||||
hypre_ParCSRMatrixDiag(blocks[i]) = csr_blocks[i];
|
||||
}
|
||||
|
||||
/* finish communication, receive offd_col_block_num */
|
||||
hypre_ParCSRCommHandleDestroy(comm_handle);
|
||||
mfem_hypre_TFree(int_buf_data);
|
||||
mfem_hypre_TFree_host(int_buf_data);
|
||||
|
||||
/* decode global offd column numbers */
|
||||
HYPRE_Int *offd_col_block_num_nc = mfem_hypre_TAlloc(HYPRE_Int, offd_cols);
|
||||
HYPRE_BigInt* offd_global_col = mfem_hypre_TAlloc(HYPRE_BigInt, offd_cols);
|
||||
HYPRE_Int *offd_col_block_num_nc = mfem_hypre_TAlloc_host(HYPRE_Int,
|
||||
offd_cols);
|
||||
HYPRE_BigInt* offd_global_col = mfem_hypre_TAlloc_host(HYPRE_BigInt,
|
||||
offd_cols);
|
||||
for (i = 0; i < offd_cols; i++)
|
||||
{
|
||||
offd_global_col[i] = offd_col_block_num[i] / nc;
|
||||
offd_col_block_num_nc[i] = offd_col_block_num[i] % nc;
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(offd_col_block_num);
|
||||
mfem_hypre_TFree_host(offd_col_block_num);
|
||||
|
||||
/* split offd part */
|
||||
hypre_CSRMatrixSplit(Aoffd, nr, nc, row_block_num, offd_col_block_num_nc,
|
||||
@@ -939,13 +961,13 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
mfem_hypre_TFree(hypre_ParCSRMatrixOffd(blocks[i]));
|
||||
mfem_hypre_TFree_host(hypre_ParCSRMatrixOffd(blocks[i]));
|
||||
hypre_ParCSRMatrixOffd(blocks[i]) = csr_blocks[i];
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(csr_blocks);
|
||||
mfem_hypre_TFree(col_block_num);
|
||||
mfem_hypre_TFree(row_block_num);
|
||||
mfem_hypre_TFree_host(csr_blocks);
|
||||
mfem_hypre_TFree_host(col_block_num);
|
||||
mfem_hypre_TFree_host(row_block_num);
|
||||
|
||||
/* update block col-maps */
|
||||
for (int bi = 0; bi < nr; bi++)
|
||||
@@ -956,8 +978,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
hypre_CSRMatrix *block_offd = hypre_ParCSRMatrixOffd(block);
|
||||
HYPRE_Int block_offd_cols = hypre_CSRMatrixNumCols(block_offd);
|
||||
|
||||
HYPRE_BigInt *block_col_map = mfem_hypre_TAlloc(HYPRE_BigInt,
|
||||
block_offd_cols);
|
||||
HYPRE_BigInt *block_col_map = mfem_hypre_TAlloc_host(HYPRE_BigInt,
|
||||
block_offd_cols);
|
||||
for (i = j = 0; i < offd_cols; i++)
|
||||
{
|
||||
HYPRE_Int bn = offd_col_block_num_nc[i];
|
||||
@@ -969,8 +991,8 @@ void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(offd_global_col);
|
||||
mfem_hypre_TFree(offd_col_block_num_nc);
|
||||
mfem_hypre_TFree_host(offd_global_col);
|
||||
mfem_hypre_TFree_host(offd_col_block_num_nc);
|
||||
|
||||
/* finish the new matrices, make them own all the stuff */
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
@@ -1367,7 +1389,7 @@ hypre_ParCSRCommHandleCreate_bool(HYPRE_Int job,
|
||||
HYPRE_Int ip, vec_start, vec_len;
|
||||
|
||||
num_requests = num_sends + num_recvs;
|
||||
requests = mfem_hypre_CTAlloc(hypre_MPI_Request, num_requests);
|
||||
requests = mfem_hypre_CTAlloc_host(hypre_MPI_Request, num_requests);
|
||||
|
||||
hypre_MPI_Comm_size(comm, &num_procs);
|
||||
hypre_MPI_Comm_rank(comm, &my_id);
|
||||
@@ -1424,7 +1446,7 @@ hypre_ParCSRCommHandleCreate_bool(HYPRE_Int job,
|
||||
* set up comm_handle and return
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
comm_handle = mfem_hypre_CTAlloc(hypre_ParCSRCommHandle, 1);
|
||||
comm_handle = mfem_hypre_CTAlloc_host(hypre_ParCSRCommHandle, 1);
|
||||
|
||||
hypre_ParCSRCommHandleCommPkg(comm_handle) = comm_pkg;
|
||||
hypre_ParCSRCommHandleSendData(comm_handle) = send_data;
|
||||
@@ -1452,7 +1474,7 @@ void hypre_ParCSRMatrixAbsMatvec(hypre_ParCSRMatrix *A,
|
||||
|
||||
HYPRE_Real *x_tmp, *x_buf;
|
||||
|
||||
x_tmp = mfem_hypre_CTAlloc(HYPRE_Real, num_cols_offd);
|
||||
x_tmp = mfem_hypre_CTAlloc_host(HYPRE_Real, num_cols_offd);
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* If there exists no CommPkg for A, a CommPkg is generated using
|
||||
@@ -1465,7 +1487,7 @@ void hypre_ParCSRMatrixAbsMatvec(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
x_buf = mfem_hypre_CTAlloc(
|
||||
x_buf = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Real, hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
|
||||
index = 0;
|
||||
@@ -1489,8 +1511,8 @@ void hypre_ParCSRMatrixAbsMatvec(hypre_ParCSRMatrix *A,
|
||||
hypre_CSRMatrixAbsMatvec(offd, alpha, x_tmp, 1.0, y);
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(x_buf);
|
||||
mfem_hypre_TFree(x_tmp);
|
||||
mfem_hypre_TFree_host(x_buf);
|
||||
mfem_hypre_TFree_host(x_tmp);
|
||||
}
|
||||
|
||||
/* Based on hypre_ParCSRMatrixMatvecT in par_csr_matvec.c */
|
||||
@@ -1511,7 +1533,7 @@ void hypre_ParCSRMatrixAbsMatvecT(hypre_ParCSRMatrix *A,
|
||||
|
||||
HYPRE_Int i, j, jj, end, num_sends;
|
||||
|
||||
y_tmp = mfem_hypre_TAlloc(HYPRE_Real, num_cols_offd);
|
||||
y_tmp = mfem_hypre_TAlloc_host(HYPRE_Real, num_cols_offd);
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* If there exists no CommPkg for A, a CommPkg is generated using
|
||||
@@ -1524,7 +1546,7 @@ void hypre_ParCSRMatrixAbsMatvecT(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
y_buf = mfem_hypre_CTAlloc(
|
||||
y_buf = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Real, hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
|
||||
if (num_cols_offd)
|
||||
@@ -1568,8 +1590,8 @@ void hypre_ParCSRMatrixAbsMatvecT(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(y_buf);
|
||||
mfem_hypre_TFree(y_tmp);
|
||||
mfem_hypre_TFree_host(y_buf);
|
||||
mfem_hypre_TFree_host(y_tmp);
|
||||
}
|
||||
|
||||
/* Based on hypre_ParCSRMatrixMatvec in par_csr_matvec.c */
|
||||
@@ -1589,7 +1611,7 @@ void hypre_ParCSRMatrixBooleanMatvec(hypre_ParCSRMatrix *A,
|
||||
|
||||
HYPRE_Bool *x_tmp, *x_buf;
|
||||
|
||||
x_tmp = mfem_hypre_CTAlloc(HYPRE_Bool, num_cols_offd);
|
||||
x_tmp = mfem_hypre_CTAlloc_host(HYPRE_Bool, num_cols_offd);
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* If there exists no CommPkg for A, a CommPkg is generated using
|
||||
@@ -1602,7 +1624,7 @@ void hypre_ParCSRMatrixBooleanMatvec(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
x_buf = mfem_hypre_CTAlloc(
|
||||
x_buf = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Bool, hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
|
||||
index = 0;
|
||||
@@ -1626,8 +1648,8 @@ void hypre_ParCSRMatrixBooleanMatvec(hypre_ParCSRMatrix *A,
|
||||
hypre_CSRMatrixBooleanMatvec(offd, alpha, x_tmp, 1, y);
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(x_buf);
|
||||
mfem_hypre_TFree(x_tmp);
|
||||
mfem_hypre_TFree_host(x_buf);
|
||||
mfem_hypre_TFree_host(x_tmp);
|
||||
}
|
||||
|
||||
/* Based on hypre_ParCSRMatrixMatvecT in par_csr_matvec.c */
|
||||
@@ -1648,7 +1670,7 @@ void hypre_ParCSRMatrixBooleanMatvecT(hypre_ParCSRMatrix *A,
|
||||
|
||||
HYPRE_Int i, j, jj, end, num_sends;
|
||||
|
||||
y_tmp = mfem_hypre_TAlloc(HYPRE_Bool, num_cols_offd);
|
||||
y_tmp = mfem_hypre_TAlloc_host(HYPRE_Bool, num_cols_offd);
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* If there exists no CommPkg for A, a CommPkg is generated using
|
||||
@@ -1661,7 +1683,7 @@ void hypre_ParCSRMatrixBooleanMatvecT(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
|
||||
num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg);
|
||||
y_buf = mfem_hypre_CTAlloc(
|
||||
y_buf = mfem_hypre_CTAlloc_host(
|
||||
HYPRE_Bool, hypre_ParCSRCommPkgSendMapStart(comm_pkg, num_sends));
|
||||
|
||||
if (num_cols_offd)
|
||||
@@ -1705,8 +1727,8 @@ void hypre_ParCSRMatrixBooleanMatvecT(hypre_ParCSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(y_buf);
|
||||
mfem_hypre_TFree(y_tmp);
|
||||
mfem_hypre_TFree_host(y_buf);
|
||||
mfem_hypre_TFree_host(y_tmp);
|
||||
}
|
||||
|
||||
HYPRE_Int
|
||||
@@ -1733,7 +1755,7 @@ hypre_CSRMatrixSum(hypre_CSRMatrix *A,
|
||||
return -1; /* error: incompatible matrix dimensions */
|
||||
}
|
||||
|
||||
marker = mfem_hypre_CTAlloc(HYPRE_Int, ncols_A);
|
||||
marker = mfem_hypre_CTAlloc_host(HYPRE_Int, ncols_A);
|
||||
for (ia = 0; ia < ncols_A; ia++)
|
||||
{
|
||||
marker[ia] = -1;
|
||||
@@ -1757,7 +1779,7 @@ hypre_CSRMatrixSum(hypre_CSRMatrix *A,
|
||||
}
|
||||
}
|
||||
|
||||
mfem_hypre_TFree(marker);
|
||||
mfem_hypre_TFree_host(marker);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1818,7 +1840,7 @@ hypre_ParCSRMatrixAdd(hypre_ParCSRMatrix *A,
|
||||
return NULL; /* error: A_offd and B_offd have different dimensions */
|
||||
}
|
||||
/* copy A_cmap -> C_cmap */
|
||||
C_cmap = mfem_hypre_TAlloc(HYPRE_BigInt, A_cmap_size);
|
||||
C_cmap = mfem_hypre_TAlloc_host(HYPRE_BigInt, A_cmap_size);
|
||||
for (im = 0; im < A_cmap_size; im++)
|
||||
{
|
||||
C_cmap[im] = A_cmap[im];
|
||||
@@ -1859,7 +1881,7 @@ hypre_ParCSRMatrixAdd(hypre_ParCSRMatrix *A,
|
||||
csr_B = hypre_MergeDiagAndOffd(B);
|
||||
|
||||
/* add A and B */
|
||||
csr_C_temp = hypre_CSRMatrixAdd(csr_A,csr_B);
|
||||
csr_C_temp = hypre_CSRMatrixAdd(csr_A, csr_B);
|
||||
|
||||
/* delete CSR versions of A and B */
|
||||
ierr += hypre_CSRMatrixDestroy(csr_A);
|
||||
|
||||
+19
-2
@@ -19,6 +19,7 @@
|
||||
// Enable internal hypre timing routines
|
||||
#define HYPRE_TIMING
|
||||
|
||||
#include "../general/mem_manager.hpp"
|
||||
#include "_hypre_parcsr_mv.h"
|
||||
|
||||
// Older hypre versions do not define HYPRE_BigInt and HYPRE_MPI_BIG_INT, so we
|
||||
@@ -38,13 +39,23 @@ typedef HYPRE_Int HYPRE_BigInt;
|
||||
#define mfem_hypre_CTAlloc(type, size) hypre_CTAlloc(type, size)
|
||||
#define mfem_hypre_TFree(ptr) hypre_TFree(ptr)
|
||||
|
||||
#define mfem_hypre_TAlloc_host(type, size) hypre_TAlloc(type, size)
|
||||
#define mfem_hypre_CTAlloc_host(type, size) hypre_CTAlloc(type, size)
|
||||
#define mfem_hypre_TFree_host(ptr) hypre_TFree(ptr)
|
||||
|
||||
#else // MFEM_HYPRE_VERSION >= 21400
|
||||
|
||||
#define mfem_hypre_TAlloc(type, size) \
|
||||
hypre_TAlloc(type, size, HYPRE_MEMORY_HOST)
|
||||
hypre_TAlloc(type, size, HYPRE_MEMORY_DEVICE)
|
||||
#define mfem_hypre_CTAlloc(type, size) \
|
||||
hypre_CTAlloc(type, size, HYPRE_MEMORY_DEVICE)
|
||||
#define mfem_hypre_TFree(ptr) hypre_TFree(ptr, HYPRE_MEMORY_DEVICE)
|
||||
|
||||
#define mfem_hypre_TAlloc_host(type, size) \
|
||||
hypre_TAlloc(type, size, HYPRE_MEMORY_HOST)
|
||||
#define mfem_hypre_CTAlloc_host(type, size) \
|
||||
hypre_CTAlloc(type, size, HYPRE_MEMORY_HOST)
|
||||
#define mfem_hypre_TFree(ptr) hypre_TFree(ptr, HYPRE_MEMORY_HOST)
|
||||
#define mfem_hypre_TFree_host(ptr) hypre_TFree(ptr, HYPRE_MEMORY_HOST)
|
||||
|
||||
// Notes regarding allocation and deallocation of hypre objects in 2.14.0
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -85,6 +96,12 @@ namespace mfem
|
||||
// become part of HYPRE at some point. In the meantime the module can be
|
||||
// thought of as an extension of HYPRE.
|
||||
|
||||
struct MemoryIJData
|
||||
{
|
||||
Memory<HYPRE_Int> I, J;
|
||||
Memory<double> data;
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
|
||||
+1169
File diff suppressed because it is too large
Load Diff
+244
@@ -0,0 +1,244 @@
|
||||
#ifndef MFEM_IMEX
|
||||
#define MFEM_IMEX
|
||||
|
||||
#include "../config/config.hpp"
|
||||
#include "operator.hpp"
|
||||
#include "ode.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
/** Class for spatial discretizations of a PDE resulting in the time-dependent,
|
||||
nonlinear set of ODEs with implicit-explicit additive partition
|
||||
M*du/dt = N_E(u,t) + N_I(u,t).
|
||||
MFEM typically treats time integration as
|
||||
du/dt = F^{-1} G(u),
|
||||
Here F represents what MFEM calls the “implicit” part, and G represents the
|
||||
“explicit” part; in simpler terms, F is typically just a mass matrix.
|
||||
|
||||
For BDF schemes, the ImplicitSolve function is a bit different, and it is
|
||||
more natural to apply M and M^{-1} separate from the Mult functions, so we
|
||||
include MassMult and MassInv as functions to be provided, and do not include
|
||||
such actions in the Mult functions. */
|
||||
class IMEXTimeDependentOperator : public TimeDependentOperator
|
||||
{
|
||||
protected:
|
||||
mutable Vector temp; // Auxillary vector
|
||||
|
||||
public:
|
||||
// Sets linearly implicit to false by default
|
||||
IMEXTimeDependentOperator(int n, double t=0.0, Type type=EXPLICIT)
|
||||
: TimeDependentOperator(n, t, type) { };
|
||||
~IMEXTimeDependentOperator() { };
|
||||
|
||||
/** Apply action of implicit part of operator y <- N_I(x,y). For fully
|
||||
implicit schemes, this just corresponds to applying the time-dependent
|
||||
(nonlinear) operator.
|
||||
PREVIOUSLY CALLED ExplicitMult */
|
||||
virtual void ImplicitMult(const Vector &x, Vector &y) const = 0;
|
||||
|
||||
/** Apply action of explicit part of operator y <- N_E(x,y) */
|
||||
virtual void ExplicitMult(const Vector &x, Vector &y) const { y = 0.0; };
|
||||
|
||||
/** Solve k = f(x+dt*k) for stage k, where f() is the implicit part of
|
||||
the operator. Used in Runge-Kutta methods. */
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k)
|
||||
{ mfem::mfem_error("IMEXTimeDependentOperator::ImplicitSolve() is not overridden!"); };
|
||||
|
||||
/** Solve M*x - dtf(x, t) = b for solution x, where f() is the implicit
|
||||
part of the operator. Used in BDF methods. */
|
||||
virtual void ImplicitSolve2(const double dt, const Vector &b, Vector &x)
|
||||
{ mfem::mfem_error("IMEXTimeDependentOperator::ImplicitSolve2() is not overridden!"); };
|
||||
|
||||
/** Apply action mass matrix, y = M*x.
|
||||
If not re-implemented, this method simply generates an error.
|
||||
PREVIOUSLY CALLED ImplictMult */
|
||||
virtual void MassMult(const Vector &x, Vector &y) const = 0;
|
||||
|
||||
/** Apply action of inverse of mass matrix, y = M^{-1}*x.
|
||||
If not re-implemented, this method simply generates an error.
|
||||
NOTE : only necessary for PolyIMEX methods. */
|
||||
virtual void MassInv(const Vector &x, Vector &y) const = 0;
|
||||
};
|
||||
|
||||
/** Class holding RK Butcher tableau, and associated data required by
|
||||
implicit and explicit splitting. */
|
||||
class IMEXRKData
|
||||
{
|
||||
public:
|
||||
// Implicit Runge Kutta type. Enumeration (s, \sigma, p):
|
||||
// - s = number of implicit stages
|
||||
// - \sigma = number of explicit stages
|
||||
// - p = order
|
||||
// In this notation, when s = \sigma, we satisfy (2.3)/(2.4) in
|
||||
// Ascher et al., and do not need to compute the final explicit
|
||||
// stage. This is represented in the stiffly_accurate boolean.
|
||||
enum Type {
|
||||
IMEX111 = 111,
|
||||
IMEX121 = 121,
|
||||
IMEX122 = 122,
|
||||
IMEX222 = 222,
|
||||
IMEX232 = 232,
|
||||
IMEX233 = 233,
|
||||
IMEX443 = 443,
|
||||
// ARK ESDIRK-ERK schemes: enumeration (s,p), for total number of
|
||||
// stages s.
|
||||
ARK43 = -43
|
||||
};
|
||||
|
||||
IMEXRKData() : s(-1) { };
|
||||
IMEXRKData(Type ID_) : ID(ID_) { SetData(); };
|
||||
~IMEXRKData() { };
|
||||
|
||||
/// Set explicit RK data
|
||||
void SetExplicitData(DenseMatrix Ae_, Vector be_, Vector ce_);
|
||||
/// Set implicit RK data
|
||||
void SetImplicitData(DenseMatrix Ai_, Vector bi_, Vector ci_, bool esdirk_=false);
|
||||
void SetID(Type ID_) { ID=ID_; SetData(); };
|
||||
|
||||
bool esdirk;
|
||||
bool stiffly_accurate;
|
||||
bool use_final_exp_stage;
|
||||
int s;
|
||||
|
||||
DenseMatrix Ai; // Implicit Butcher matrix
|
||||
Vector bi; // Implicit Butcher tableau weights
|
||||
DenseMatrix Ae; // Explicit Butcher matrix
|
||||
Vector be; // Explicit Butcher tableau weights
|
||||
Vector c0; // Butcher tableau nodes (same for implicit and explicit!)
|
||||
|
||||
private:
|
||||
Type ID;
|
||||
void SetData();
|
||||
void InitData();
|
||||
};
|
||||
|
||||
/** Class for two-part additive IMEX RK method, where explicit and implicit
|
||||
stage vectors are stored. Assume same abscissae, {c}, for both schemes.
|
||||
Butcher Data must be provided either in a custom IMEXRKData object, or
|
||||
using the IMEXRKData::Type for predefined tableaux. */
|
||||
class IMEXRK : public ODESolver
|
||||
{
|
||||
protected:
|
||||
IMEXRKData tableaux;
|
||||
std::vector< Vector *> exp_stages;
|
||||
std::vector< Vector *> imp_stages;
|
||||
IMEXTimeDependentOperator *imex; // Spatial discretization.
|
||||
|
||||
public:
|
||||
IMEXRK(IMEXRKData tableaux_) : ODESolver(), tableaux(tableaux_) { };
|
||||
IMEXRK(IMEXRKData::Type type_) : ODESolver(), tableaux(type_) { };
|
||||
~IMEXRK();
|
||||
void Init(IMEXTimeDependentOperator &_imex);
|
||||
void Step(Vector &x, double &t, double &dt) override;
|
||||
};
|
||||
|
||||
/** Class holding BDF integrator data. Setting alpha < 0 (the default
|
||||
constructor) defines alpha = 2/(q-1), corresponding to classical BDF
|
||||
of order q. */
|
||||
class BDFData
|
||||
{
|
||||
public:
|
||||
|
||||
enum Type {
|
||||
BDF1 = 01, BDF2 = 02, BDF3 = 03, BDF4 = 04,
|
||||
IMEX_BDF1 = 11, IMEX_BDF2 = 12, IMEX_BDF3 = 13,
|
||||
IMEX_BDF4 = 14
|
||||
};
|
||||
|
||||
BDFData() { };
|
||||
BDFData(Type ID_, double alpha_=-1) : ID(ID_), alpha(alpha_) { SetData(); };
|
||||
~BDFData() { };
|
||||
|
||||
int GetID() { return static_cast<int>(ID); };
|
||||
void SetID(Type ID_, double alpha_=-1)
|
||||
{
|
||||
ID=ID_;
|
||||
alpha = alpha_;
|
||||
SetData();
|
||||
};
|
||||
void Print()
|
||||
{
|
||||
std::cout << "q = " << q << "\n";
|
||||
std::cout << "alpha = " << alpha << "\n";
|
||||
std::cout << "A:\n";
|
||||
A.PrintMatlab();
|
||||
std::cout << "Be:\n";
|
||||
Be.PrintMatlab();
|
||||
std::cout << "Bi:\n";
|
||||
Bi.Print();
|
||||
std::cout << "z:\n";
|
||||
z0.Print();
|
||||
};
|
||||
|
||||
double alpha;
|
||||
int q; // Number of previous values stored
|
||||
bool shifted_nodes; // false = clssical BDF, true = Polynomial BDF w/ shifted nodes
|
||||
DenseMatrix A; // Previous solution coefficients
|
||||
Vector Bi; // Implicit coefficients
|
||||
DenseMatrix Be; // Explicit coefficients
|
||||
Vector z0;
|
||||
|
||||
|
||||
private:
|
||||
Type ID;
|
||||
void SetData();
|
||||
void InitData();
|
||||
};
|
||||
|
||||
/** Class for IMEX-BDF methods, including classical IMEX-BDF and IMEX-
|
||||
Polynomial-BDF (IMEX-PBDF). IMEX-PBDF methods have an additional
|
||||
alpha parameter, where larger alpha leads to smaller stability
|
||||
regions and a smaller leading accuracy constant, while smaller
|
||||
alpha leads to larger stabiltiy regions and a larger accuracy
|
||||
constant. For classical methods, there are two implementations:
|
||||
- ClassicalStep() stores previous solutions and the explicit
|
||||
part of the operator evaluated on the solution, and
|
||||
- ClassicalStepNoStore() does not store the explicit
|
||||
component, but must re-evaluate q times during each time
|
||||
step.
|
||||
This option can be set via the recompute_exp input. The type of
|
||||
scheme must be set through the BDFData structure or BDFData::Type.
|
||||
There is also an option to use pointwise Lagrange interpolating
|
||||
polynomials to provide an initial guess for the ImplicitSolve. This
|
||||
is set via InterpolateGuess(). This option is only implemented for
|
||||
PBDF. */
|
||||
class IMEXBDF : public ODESolver
|
||||
{
|
||||
private:
|
||||
BDFData data;
|
||||
bool recompute_exp;
|
||||
bool interpolate;
|
||||
int initialized;
|
||||
double dt_prev;
|
||||
std::vector< Vector*> sols;
|
||||
std::vector< Vector*> exp_sols;
|
||||
IMEXTimeDependentOperator *imex; // Spatial discretization
|
||||
IMEXRK *RKsolver;
|
||||
std::vector<double> exp_nodes;
|
||||
|
||||
void AlphaStep(Vector &x, double &t, double &dt);
|
||||
void ClassicalStep(Vector &x, double &t, double &dt);
|
||||
void ClassicalStepNoStore(Vector &x, double &t, double &dt);
|
||||
|
||||
public:
|
||||
IMEXBDF(BDFData data_, bool recompute_exp_=false) :
|
||||
ODESolver(), data(data_), recompute_exp(recompute_exp_),
|
||||
interpolate(false) { };
|
||||
IMEXBDF(BDFData::Type scheme, bool recompute_exp_=false) :
|
||||
ODESolver(), recompute_exp(recompute_exp_), interpolate(false)
|
||||
{ data.SetID(scheme); };
|
||||
IMEXBDF(BDFData::Type scheme, double alpha) :
|
||||
ODESolver(), interpolate(false), recompute_exp(false)
|
||||
{ data.SetID(scheme, alpha); };
|
||||
~IMEXBDF();
|
||||
|
||||
void Init(IMEXTimeDependentOperator &_imex);
|
||||
void Step(Vector &x, double &t, double &dt);
|
||||
void InterpolateGuess() {interpolate = true; };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "invariants.hpp"
|
||||
#include "constraints.hpp"
|
||||
#include "auxiliary.hpp"
|
||||
#include "imex.hpp"
|
||||
|
||||
#ifdef MFEM_USE_AMGX
|
||||
#include "amgxsolver.hpp"
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ void Operator::InitTVectors(const Operator *Po, const Operator *Ri,
|
||||
else
|
||||
{
|
||||
// B points to same data as b
|
||||
B.NewMemoryAndSize(b.GetMemory(), b.Size(), false);
|
||||
B.MakeRef(b, 0, b.Size());
|
||||
}
|
||||
if (!IsIdentityProlongation(Pi))
|
||||
{
|
||||
@@ -44,7 +44,7 @@ void Operator::InitTVectors(const Operator *Po, const Operator *Ri,
|
||||
else
|
||||
{
|
||||
// X points to same data as x
|
||||
X.NewMemoryAndSize(x.GetMemory(), x.Size(), false);
|
||||
X.MakeRef(x, 0, x.Size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -606,9 +606,11 @@ void SLI(const Operator &A, Solver &B, const Vector &b, Vector &x,
|
||||
|
||||
void CGSolver::UpdateVectors()
|
||||
{
|
||||
r.SetSize(width);
|
||||
d.SetSize(width);
|
||||
z.SetSize(width);
|
||||
MemoryType mt = GetMemoryType(oper->GetMemoryClass());
|
||||
|
||||
r.SetSize(width, mt); r.UseDevice(true);
|
||||
d.SetSize(width, mt); d.UseDevice(true);
|
||||
z.SetSize(width, mt); z.UseDevice(true);
|
||||
}
|
||||
|
||||
void CGSolver::Mult(const Vector &b, Vector &x) const
|
||||
@@ -616,6 +618,7 @@ void CGSolver::Mult(const Vector &b, Vector &x) const
|
||||
int i;
|
||||
double r0, den, nom, nom0, betanom, alpha, beta;
|
||||
|
||||
x.UseDevice(true);
|
||||
if (iterative_mode)
|
||||
{
|
||||
oper->Mult(x, r);
|
||||
|
||||
+11
-23
@@ -33,7 +33,12 @@ int SparseMatrix::SparseMatrixCount = 0;
|
||||
cusparseHandle_t SparseMatrix::handle = nullptr;
|
||||
size_t SparseMatrix::bufferSize = 0;
|
||||
void * SparseMatrix::dBuffer = nullptr;
|
||||
#endif
|
||||
# if CUSPARSE_VERSION >= 11400
|
||||
# define MFEM_CUSPARSE_ALG CUSPARSE_SPMV_CSR_ALG1
|
||||
# else
|
||||
# define MFEM_CUSPARSE_ALG CUSPARSE_CSRMV_ALG1
|
||||
# endif // CUSPARSE_VERSION >= 11400
|
||||
#endif // MFEM_USE_CUDA
|
||||
|
||||
void SparseMatrix::InitCuSparse()
|
||||
{
|
||||
@@ -679,25 +684,16 @@ void SparseMatrix::AddMult(const Vector &x, Vector &y, const double a) const
|
||||
cusparseCreateMatDescr(&matA_descr);
|
||||
cusparseSetMatIndexBase(matA_descr, CUSPARSE_INDEX_BASE_ZERO);
|
||||
cusparseSetMatType(matA_descr, CUSPARSE_MATRIX_TYPE_GENERAL);
|
||||
|
||||
#endif
|
||||
|
||||
initBuffers = true;
|
||||
}
|
||||
// Allocate kernel space. Buffer is shared between different sparsemats
|
||||
size_t newBufferSize = 0;
|
||||
|
||||
#if CUDA_VERSION >= 11020
|
||||
cusparseSpMV_bufferSize(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha,
|
||||
matA_descr,
|
||||
vecX_descr, &beta, vecY_descr, CUDA_R_64F,
|
||||
CUSPARSE_SPMV_CSR_ALG1, &newBufferSize);
|
||||
#elif CUDA_VERSION >= 10010
|
||||
cusparseSpMV_bufferSize(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha,
|
||||
matA_descr,
|
||||
vecX_descr, &beta, vecY_descr, CUDA_R_64F,
|
||||
CUSPARSE_CSRMV_ALG1, &newBufferSize);
|
||||
#endif
|
||||
MFEM_CUSPARSE_ALG, &newBufferSize);
|
||||
|
||||
// Check if we need to resize
|
||||
if (newBufferSize > bufferSize)
|
||||
@@ -707,30 +703,22 @@ void SparseMatrix::AddMult(const Vector &x, Vector &y, const double a) const
|
||||
CuMemAlloc(&dBuffer, bufferSize);
|
||||
}
|
||||
|
||||
#if CUDA_VERSION >= 11020
|
||||
#if CUDA_VERSION >= 10010
|
||||
// Update input/output vectors
|
||||
cusparseDnVecSetValues(vecX_descr, const_cast<double *>(d_x));
|
||||
cusparseDnVecSetValues(vecY_descr, d_y);
|
||||
|
||||
// Y = alpha A * X + beta * Y
|
||||
cusparseSpMV(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, matA_descr,
|
||||
vecX_descr, &beta, vecY_descr, CUDA_R_64F, CUSPARSE_SPMV_CSR_ALG1, dBuffer);
|
||||
#elif CUDA_VERSION >= 10010
|
||||
// Update input/output vectors
|
||||
cusparseDnVecSetValues(vecX_descr, const_cast<double *>(d_x));
|
||||
cusparseDnVecSetValues(vecY_descr, d_y);
|
||||
|
||||
// Y = alpha A * X + beta * Y
|
||||
cusparseSpMV(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, matA_descr,
|
||||
vecX_descr, &beta, vecY_descr, CUDA_R_64F, CUSPARSE_CSRMV_ALG1, dBuffer);
|
||||
vecX_descr, &beta, vecY_descr, CUDA_R_64F, MFEM_CUSPARSE_ALG, dBuffer);
|
||||
#else
|
||||
cusparseDcsrmv(handle, CUSPARSE_OPERATION_NON_TRANSPOSE,
|
||||
Height(), Width(), J.Capacity(),
|
||||
&alpha, matA_descr,
|
||||
const_cast<double *>(d_A), const_cast<int *>(d_I), const_cast<int *>(d_J),
|
||||
const_cast<double *>(d_x), &beta, d_y);
|
||||
#endif
|
||||
#endif
|
||||
#endif // CUDA_VERSION >= 10010
|
||||
#endif // MFEM_USE_CUDA
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+4
-1
@@ -189,6 +189,9 @@ SuperLURowLocMatrix::SuperLURowLocMatrix( const HypreParMatrix & hypParMat )
|
||||
dCreate_CompRowLoc_Matrix_dist(A, m, n, nnz_loc, m_loc, fst_row,
|
||||
nzval, colind, rowptr,
|
||||
SLU_NR_loc, SLU_D, SLU_GE);
|
||||
|
||||
// Save global number of columns (width) of the matrix
|
||||
num_global_cols = n;
|
||||
}
|
||||
|
||||
SuperLURowLocMatrix::~SuperLURowLocMatrix()
|
||||
@@ -262,7 +265,7 @@ SuperLUSolver::~SuperLUSolver()
|
||||
if ( LUStructInitialized_ )
|
||||
{
|
||||
ScalePermstructFree(SPstruct);
|
||||
Destroy_LU(width, grid, LUstruct);
|
||||
Destroy_LU(APtr_->GetGlobalNumColumns(), grid, LUstruct);
|
||||
LUstructFree(LUstruct);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,12 @@ public:
|
||||
|
||||
void * InternalData() const { return rowLocPtr_; }
|
||||
|
||||
HYPRE_BigInt GetGlobalNumColumns() const { return num_global_cols; }
|
||||
|
||||
private:
|
||||
MPI_Comm comm_;
|
||||
void * rowLocPtr_;
|
||||
HYPRE_BigInt num_global_cols;
|
||||
|
||||
}; // mfem::SuperLURowLocMatrix
|
||||
|
||||
|
||||
@@ -773,6 +773,7 @@ void Vector::Randomize(int seed)
|
||||
// srand(seed++);
|
||||
srand((unsigned)seed);
|
||||
|
||||
HostWrite();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
data[i] = std::abs(rand()/max);
|
||||
|
||||
+20
-4
@@ -82,6 +82,11 @@ public:
|
||||
Vector(double *data_, int size_)
|
||||
{ data.Wrap(data_, size_, false); size = size_; }
|
||||
|
||||
/** @brief Create a Vector referencing a sub-vector of the Vector @a base
|
||||
starting at the given offset, @a base_offset, and size @a size_. */
|
||||
Vector(Vector &base, int base_offset, int size_)
|
||||
: data(base.data, base_offset, size_), size(size_) { }
|
||||
|
||||
/// Create a Vector of size @a size_ using MemoryType @a mt.
|
||||
Vector(int size_, MemoryType mt)
|
||||
: data(size_, mt), size(size_) { }
|
||||
@@ -159,6 +164,11 @@ public:
|
||||
/// Reset the Vector to use the given external Memory @a mem and size @a s.
|
||||
/** If @a own_mem is false, the Vector will not own any of the pointers of
|
||||
@a mem.
|
||||
|
||||
Note that when @a own_mem is true, the @a mem object can be destroyed
|
||||
immediately by the caller but `mem.Delete()` should NOT be called since
|
||||
the Vector object takes ownership of all pointers owned by @a mem.
|
||||
|
||||
@sa NewDataAndSize(). */
|
||||
inline void NewMemoryAndSize(const Memory<double> &mem, int s, bool own_mem);
|
||||
|
||||
@@ -224,10 +234,10 @@ public:
|
||||
const Memory<double> &GetMemory() const { return data; }
|
||||
|
||||
/// Update the memory location of the vector to match @a v.
|
||||
void SyncMemory(const Vector &v) { GetMemory().Sync(v.GetMemory()); }
|
||||
void SyncMemory(const Vector &v) const { GetMemory().Sync(v.GetMemory()); }
|
||||
|
||||
/// Update the alias memory location of the vector to match @a v.
|
||||
void SyncAliasMemory(const Vector &v)
|
||||
void SyncAliasMemory(const Vector &v) const
|
||||
{ GetMemory().SyncAlias(v.GetMemory(),Size()); }
|
||||
|
||||
/// Read the Vector data (host pointer) ownership flag.
|
||||
@@ -559,8 +569,14 @@ inline void Vector::NewMemoryAndSize(const Memory<double> &mem, int s,
|
||||
{
|
||||
data.Delete();
|
||||
size = s;
|
||||
data = mem;
|
||||
if (!own_mem) { data.ClearOwnerFlags(); }
|
||||
if (own_mem)
|
||||
{
|
||||
data = mem;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.MakeAlias(mem, 0, s);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Vector::MakeRef(Vector &base, int offset, int s)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# CONTRIBUTING.md for details.
|
||||
|
||||
# The current MFEM version as an integer, see also `CMakeLists.txt`.
|
||||
MFEM_VERSION = 40201
|
||||
MFEM_VERSION = 40301
|
||||
MFEM_VERSION_STRING = $(shell printf "%06d" $(MFEM_VERSION) | \
|
||||
sed -e 's/^0*\(.*.\)\(..\)\(..\)$$/\1.\2.\3/' -e 's/\.0/./g' -e 's/\.0$$//')
|
||||
|
||||
@@ -209,27 +209,28 @@ CXXFLAGS ?= $(OPTIM_FLAGS)
|
||||
|
||||
# MPI configuration
|
||||
ifneq ($(MFEM_USE_MPI),YES)
|
||||
MFEM_HOST_CXX = $(CXX)
|
||||
HOST_CXX = $(CXX)
|
||||
PKGS_NEED_MPI = SUPERLU MUMPS STRUMPACK PETSC PUMI SLEPC MKL_CPARDISO
|
||||
$(foreach mpidep,$(PKGS_NEED_MPI),$(if $(MFEM_USE_$(mpidep):NO=),\
|
||||
$(warning *** [MPI is OFF] setting MFEM_USE_$(mpidep) = NO)\
|
||||
$(eval override MFEM_USE_$(mpidep)=NO),))
|
||||
else
|
||||
MFEM_HOST_CXX = $(MPICXX)
|
||||
HOST_CXX = $(MPICXX)
|
||||
INCFLAGS += $(HYPRE_OPT)
|
||||
ALL_LIBS += $(HYPRE_LIB)
|
||||
endif
|
||||
|
||||
# Default configuration
|
||||
ifeq ($(MFEM_USE_CUDA)$(MFEM_USE_HIP),NONO)
|
||||
MFEM_CXX ?= $(MFEM_HOST_CXX)
|
||||
MFEM_HOST_CXX := $(MFEM_CXX)
|
||||
MFEM_CXX ?= $(HOST_CXX)
|
||||
MFEM_HOST_CXX ?= $(MFEM_CXX)
|
||||
XCOMPILER = $(CXX_XCOMPILER)
|
||||
XLINKER = $(CXX_XLINKER)
|
||||
endif
|
||||
|
||||
ifeq ($(MFEM_USE_CUDA),YES)
|
||||
MFEM_CXX ?= $(CUDA_CXX)
|
||||
MFEM_HOST_CXX ?= $(HOST_CXX)
|
||||
CXXFLAGS += $(CUDA_FLAGS) -ccbin $(MFEM_HOST_CXX)
|
||||
XCOMPILER = $(CUDA_XCOMPILER)
|
||||
XLINKER = $(CUDA_XLINKER)
|
||||
@@ -247,7 +248,7 @@ ifeq ($(MFEM_USE_HIP),YES)
|
||||
ALL_LIBS += $(MPI_LIB)
|
||||
endif
|
||||
MFEM_CXX ?= $(HIP_CXX)
|
||||
MFEM_HOST_CXX := $(MFEM_CXX)
|
||||
MFEM_HOST_CXX ?= $(MFEM_CXX)
|
||||
CXXFLAGS += $(HIP_FLAGS)
|
||||
XLINKER = $(HIP_XLINKER)
|
||||
XCOMPILER = $(HIP_XCOMPILER)
|
||||
@@ -271,7 +272,7 @@ ifeq ($(MFEM_USE_LEGACY_OPENMP),YES)
|
||||
endif
|
||||
|
||||
# List of MFEM dependencies, that require the *_LIB variable to be non-empty
|
||||
MFEM_REQ_LIB_DEPS = SUPERLU MUMPS METIS CONDUIT SIDRE LAPACK SUNDIALS MESQUITE\
|
||||
MFEM_REQ_LIB_DEPS = SUPERLU MUMPS METIS FMS CONDUIT SIDRE LAPACK SUNDIALS MESQUITE\
|
||||
SUITESPARSE STRUMPACK GINKGO GNUTLS NETCDF PETSC SLEPC MPFR PUMI HIOP GSLIB\
|
||||
OCCA CEED RAJA UMPIRE MKL_CPARDISO AMGX CALIPER
|
||||
|
||||
@@ -335,11 +336,11 @@ MFEM_DEFINES = MFEM_VERSION MFEM_VERSION_STRING MFEM_GIT_STRING MFEM_USE_MPI\
|
||||
MFEM_USE_LEGACY_OPENMP MFEM_USE_MEMALLOC MFEM_TIMER_TYPE MFEM_USE_SUNDIALS\
|
||||
MFEM_USE_MESQUITE MFEM_USE_SUITESPARSE MFEM_USE_GINKGO MFEM_USE_SUPERLU\
|
||||
MFEM_USE_STRUMPACK MFEM_USE_GNUTLS MFEM_USE_NETCDF MFEM_USE_PETSC\
|
||||
MFEM_USE_SLEPC MFEM_USE_MPFR MFEM_USE_SIDRE MFEM_USE_CONDUIT MFEM_USE_PUMI\
|
||||
MFEM_USE_HIOP MFEM_USE_GSLIB MFEM_USE_CUDA MFEM_USE_HIP MFEM_USE_OCCA\
|
||||
MFEM_USE_CEED MFEM_USE_RAJA MFEM_USE_UMPIRE MFEM_USE_SIMD MFEM_USE_ADIOS2\
|
||||
MFEM_USE_MKL_CPARDISO MFEM_USE_AMGX MFEM_USE_MUMPS MFEM_USE_CALIPER\
|
||||
MFEM_SOURCE_DIR MFEM_INSTALL_DIR
|
||||
MFEM_USE_SLEPC MFEM_USE_MPFR MFEM_USE_SIDRE MFEM_USE_FMS MFEM_USE_CONDUIT\
|
||||
MFEM_USE_PUMI MFEM_USE_HIOP MFEM_USE_GSLIB MFEM_USE_CUDA MFEM_USE_HIP\
|
||||
MFEM_USE_OCCA MFEM_USE_CEED MFEM_USE_RAJA MFEM_USE_UMPIRE MFEM_USE_SIMD\
|
||||
MFEM_USE_ADIOS2 MFEM_USE_MKL_CPARDISO MFEM_USE_AMGX MFEM_USE_MUMPS\
|
||||
MFEM_USE_CALIPER MFEM_SOURCE_DIR MFEM_INSTALL_DIR
|
||||
|
||||
# List of makefile variables that will be written to config.mk:
|
||||
MFEM_CONFIG_VARS = MFEM_CXX MFEM_HOST_CXX MFEM_CPPFLAGS MFEM_CXXFLAGS\
|
||||
@@ -519,6 +520,17 @@ test test-noclean:
|
||||
if [ 0 -ne $${ERR} ]; then echo "Some tests failed."; exit 1; \
|
||||
else echo "All tests passed."; fi
|
||||
|
||||
.PHONY: test-miniapps
|
||||
test-miniapps:
|
||||
@echo "Building all miniapps ..."
|
||||
@$(MAKE) $(MAKEOVERRIDES_SAVE) miniapps
|
||||
@ERR=0; for dir in $(MINIAPP_TEST_DIRS); do \
|
||||
echo "Running tests in $${dir} ..."; \
|
||||
if ! $(MAKE) -j1 -C $(BLD)$${dir} test; then \
|
||||
ERR=1; fi; done; \
|
||||
if [ 0 -ne $${ERR} ]; then echo "Some miniapp tests failed."; \
|
||||
exit 1; else echo "All miniapp tests passed."; fi
|
||||
|
||||
unittest: lib
|
||||
$(MAKE) -C $(BLD)tests/unit test
|
||||
|
||||
@@ -651,6 +663,7 @@ status info:
|
||||
$(info MFEM_USE_SLEPC = $(MFEM_USE_SLEPC))
|
||||
$(info MFEM_USE_MPFR = $(MFEM_USE_MPFR))
|
||||
$(info MFEM_USE_SIDRE = $(MFEM_USE_SIDRE))
|
||||
$(info MFEM_USE_FMS = $(MFEM_USE_FMS))
|
||||
$(info MFEM_USE_CONDUIT = $(MFEM_USE_CONDUIT))
|
||||
$(info MFEM_USE_PUMI = $(MFEM_USE_PUMI))
|
||||
$(info MFEM_USE_HIOP = $(MFEM_USE_HIOP))
|
||||
|
||||
+11
-5
@@ -75,7 +75,7 @@ void Mesh::GetElementCenter(int i, Vector ¢er)
|
||||
|
||||
double Mesh::GetElementSize(ElementTransformation *T, int type)
|
||||
{
|
||||
DenseMatrix J(Dim);
|
||||
DenseMatrix J(spaceDim,Dim);
|
||||
|
||||
Geometry::Type geom = T->GetGeometryType();
|
||||
T->SetIntPoint(&Geometries.GetCenter(geom));
|
||||
@@ -83,7 +83,7 @@ double Mesh::GetElementSize(ElementTransformation *T, int type)
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
return pow(fabs(J.Det()), 1./Dim);
|
||||
return pow(fabs(J.Weight()), 1./Dim);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ double Mesh::GetElementSize(int i, int type)
|
||||
|
||||
double Mesh::GetElementSize(int i, const Vector &dir)
|
||||
{
|
||||
DenseMatrix J(Dim);
|
||||
DenseMatrix J(spaceDim,Dim);
|
||||
Vector d_hat(Dim);
|
||||
GetElementJacobian(i, J);
|
||||
J.MultTranspose(dir, d_hat);
|
||||
@@ -599,6 +599,8 @@ void Mesh::GetEdgeTransformation(int EdgeNo, IsoparametricTransformation *EdTr)
|
||||
else
|
||||
{
|
||||
const FiniteElement *edge_el = Nodes->FESpace()->GetEdgeElement(EdgeNo);
|
||||
Nodes->HostRead();
|
||||
const GridFunction &nodes = *Nodes;
|
||||
if (edge_el)
|
||||
{
|
||||
Array<int> vdofs;
|
||||
@@ -609,7 +611,7 @@ void Mesh::GetEdgeTransformation(int EdgeNo, IsoparametricTransformation *EdTr)
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
pm(i, j) = (*Nodes)(vdofs[n*i+j]);
|
||||
pm(i, j) = nodes(vdofs[n*i+j]);
|
||||
}
|
||||
}
|
||||
EdTr->SetFE(edge_el);
|
||||
@@ -4108,7 +4110,11 @@ void Mesh::MakeRefined_(Mesh &orig_mesh, const Array<int> ref_factors,
|
||||
}
|
||||
|
||||
MFEM_ASSERT(CheckElementOrientation(false) == 0, "");
|
||||
MFEM_ASSERT(CheckBdrElementOrientation(false) == 0, "");
|
||||
|
||||
// The check below is disabled because is fails for parallel meshes with
|
||||
// interior "boundary" element that, when such "boundary" element is between
|
||||
// two elements on different processors.
|
||||
// MFEM_ASSERT(CheckBdrElementOrientation(false) == 0, "");
|
||||
}
|
||||
|
||||
Mesh Mesh::MakeSimplicial(const Mesh &orig_mesh)
|
||||
|
||||
+15
-11
@@ -503,7 +503,7 @@ public:
|
||||
Mesh& operator=(Mesh &&mesh);
|
||||
|
||||
/// Explicitly delete the copy assignment operator.
|
||||
Mesh& operator=(Mesh &mesh) = delete;
|
||||
Mesh& operator=(const Mesh &mesh) = delete;
|
||||
|
||||
/** @name Named mesh constructors.
|
||||
|
||||
@@ -811,11 +811,6 @@ public:
|
||||
MFEM_DEPRECATED
|
||||
Mesh(Mesh *orig_mesh, int ref_factor, int ref_type);
|
||||
|
||||
/// A version of the above constructor for non-uniform refinement.
|
||||
/** The input array @a ref_factors contains one refinement factor per element
|
||||
of the input mesh. */
|
||||
Mesh(Mesh *orig_mesh, const Array<int> &ref_factors, int ref_type);
|
||||
|
||||
/** This is similar to the mesh constructor with the same arguments, but here
|
||||
the current mesh is destroyed and another one created based on the data
|
||||
stream again given in MFEM, Netgen, or VTK format. If generate_edges = 0
|
||||
@@ -877,17 +872,26 @@ public:
|
||||
long GetGlobalNE() const { return ReduceInt(NumOfElements); }
|
||||
|
||||
/** @brief Return the mesh geometric factors corresponding to the given
|
||||
integration rule. */
|
||||
/** If the device MemoryType parameter @a d_mt is specified, then the
|
||||
returned object will use that type unless it was previously allocated
|
||||
with a different type. */
|
||||
integration rule.
|
||||
|
||||
The IntegrationRule used with GetGeometricFactors needs to remain valid
|
||||
until the internally stored GeometricFactors objects are destroyed (by
|
||||
either calling Mesh::DeleteGeometricFactors or the Mesh destructor). If
|
||||
the device MemoryType parameter @a d_mt is specified, then the returned
|
||||
object will use that type unless it was previously allocated with a
|
||||
different type. */
|
||||
const GeometricFactors* GetGeometricFactors(
|
||||
const IntegrationRule& ir,
|
||||
const int flags,
|
||||
MemoryType d_mt = MemoryType::DEFAULT);
|
||||
|
||||
/** @brief Return the mesh geometric factors for the faces corresponding
|
||||
to the given integration rule. */
|
||||
to the given integration rule.
|
||||
|
||||
The IntegrationRule used with GetFaceGeometricFactors needs to remain
|
||||
valid until the internally stored FaceGeometricFactors objects are
|
||||
destroyed (by either calling Mesh::DeleteGeometricFactors or the Mesh
|
||||
destructor). */
|
||||
const FaceGeometricFactors* GetFaceGeometricFactors(const IntegrationRule& ir,
|
||||
const int flags,
|
||||
FaceType type);
|
||||
|
||||
@@ -2283,7 +2283,6 @@ void NCMesh::GetMeshComponents(Mesh &mesh) const
|
||||
// left uninitialized here; they will be initialized later by the Mesh from
|
||||
// Nodes -- here we just make sure mesh.vertices has the correct size.
|
||||
|
||||
mesh.elements.SetSize(NElements);
|
||||
mesh.elements.SetSize(0);
|
||||
|
||||
mesh.boundary.SetSize(0);
|
||||
|
||||
+1
-1
@@ -131,6 +131,7 @@ public:
|
||||
int GetNVertices() const { return NVertices; }
|
||||
int GetNEdges() const { return NEdges; }
|
||||
int GetNFaces() const { return NFaces; }
|
||||
virtual int GetNGhostElements() const { return 0; }
|
||||
|
||||
/** Perform the given batch of refinements. Please note that in the presence
|
||||
of anisotropic splits additional refinements may be necessary to keep
|
||||
@@ -160,7 +161,6 @@ public:
|
||||
derefinements may have to be skipped to preserve mesh consistency. */
|
||||
virtual void Derefine(const Array<int> &derefs);
|
||||
|
||||
|
||||
// master/slave lists
|
||||
|
||||
/// Identifies a vertex/edge/face in both Mesh and NCMesh.
|
||||
|
||||
@@ -1339,6 +1339,37 @@ void ParNCMesh::LimitNCLevel(int max_nc_level)
|
||||
}
|
||||
}
|
||||
|
||||
void ParNCMesh::GetFineToCoarsePartitioning(const Array<int> &derefs,
|
||||
Array<int> &new_ranks) const
|
||||
{
|
||||
new_ranks.SetSize(leaf_elements.Size()-GetNGhostElements());
|
||||
for (int i = 0; i < leaf_elements.Size()-GetNGhostElements(); i++)
|
||||
{
|
||||
new_ranks[i] = elements[leaf_elements[i]].rank;
|
||||
}
|
||||
|
||||
for (int i = 0; i < derefs.Size(); i++)
|
||||
{
|
||||
int row = derefs[i];
|
||||
MFEM_VERIFY(row >= 0 && row < derefinements.Size(),
|
||||
"invalid derefinement number.");
|
||||
|
||||
const int* fine = derefinements.GetRow(row);
|
||||
int size = derefinements.RowSize(row);
|
||||
|
||||
int coarse_rank = INT_MAX;
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
int fine_rank = elements[leaf_elements[fine[j]]].rank;
|
||||
coarse_rank = std::min(coarse_rank, fine_rank);
|
||||
}
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
new_ranks[fine[j]] = coarse_rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParNCMesh::Derefine(const Array<int> &derefs)
|
||||
{
|
||||
MFEM_VERIFY(Dim < 3 || Iso,
|
||||
|
||||
+5
-1
@@ -95,6 +95,11 @@ public:
|
||||
in sync. The interface is identical. */
|
||||
virtual void Derefine(const Array<int> &derefs);
|
||||
|
||||
/** Gets partitioning for the coarse mesh if the current fine mesh were to
|
||||
be derefined. */
|
||||
virtual void GetFineToCoarsePartitioning(const Array<int> &derefs,
|
||||
Array<int> &new_ranks) const;
|
||||
|
||||
/** Migrate leaf elements of the global refinement hierarchy (including ghost
|
||||
elements) so that each processor owns the same number of leaves (+-1).
|
||||
The default partitioning strategy is based on equal splitting of the
|
||||
@@ -243,7 +248,6 @@ public:
|
||||
The debug mesh will have element attributes set to element rank + 1. */
|
||||
void GetDebugMesh(Mesh &debug_mesh) const;
|
||||
|
||||
|
||||
protected: // interface for ParMesh
|
||||
|
||||
friend class ParMesh;
|
||||
|
||||
+36
-25
@@ -35,7 +35,7 @@
|
||||
// mpirun -np 2 pfindpts -m ../../data/inline-wedge.mesh -o 3
|
||||
// mpirun -np 2 pfindpts -m ../../data/amr-quad.mesh -o 2
|
||||
// mpirun -np 2 pfindpts -m ../../data/rt-2d-q3.mesh -o 3 -mo 4 -ft 2
|
||||
|
||||
// mpirun -np 2 pfindpts -m ../../data/inline-quad.mesh -ft 1 -no-vis -sr0
|
||||
|
||||
#include "mfem.hpp"
|
||||
|
||||
@@ -74,6 +74,7 @@ int main (int argc, char *argv[])
|
||||
bool visualization = true;
|
||||
int fieldtype = 0;
|
||||
int ncomp = 1;
|
||||
bool search_on_rank_0 = false;
|
||||
|
||||
// Parse command-line options.
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -94,6 +95,9 @@ int main (int argc, char *argv[])
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
"--no-visualization",
|
||||
"Enable or disable GLVis visualization.");
|
||||
args.AddOption(&search_on_rank_0, "-sr0", "--search-on-r0", "-no-sr0",
|
||||
"--no-search-on-r0",
|
||||
"Enable search only on rank 0 (disable to search points on all tasks).");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -211,7 +215,7 @@ int main (int argc, char *argv[])
|
||||
// Note that some points might be outside, if the mesh is not a box. Note
|
||||
// also that all tasks search the same points (not mandatory).
|
||||
const int pts_cnt_1D = 10;
|
||||
const int pts_cnt = pow(pts_cnt_1D, dim);
|
||||
int pts_cnt = pow(pts_cnt_1D, dim);
|
||||
Vector vxyz(pts_cnt * dim);
|
||||
if (dim == 2)
|
||||
{
|
||||
@@ -237,6 +241,12 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if ( (myid != 0) && (search_on_rank_0) )
|
||||
{
|
||||
pts_cnt = 0;
|
||||
vxyz.Destroy();
|
||||
}
|
||||
|
||||
// Find and Interpolate FE function values on the desired points.
|
||||
Vector interp_vals(pts_cnt*vec_dim);
|
||||
FindPointsGSLIB finder(MPI_COMM_WORLD);
|
||||
@@ -246,36 +256,37 @@ int main (int argc, char *argv[])
|
||||
Array<unsigned int> task_id_out = finder.GetProc();
|
||||
Vector dist_p_out = finder.GetDist();
|
||||
|
||||
int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
|
||||
double max_err = 0.0, max_dist = 0.0;
|
||||
Vector pos(dim);
|
||||
int npt = 0;
|
||||
for (int j = 0; j < vec_dim; j++)
|
||||
// Print the results for task 0 since either 1) all tasks have the
|
||||
// same set of points or 2) only task 0 has any points.
|
||||
if (myid == 0 )
|
||||
{
|
||||
for (int i = 0; i < pts_cnt; i++)
|
||||
int face_pts = 0, not_found = 0, found_loc = 0, found_away = 0;
|
||||
double max_err = 0.0, max_dist = 0.0;
|
||||
Vector pos(dim);
|
||||
int npt = 0;
|
||||
for (int j = 0; j < vec_dim; j++)
|
||||
{
|
||||
if (j == 0)
|
||||
for (int i = 0; i < pts_cnt; i++)
|
||||
{
|
||||
(task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
|
||||
}
|
||||
if (j == 0)
|
||||
{
|
||||
(task_id_out[i] == (unsigned)myid) ? found_loc++ : found_away++;
|
||||
}
|
||||
|
||||
if (code_out[i] < 2)
|
||||
{
|
||||
for (int d = 0; d < dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
|
||||
Vector exact_val(vec_dim);
|
||||
F_exact(pos, exact_val);
|
||||
max_err = std::max(max_err, fabs(exact_val(j) - interp_vals(npt)));
|
||||
max_dist = std::max(max_dist, dist_p_out(i));
|
||||
if (code_out[i] == 1 && j == 0) { face_pts++; }
|
||||
if (code_out[i] < 2)
|
||||
{
|
||||
for (int d = 0; d < dim; d++) { pos(d) = vxyz(d * pts_cnt + i); }
|
||||
Vector exact_val(vec_dim);
|
||||
F_exact(pos, exact_val);
|
||||
max_err = std::max(max_err, fabs(exact_val(j) - interp_vals(npt)));
|
||||
max_dist = std::max(max_dist, dist_p_out(i));
|
||||
if (code_out[i] == 1 && j == 0) { face_pts++; }
|
||||
}
|
||||
else { if (j == 0) { not_found++; } }
|
||||
npt++;
|
||||
}
|
||||
else { if (j == 0) { not_found++; } }
|
||||
npt++;
|
||||
}
|
||||
}
|
||||
|
||||
// Print the results for task 0 since all tasks have the same set of points.
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << setprecision(16)
|
||||
<< "Searched unique points: " << pts_cnt
|
||||
<< "\nFound on local mesh: " << found_loc
|
||||
|
||||
@@ -327,7 +327,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
bnd(i+d*number_boundary) = vxyz(idx + d*number_true);
|
||||
}
|
||||
n colorv[i] = (unsigned int)color;
|
||||
colorv[i] = (unsigned int)color;
|
||||
}
|
||||
Vector interp_vals1(number_boundary);
|
||||
finder.Interpolate(bnd, colorv, x, interp_vals1);
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
// Adapted analytic shape+orientation:
|
||||
// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 85 -tid 4 -ni 100 -bnd -qt 1 -qo 8 -fd
|
||||
//
|
||||
// Adapted analytic shape and/or size with hr-adaptivity:
|
||||
// mesh-optimizer -m square01.mesh -o 2 -tid 9 -ni 50 -li 20 -hmid 55 -mid 7 -hr
|
||||
// mesh-optimizer -m square01.mesh -o 2 -tid 10 -ni 50 -li 20 -hmid 55 -mid 7 -hr
|
||||
// mesh-optimizer -m square01.mesh -o 2 -tid 11 -ni 50 -li 20 -hmid 58 -mid 7 -hr
|
||||
//
|
||||
// Adapted discrete size:
|
||||
// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 80 -tid 5 -ni 50 -qo 4 -nor
|
||||
// Adapted discrete size 3D with PA:
|
||||
@@ -123,6 +128,8 @@ int main(int argc, char *argv[])
|
||||
int max_lin_iter = 100;
|
||||
bool move_bnd = true;
|
||||
int combomet = 0;
|
||||
bool hradaptivity = false;
|
||||
int h_metric_id = -1;
|
||||
bool normalization = false;
|
||||
bool visualization = true;
|
||||
int verbosity_level = 0;
|
||||
@@ -131,6 +138,8 @@ int main(int argc, char *argv[])
|
||||
bool exactaction = false;
|
||||
const char *devopt = "cpu";
|
||||
bool pa = false;
|
||||
int n_hr_iter = 5;
|
||||
int n_h_iter = 1;
|
||||
|
||||
// 1. Parse command-line options.
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -221,6 +230,12 @@ int main(int argc, char *argv[])
|
||||
"0: Use single metric\n\t"
|
||||
"1: Shape + space-dependent size given analytically\n\t"
|
||||
"2: Shape + adapted size given discretely; shared target");
|
||||
args.AddOption(&hradaptivity, "-hr", "--hr-adaptivity", "-no-hr",
|
||||
"--no-hr-adaptivity",
|
||||
"Enable hr-adaptivity.");
|
||||
args.AddOption(&h_metric_id, "-hmid", "--h-metric",
|
||||
"Same options as metric_id. Used to determine refinement"
|
||||
" type for each element if h-adaptivity is enabled.");
|
||||
args.AddOption(&normalization, "-nor", "--normalization", "-no-nor",
|
||||
"--no-normalization",
|
||||
"Make all terms in the optimization functional unitless.");
|
||||
@@ -241,6 +256,11 @@ int main(int argc, char *argv[])
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
|
||||
"--no-partial-assembly", "Enable Partial Assembly.");
|
||||
args.AddOption(&n_hr_iter, "-nhr", "--n_hr_iter",
|
||||
"Number of hr-adaptivity iterations.");
|
||||
args.AddOption(&n_h_iter, "-nh", "--n_h_iter",
|
||||
"Number of h-adaptivity iterations per r-adaptivity"
|
||||
"iteration.");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -249,6 +269,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
args.PrintOptions(cout);
|
||||
|
||||
if (h_metric_id < 0) { h_metric_id = metric_id; }
|
||||
|
||||
if (hradaptivity)
|
||||
{
|
||||
MFEM_VERIFY(strcmp(devopt,"cpu")==0, "HR-adaptivity is currently only"
|
||||
" supported on cpus.");
|
||||
}
|
||||
Device device(devopt);
|
||||
device.Print();
|
||||
|
||||
@@ -261,7 +288,9 @@ int main(int argc, char *argv[])
|
||||
else { cout << "(NONE)"; }
|
||||
cout << endl;
|
||||
|
||||
// 3. Define a finite element space on the mesh. Here we use vector finite
|
||||
if (hradaptivity) { mesh->EnsureNCMesh(); }
|
||||
|
||||
// 3. Define a finite element space on the mesh-> Here we use vector finite
|
||||
// elements which are tensor products of quadratic finite elements. The
|
||||
// number of components in the vector finite element space is specified by
|
||||
// the last parameter of the FiniteElementSpace constructor.
|
||||
@@ -392,9 +421,41 @@ int main(int argc, char *argv[])
|
||||
cout << "Unknown metric_id: " << metric_id << endl;
|
||||
return 3;
|
||||
}
|
||||
TMOP_QualityMetric *h_metric = NULL;
|
||||
if (hradaptivity)
|
||||
{
|
||||
switch (h_metric_id)
|
||||
{
|
||||
case 1: h_metric = new TMOP_Metric_001; break;
|
||||
case 2: h_metric = new TMOP_Metric_002; break;
|
||||
case 7: h_metric = new TMOP_Metric_007; break;
|
||||
case 9: h_metric = new TMOP_Metric_009; break;
|
||||
case 55: h_metric = new TMOP_Metric_055; break;
|
||||
case 56: h_metric = new TMOP_Metric_056; break;
|
||||
case 58: h_metric = new TMOP_Metric_058; break;
|
||||
case 77: h_metric = new TMOP_Metric_077; break;
|
||||
case 315: h_metric = new TMOP_Metric_315; break;
|
||||
case 316: h_metric = new TMOP_Metric_316; break;
|
||||
case 321: h_metric = new TMOP_Metric_321; break;
|
||||
default: cout << "Metric_id not supported for h-adaptivity: " << h_metric_id <<
|
||||
endl;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (metric_id < 300 || h_metric_id < 300)
|
||||
{
|
||||
MFEM_VERIFY(dim == 2, "Incompatible metric for 3D meshes");
|
||||
}
|
||||
if (metric_id >= 300 || h_metric_id >= 300)
|
||||
{
|
||||
MFEM_VERIFY(dim == 3, "Incompatible metric for 2D meshes");
|
||||
}
|
||||
|
||||
TargetConstructor::TargetType target_t;
|
||||
TargetConstructor *target_c = NULL;
|
||||
HessianCoefficient *adapt_coeff = NULL;
|
||||
HRHessianCoefficient *hr_adapt_coeff = NULL;
|
||||
H1_FECollection ind_fec(mesh_poly_deg, dim);
|
||||
FiniteElementSpace ind_fes(mesh, &ind_fec);
|
||||
FiniteElementSpace ind_fesv(mesh, &ind_fec, dim);
|
||||
@@ -604,6 +665,18 @@ int main(int argc, char *argv[])
|
||||
target_c = tc;
|
||||
break;
|
||||
}
|
||||
// Targets used for hr-adaptivity tests.
|
||||
case 9: // size target in an annular region.
|
||||
case 10: // size+aspect-ratio in an annular region.
|
||||
case 11: // size+aspect-ratio target for a rotate sine wave
|
||||
{
|
||||
target_t = TargetConstructor::GIVEN_FULL;
|
||||
AnalyticAdaptTC *tc = new AnalyticAdaptTC(target_t);
|
||||
hr_adapt_coeff = new HRHessianCoefficient(dim, target_id - 9);
|
||||
tc->SetAnalyticTargetSpec(NULL, NULL, hr_adapt_coeff);
|
||||
target_c = tc;
|
||||
break;
|
||||
}
|
||||
default: cout << "Unknown target_id: " << target_id << endl; return 3;
|
||||
}
|
||||
if (target_c == NULL)
|
||||
@@ -611,7 +684,8 @@ int main(int argc, char *argv[])
|
||||
target_c = new TargetConstructor(target_t);
|
||||
}
|
||||
target_c->SetNodes(x0);
|
||||
TMOP_Integrator *he_nlf_integ = new TMOP_Integrator(metric, target_c);
|
||||
TMOP_Integrator *he_nlf_integ = new TMOP_Integrator(metric, target_c,
|
||||
h_metric);
|
||||
|
||||
// Finite differences for computations of derivatives.
|
||||
if (fdscheme)
|
||||
@@ -721,10 +795,10 @@ int main(int argc, char *argv[])
|
||||
TargetConstructor::IDEAL_SHAPE_EQUAL_SIZE);
|
||||
target_c2->SetVolumeScale(0.01);
|
||||
target_c2->SetNodes(x0);
|
||||
he_nlf_integ2 = new TMOP_Integrator(metric2, target_c2);
|
||||
he_nlf_integ2 = new TMOP_Integrator(metric2, target_c2, h_metric);
|
||||
he_nlf_integ2->SetCoefficient(coeff2);
|
||||
}
|
||||
else { he_nlf_integ2 = new TMOP_Integrator(metric2, target_c); }
|
||||
else { he_nlf_integ2 = new TMOP_Integrator(metric2, target_c, h_metric); }
|
||||
he_nlf_integ2->SetIntegrationRules(*irules, quad_order);
|
||||
if (fdscheme) { he_nlf_integ2->EnableFiniteDifferences(x); }
|
||||
he_nlf_integ2->SetExactActionFlag(exactaction);
|
||||
@@ -778,7 +852,9 @@ int main(int argc, char *argv[])
|
||||
tauval -= 0.01 * h0.Min();
|
||||
}
|
||||
|
||||
const double init_energy = a.GetGridFunctionEnergy(x);
|
||||
// For HR tests, the energy is normalized by the number of elements.
|
||||
const double init_energy = a.GetGridFunctionEnergy(x) /
|
||||
(hradaptivity ? mesh->GetNE() : 1);
|
||||
|
||||
// Visualize the starting mesh and metric values.
|
||||
// Note that for combinations of metrics, this only shows the first metric.
|
||||
@@ -906,13 +982,25 @@ int main(int argc, char *argv[])
|
||||
solver.SetAdaptiveLinRtol(solver_art_type, 0.5, 0.9);
|
||||
}
|
||||
solver.SetPrintLevel(verbosity_level >= 1 ? 1 : -1);
|
||||
solver.SetOperator(a);
|
||||
solver.Mult(b, x.GetTrueVector());
|
||||
x.SetFromTrueVector();
|
||||
if (solver.GetConverged() == false)
|
||||
|
||||
// hr-adaptivity solver.
|
||||
// If hr-adaptivity is disabled, r-adaptivity is done once using the
|
||||
// TMOPNewtonSolver.
|
||||
// Otherwise, "hr_iter" iterations of r-adaptivity are done followed by
|
||||
// "h_per_r_iter" iterations of h-adaptivity after each r-adaptivity.
|
||||
// The solver terminates if an h-adaptivity iteration does not modify
|
||||
// any element in the mesh.
|
||||
TMOPHRSolver hr_solver(*mesh, a, solver,
|
||||
x, move_bnd, hradaptivity,
|
||||
mesh_poly_deg, h_metric_id,
|
||||
n_hr_iter, n_h_iter);
|
||||
hr_solver.AddGridFunctionForUpdate(&x0);
|
||||
if (adapt_lim_const > 0.)
|
||||
{
|
||||
cout << "Nonlinear solver: rtol = " << solver_rtol << " not achieved.\n";
|
||||
hr_solver.AddGridFunctionForUpdate(&zeta_0);
|
||||
hr_solver.AddFESpaceForUpdate(&ind_fes);
|
||||
}
|
||||
hr_solver.Mult();
|
||||
|
||||
// 15. Save the optimized mesh to a file. This output can be viewed later
|
||||
// using GLVis: "glvis -m optimized.mesh".
|
||||
@@ -922,14 +1010,15 @@ int main(int argc, char *argv[])
|
||||
mesh->Print(mesh_ofs);
|
||||
}
|
||||
|
||||
// 16. Compute the amount of energy decrease.
|
||||
const double fin_energy = a.GetGridFunctionEnergy(x);
|
||||
const double fin_energy = a.GetGridFunctionEnergy(x) /
|
||||
(hradaptivity ? mesh->GetNE() : 1);
|
||||
double metric_part = fin_energy;
|
||||
if (lim_const > 0.0 || adapt_lim_const > 0.0)
|
||||
{
|
||||
lim_coeff.constant = 0.0;
|
||||
coef_zeta.constant = 0.0;
|
||||
metric_part = a.GetGridFunctionEnergy(x);
|
||||
metric_part = a.GetGridFunctionEnergy(x) /
|
||||
(hradaptivity ? mesh->GetNE() : 1);
|
||||
lim_coeff.constant = lim_const;
|
||||
coef_zeta.constant = adapt_lim_const;
|
||||
}
|
||||
@@ -942,7 +1031,7 @@ int main(int argc, char *argv[])
|
||||
cout << "The strain energy decreased by: " << setprecision(12)
|
||||
<< (init_energy - fin_energy) * 100.0 / init_energy << " %." << endl;
|
||||
|
||||
// 17. Visualize the final mesh and metric values.
|
||||
// 16. Visualize the final mesh and metric values.
|
||||
if (visualization)
|
||||
{
|
||||
char title[] = "Final metric values";
|
||||
@@ -956,13 +1045,13 @@ int main(int argc, char *argv[])
|
||||
600, 600, 300, 300);
|
||||
}
|
||||
|
||||
// 18. Visualize the mesh displacement.
|
||||
// 17. Visualize the mesh displacement.
|
||||
if (visualization)
|
||||
{
|
||||
x0 -= x;
|
||||
osockstream sock(19916, "localhost");
|
||||
sock << "solution\n";
|
||||
mesh->Print(sock);
|
||||
x0 -= x;
|
||||
x0.Save(sock);
|
||||
sock.send();
|
||||
sock << "window_title 'Displacements'\n"
|
||||
@@ -971,7 +1060,6 @@ int main(int argc, char *argv[])
|
||||
<< "keys jRmclA" << endl;
|
||||
}
|
||||
|
||||
// 19. Free the used memory.
|
||||
delete S;
|
||||
delete S_prec;
|
||||
delete target_c2;
|
||||
@@ -979,7 +1067,9 @@ int main(int argc, char *argv[])
|
||||
delete coeff1;
|
||||
delete adapt_evaluator;
|
||||
delete target_c;
|
||||
delete hr_adapt_coeff;
|
||||
delete adapt_coeff;
|
||||
delete h_metric;
|
||||
delete metric;
|
||||
delete fespace;
|
||||
delete fec;
|
||||
|
||||
@@ -90,8 +90,6 @@ double discrete_aspr_2d(const Vector &x)
|
||||
double th = 22.5*M_PI/180.;
|
||||
double xn = cos(th)*xc + sin(th)*yc;
|
||||
double yn = -sin(th)*xc + cos(th)*yc;
|
||||
// double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
|
||||
// double stretch = 1/cos(th2);
|
||||
xc = xn; yc = yn;
|
||||
|
||||
double tfac = 20;
|
||||
@@ -223,6 +221,134 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class HRHessianCoefficient : public TMOPMatrixCoefficient
|
||||
{
|
||||
private:
|
||||
int dim;
|
||||
// 0 - size target in an annular region,
|
||||
// 1 - size+aspect-ratio in an annular region,
|
||||
// 2 - size+aspect-ratio target for a rotate sine wave.
|
||||
int hr_target_type;
|
||||
|
||||
public:
|
||||
HRHessianCoefficient(int dim_, int hr_target_type_ = 0)
|
||||
: TMOPMatrixCoefficient(dim_), dim(dim_),
|
||||
hr_target_type(hr_target_type_) { }
|
||||
|
||||
virtual void Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
Vector pos(3);
|
||||
T.Transform(ip, pos);
|
||||
if (hr_target_type == 0) // size only circle
|
||||
{
|
||||
double small = 0.001, big = 0.01;
|
||||
if (dim == 3) { small = 0.005, big = 0.1; }
|
||||
const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
|
||||
double zc;
|
||||
if (dim == 3) { zc = pos(2) - 0.5; }
|
||||
double r = sqrt(xc*xc + yc*yc);
|
||||
if (dim == 3) { r = sqrt(xc*xc + yc*yc + zc*zc); }
|
||||
double r1 = 0.15; double r2 = 0.35; double sf=30.0;
|
||||
|
||||
const double tan1 = std::tanh(sf*(r-r1)),
|
||||
tan2 = std::tanh(sf*(r-r2));
|
||||
|
||||
double ind = (tan1 - tan2);
|
||||
if (ind > 1.0) {ind = 1.;}
|
||||
if (ind < 0.0) {ind = 0.;}
|
||||
double val = ind * small + (1.0 - ind) * big;
|
||||
K = 0.0;
|
||||
K(0, 0) = 1.0;
|
||||
K(0, 1) = 0.0;
|
||||
K(1, 0) = 0.0;
|
||||
K(1, 1) = 1.0;
|
||||
K(0, 0) *= pow(val,0.5);
|
||||
K(1, 1) *= pow(val,0.5);
|
||||
if (dim == 3) { K(2, 2) = pow(val,0.5); }
|
||||
}
|
||||
else if (hr_target_type == 1) // circle with size and AR
|
||||
{
|
||||
const double small = 0.001, big = 0.01;
|
||||
const double xc = pos(0)-0.5, yc = pos(1)-0.5;
|
||||
const double rv = xc*xc + yc*yc;
|
||||
double r = 0;
|
||||
if (rv>0.) {r = sqrt(rv);}
|
||||
|
||||
double r1 = 0.2; double r2 = 0.3; double sf=30.0;
|
||||
const double szfac = 1;
|
||||
const double asfac = 4;
|
||||
const double eps2 = szfac/asfac;
|
||||
const double eps1 = szfac;
|
||||
|
||||
double tan1 = std::tanh(sf*(r-r1)+1),
|
||||
tan2 = std::tanh(sf*(r-r2)-1);
|
||||
double wgt = 0.5*(tan1-tan2);
|
||||
|
||||
tan1 = std::tanh(sf*(r-r1)),
|
||||
tan2 = std::tanh(sf*(r-r2));
|
||||
|
||||
double ind = (tan1 - tan2);
|
||||
if (ind > 1.0) {ind = 1.;}
|
||||
if (ind < 0.0) {ind = 0.;}
|
||||
double szval = ind * small + (1.0 - ind) * big;
|
||||
|
||||
double th = std::atan2(yc,xc)*180./M_PI;
|
||||
if (wgt > 1) { wgt = 1; }
|
||||
if (wgt < 0) { wgt = 0; }
|
||||
|
||||
double maxval = eps2 + eps1*(1-wgt)*(1-wgt);
|
||||
double minval = eps1;
|
||||
double avgval = 0.5*(maxval+minval);
|
||||
double ampval = 0.5*(maxval-minval);
|
||||
double val1 = avgval + ampval*sin(2.*th*M_PI/180.+90*M_PI/180.);
|
||||
double val2 = avgval + ampval*sin(2.*th*M_PI/180.-90*M_PI/180.);
|
||||
|
||||
K(0,1) = 0.0;
|
||||
K(1,0) = 0.0;
|
||||
K(0,0) = val1;
|
||||
K(1,1) = val2;
|
||||
|
||||
K(0,0) *= pow(szval,0.5);
|
||||
K(1,1) *= pow(szval,0.5);
|
||||
}
|
||||
else if (hr_target_type == 2) // sharp rotated sine wave
|
||||
{
|
||||
double xc = pos(0)-0.5, yc = pos(1)-0.5;
|
||||
double th = 15.5*M_PI/180.;
|
||||
double xn = cos(th)*xc + sin(th)*yc;
|
||||
double yn = -sin(th)*xc + cos(th)*yc;
|
||||
double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
|
||||
double stretch = 1/cos(th2);
|
||||
xc = xn/stretch;
|
||||
yc = yn;
|
||||
double tfac = 20;
|
||||
double s1 = 3;
|
||||
double s2 = 2;
|
||||
double yl1 = -0.025;
|
||||
double yl2 = 0.025;
|
||||
double wgt = std::tanh((tfac*(yc-yl1) + s2*std::sin(s1*M_PI*xc)) + 1) -
|
||||
std::tanh((tfac*(yc-yl2) + s2*std::sin(s1*M_PI*xc)) - 1);
|
||||
if (wgt > 1) { wgt = 1; }
|
||||
if (wgt < 0) { wgt = 0; }
|
||||
|
||||
const double eps2 = 25;
|
||||
const double eps1 = 1;
|
||||
K(1,1) = eps1/eps2 + eps1*(1-wgt)*(1-wgt);
|
||||
K(0,0) = eps1;
|
||||
K(0,1) = 0.0;
|
||||
K(1,0) = 0.0;
|
||||
}
|
||||
else { MFEM_ABORT("Unsupported option / wrong input."); }
|
||||
}
|
||||
|
||||
virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip, int comp)
|
||||
{
|
||||
K = 0.;
|
||||
}
|
||||
};
|
||||
|
||||
// Additional IntegrationRules that can be used with the --quad-type option.
|
||||
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto);
|
||||
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform);
|
||||
@@ -252,13 +378,13 @@ double adapt_lim_fun(const Vector &x)
|
||||
|
||||
void DiffuseField(GridFunction &field, int smooth_steps)
|
||||
{
|
||||
//Setup the Laplacian operator
|
||||
// Setup the Laplacian operator
|
||||
BilinearForm *Lap = new BilinearForm(field.FESpace());
|
||||
Lap->AddDomainIntegrator(new DiffusionIntegrator());
|
||||
Lap->Assemble();
|
||||
Lap->Finalize();
|
||||
|
||||
//Setup the smoothing operator
|
||||
// Setup the smoothing operator
|
||||
DSmoother *S = new DSmoother(0,1.0,smooth_steps);
|
||||
S->iterative_mode = true;
|
||||
S->SetOperator(Lap->SpMat());
|
||||
@@ -274,7 +400,7 @@ void DiffuseField(GridFunction &field, int smooth_steps)
|
||||
#ifdef MFEM_USE_MPI
|
||||
void DiffuseField(ParGridFunction &field, int smooth_steps)
|
||||
{
|
||||
//Setup the Laplacian operator
|
||||
// Setup the Laplacian operator
|
||||
ParBilinearForm *Lap = new ParBilinearForm(field.ParFESpace());
|
||||
Lap->AddDomainIntegrator(new DiffusionIntegrator());
|
||||
Lap->Assemble();
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
// Adapted analytic shape+orientation:
|
||||
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 85 -tid 4 -ni 100 -bnd -qt 1 -qo 8 -fd
|
||||
//
|
||||
// Adapted analytic shape and/or size with hr-adaptivity:
|
||||
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -tid 9 -ni 50 -li 20 -hmid 55 -mid 7 -hr
|
||||
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -tid 10 -ni 50 -li 20 -hmid 55 -mid 7 -hr
|
||||
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -tid 11 -ni 50 -li 20 -hmid 58 -mid 7 -hr
|
||||
//
|
||||
// Adapted discrete size:
|
||||
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 80 -tid 5 -ni 50 -qo 4 -nor
|
||||
// Adapted discrete size 3D with PA:
|
||||
@@ -130,6 +135,8 @@ int main (int argc, char *argv[])
|
||||
int max_lin_iter = 100;
|
||||
bool move_bnd = true;
|
||||
int combomet = 0;
|
||||
bool hradaptivity = false;
|
||||
int h_metric_id = -1;
|
||||
bool normalization = false;
|
||||
bool visualization = true;
|
||||
int verbosity_level = 0;
|
||||
@@ -138,6 +145,8 @@ int main (int argc, char *argv[])
|
||||
bool exactaction = false;
|
||||
const char *devopt = "cpu";
|
||||
bool pa = false;
|
||||
int n_hr_iter = 5;
|
||||
int n_h_iter = 1;
|
||||
|
||||
// 2. Parse command-line options.
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -230,6 +239,12 @@ int main (int argc, char *argv[])
|
||||
"0: Use single metric\n\t"
|
||||
"1: Shape + space-dependent size given analytically\n\t"
|
||||
"2: Shape + adapted size given discretely; shared target");
|
||||
args.AddOption(&hradaptivity, "-hr", "--hr-adaptivity", "-no-hr",
|
||||
"--no-hr-adaptivity",
|
||||
"Enable hr-adaptivity.");
|
||||
args.AddOption(&h_metric_id, "-hmid", "--h-metric",
|
||||
"Same options as metric_id. Used to determine refinement"
|
||||
" type for each element if h-adaptivity is enabled.");
|
||||
args.AddOption(&normalization, "-nor", "--normalization", "-no-nor",
|
||||
"--no-normalization",
|
||||
"Make all terms in the optimization functional unitless.");
|
||||
@@ -250,6 +265,11 @@ int main (int argc, char *argv[])
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
|
||||
"--no-partial-assembly", "Enable Partial Assembly.");
|
||||
args.AddOption(&n_hr_iter, "-nhr", "--n_hr_iter",
|
||||
"Number of hr-adaptivity iterations.");
|
||||
args.AddOption(&n_h_iter, "-nh", "--n_h_iter",
|
||||
"Number of h-adaptivity iterations per r-adaptivity"
|
||||
"iteration.");
|
||||
args.Parse();
|
||||
if (!args.Good())
|
||||
{
|
||||
@@ -257,7 +277,13 @@ int main (int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
if (myid == 0) { args.PrintOptions(cout); }
|
||||
if (h_metric_id < 0) { h_metric_id = metric_id; }
|
||||
|
||||
if (hradaptivity)
|
||||
{
|
||||
MFEM_VERIFY(strcmp(devopt,"cpu")==0, "HR-adaptivity is currently only"
|
||||
" supported on cpus.");
|
||||
}
|
||||
Device device(devopt);
|
||||
if (myid == 0) { device.Print();}
|
||||
|
||||
@@ -276,6 +302,7 @@ int main (int argc, char *argv[])
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
if (hradaptivity) { mesh->EnsureNCMesh(); }
|
||||
ParMesh *pmesh = new ParMesh(MPI_COMM_WORLD, *mesh);
|
||||
|
||||
delete mesh;
|
||||
@@ -422,9 +449,41 @@ int main (int argc, char *argv[])
|
||||
if (myid == 0) { cout << "Unknown metric_id: " << metric_id << endl; }
|
||||
return 3;
|
||||
}
|
||||
TMOP_QualityMetric *h_metric = NULL;
|
||||
if (hradaptivity)
|
||||
{
|
||||
switch (h_metric_id)
|
||||
{
|
||||
case 1: h_metric = new TMOP_Metric_001; break;
|
||||
case 2: h_metric = new TMOP_Metric_002; break;
|
||||
case 7: h_metric = new TMOP_Metric_007; break;
|
||||
case 9: h_metric = new TMOP_Metric_009; break;
|
||||
case 55: h_metric = new TMOP_Metric_055; break;
|
||||
case 56: h_metric = new TMOP_Metric_056; break;
|
||||
case 58: h_metric = new TMOP_Metric_058; break;
|
||||
case 77: h_metric = new TMOP_Metric_077; break;
|
||||
case 315: h_metric = new TMOP_Metric_315; break;
|
||||
case 316: h_metric = new TMOP_Metric_316; break;
|
||||
case 321: h_metric = new TMOP_Metric_321; break;
|
||||
default: cout << "Metric_id not supported for h-adaptivity: " << h_metric_id <<
|
||||
endl;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (metric_id < 300 || h_metric_id < 300)
|
||||
{
|
||||
MFEM_VERIFY(dim == 2, "Incompatible metric for 3D meshes");
|
||||
}
|
||||
if (metric_id >= 300 || h_metric_id >= 300)
|
||||
{
|
||||
MFEM_VERIFY(dim == 3, "Incompatible metric for 2D meshes");
|
||||
}
|
||||
|
||||
TargetConstructor::TargetType target_t;
|
||||
TargetConstructor *target_c = NULL;
|
||||
HessianCoefficient *adapt_coeff = NULL;
|
||||
HRHessianCoefficient *hr_adapt_coeff = NULL;
|
||||
H1_FECollection ind_fec(mesh_poly_deg, dim);
|
||||
ParFiniteElementSpace ind_fes(pmesh, &ind_fec);
|
||||
ParFiniteElementSpace ind_fesv(pmesh, &ind_fec, dim);
|
||||
@@ -639,6 +698,18 @@ int main (int argc, char *argv[])
|
||||
target_c = tc;
|
||||
break;
|
||||
}
|
||||
// Targets used for hr-adaptivity tests.
|
||||
case 9: // size target in an annular region.
|
||||
case 10: // size+aspect-ratio in an annular region.
|
||||
case 11: // size+aspect-ratio target for a rotate sine wave
|
||||
{
|
||||
target_t = TargetConstructor::GIVEN_FULL;
|
||||
AnalyticAdaptTC *tc = new AnalyticAdaptTC(target_t);
|
||||
hr_adapt_coeff = new HRHessianCoefficient(dim, target_id - 9);
|
||||
tc->SetAnalyticTargetSpec(NULL, NULL, hr_adapt_coeff);
|
||||
target_c = tc;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (myid == 0) { cout << "Unknown target_id: " << target_id << endl; }
|
||||
return 3;
|
||||
@@ -649,13 +720,13 @@ int main (int argc, char *argv[])
|
||||
target_c = new TargetConstructor(target_t, MPI_COMM_WORLD);
|
||||
}
|
||||
target_c->SetNodes(x0);
|
||||
TMOP_Integrator *he_nlf_integ= new TMOP_Integrator(metric, target_c);
|
||||
TMOP_Integrator *he_nlf_integ = new TMOP_Integrator(metric, target_c,
|
||||
h_metric);
|
||||
|
||||
// Finite differences for computations of derivatives.
|
||||
if (fdscheme)
|
||||
{
|
||||
MFEM_VERIFY(pa == false, "PA for finite differences is not implemented.");
|
||||
|
||||
he_nlf_integ->EnableFiniteDifferences(x);
|
||||
}
|
||||
he_nlf_integ->SetExactActionFlag(exactaction);
|
||||
@@ -753,7 +824,8 @@ int main (int argc, char *argv[])
|
||||
he_nlf_integ->SetCoefficient(*coeff1);
|
||||
|
||||
// Second metric.
|
||||
metric2 = new TMOP_Metric_077;
|
||||
if (dim == 2) { metric2 = new TMOP_Metric_077; }
|
||||
else { metric2 = new TMOP_Metric_315; }
|
||||
TMOP_Integrator *he_nlf_integ2 = NULL;
|
||||
if (combomet == 1)
|
||||
{
|
||||
@@ -761,10 +833,10 @@ int main (int argc, char *argv[])
|
||||
TargetConstructor::IDEAL_SHAPE_EQUAL_SIZE, MPI_COMM_WORLD);
|
||||
target_c2->SetVolumeScale(0.01);
|
||||
target_c2->SetNodes(x0);
|
||||
he_nlf_integ2 = new TMOP_Integrator(metric2, target_c2);
|
||||
he_nlf_integ2 = new TMOP_Integrator(metric2, target_c2, h_metric);
|
||||
he_nlf_integ2->SetCoefficient(coeff2);
|
||||
}
|
||||
else { he_nlf_integ2 = new TMOP_Integrator(metric2, target_c); }
|
||||
else { he_nlf_integ2 = new TMOP_Integrator(metric2, target_c, h_metric); }
|
||||
he_nlf_integ2->SetIntegrationRules(*irules, quad_order);
|
||||
if (fdscheme) { he_nlf_integ2->EnableFiniteDifferences(x); }
|
||||
he_nlf_integ2->SetExactActionFlag(exactaction);
|
||||
@@ -777,7 +849,10 @@ int main (int argc, char *argv[])
|
||||
|
||||
a.AddDomainIntegrator(combo);
|
||||
}
|
||||
else { a.AddDomainIntegrator(he_nlf_integ); }
|
||||
else
|
||||
{
|
||||
a.AddDomainIntegrator(he_nlf_integ);
|
||||
}
|
||||
|
||||
if (pa) { a.Setup(); }
|
||||
|
||||
@@ -821,7 +896,9 @@ int main (int argc, char *argv[])
|
||||
tauval -= 0.01 * h0min_all;
|
||||
}
|
||||
|
||||
const double init_energy = a.GetParGridFunctionEnergy(x);
|
||||
// For HR tests, the energy is normalized by the number of elements.
|
||||
const double init_energy = a.GetParGridFunctionEnergy(x) /
|
||||
(hradaptivity ? pmesh->GetGlobalNE() : 1);
|
||||
|
||||
// Visualize the starting mesh and metric values.
|
||||
// Note that for combinations of metrics, this only shows the first metric.
|
||||
@@ -952,13 +1029,25 @@ int main (int argc, char *argv[])
|
||||
solver.SetAdaptiveLinRtol(solver_art_type, 0.5, 0.9);
|
||||
}
|
||||
solver.SetPrintLevel(verbosity_level >= 1 ? 1 : -1);
|
||||
solver.SetOperator(a);
|
||||
solver.Mult(b, x.GetTrueVector());
|
||||
x.SetFromTrueVector();
|
||||
if (myid == 0 && solver.GetConverged() == false)
|
||||
|
||||
// hr-adaptivity solver.
|
||||
// If hr-adaptivity is disabled, r-adaptivity is done once using the
|
||||
// TMOPNewtonSolver.
|
||||
// Otherwise, "hr_iter" iterations of r-adaptivity are done followed by
|
||||
// "h_per_r_iter" iterations of h-adaptivity after each r-adaptivity.
|
||||
// The solver terminates if an h-adaptivity iteration does not modify
|
||||
// any element in the mesh.
|
||||
TMOPHRSolver hr_solver(*pmesh, a, solver,
|
||||
x, move_bnd, hradaptivity,
|
||||
mesh_poly_deg, h_metric_id,
|
||||
n_hr_iter, n_h_iter);
|
||||
hr_solver.AddGridFunctionForUpdate(&x0);
|
||||
if (adapt_lim_const > 0.)
|
||||
{
|
||||
cout << "Nonlinear solver: rtol = " << solver_rtol << " not achieved.\n";
|
||||
hr_solver.AddGridFunctionForUpdate(&zeta_0);
|
||||
hr_solver.AddFESpaceForUpdate(&ind_fes);
|
||||
}
|
||||
hr_solver.Mult();
|
||||
|
||||
// 16. Save the optimized mesh to a file. This output can be viewed later
|
||||
// using GLVis: "glvis -m optimized -np num_mpi_tasks".
|
||||
@@ -971,13 +1060,15 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
// 17. Compute the amount of energy decrease.
|
||||
const double fin_energy = a.GetParGridFunctionEnergy(x);
|
||||
const double fin_energy = a.GetParGridFunctionEnergy(x) /
|
||||
(hradaptivity ? pmesh->GetGlobalNE() : 1);
|
||||
double metric_part = fin_energy;
|
||||
if (lim_const > 0.0 || adapt_lim_const > 0.0)
|
||||
{
|
||||
lim_coeff.constant = 0.0;
|
||||
coef_zeta.constant = 0.0;
|
||||
metric_part = a.GetParGridFunctionEnergy(x);
|
||||
metric_part = a.GetParGridFunctionEnergy(x) /
|
||||
(hradaptivity ? pmesh->GetGlobalNE() : 1);
|
||||
lim_coeff.constant = lim_const;
|
||||
coef_zeta.constant = adapt_lim_const;
|
||||
}
|
||||
@@ -1036,7 +1127,9 @@ int main (int argc, char *argv[])
|
||||
delete coeff1;
|
||||
delete adapt_evaluator;
|
||||
delete target_c;
|
||||
delete hr_adapt_coeff;
|
||||
delete adapt_coeff;
|
||||
delete h_metric;
|
||||
delete metric;
|
||||
delete pfespace;
|
||||
delete fec;
|
||||
|
||||
@@ -557,4 +557,3 @@ int main(int argc, char *argv[])
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ double ParametricBNLForm::GetEnergyBlocked(const BlockVector &bx,
|
||||
|
||||
void ParametricBNLForm::SetStateFields(const Vector &xv) const
|
||||
{
|
||||
BlockVector bx(xv.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(xv), block_trueOffsets);
|
||||
if (needs_prolongation)
|
||||
{
|
||||
for (int s = 0; s < fes.Size(); s++)
|
||||
@@ -355,7 +355,7 @@ void ParametricBNLForm::SetStateFields(const Vector &xv) const
|
||||
|
||||
void ParametricBNLForm::SetAdjointFields(const Vector &av) const
|
||||
{
|
||||
BlockVector bx(av.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(av), block_trueOffsets);
|
||||
if (needs_prolongation)
|
||||
{
|
||||
for (int s = 0; s < fes.Size(); s++)
|
||||
@@ -372,7 +372,7 @@ void ParametricBNLForm::SetAdjointFields(const Vector &av) const
|
||||
|
||||
void ParametricBNLForm::SetParamFields(const Vector &dv) const
|
||||
{
|
||||
BlockVector bx(dv.GetData(), paramblock_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(dv), paramblock_trueOffsets);
|
||||
if (prmneeds_prolongation)
|
||||
{
|
||||
for (int s = 0; s < paramfes.Size(); s++)
|
||||
@@ -388,7 +388,7 @@ void ParametricBNLForm::SetParamFields(const Vector &dv) const
|
||||
|
||||
double ParametricBNLForm::GetEnergy(const Vector &x) const
|
||||
{
|
||||
xs.Update(x.GetData(),block_offsets);
|
||||
xs.Update(const_cast<Vector&>(x),block_offsets);
|
||||
return GetEnergyBlocked(xs,xdv);
|
||||
}
|
||||
|
||||
@@ -898,8 +898,8 @@ const
|
||||
|
||||
void ParametricBNLForm::ParamMult(const Vector &x, Vector &y) const
|
||||
{
|
||||
BlockVector bx(x.GetData(), paramblock_trueOffsets);
|
||||
BlockVector by(y.GetData(), paramblock_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(x), paramblock_trueOffsets);
|
||||
BlockVector by(y, paramblock_trueOffsets);
|
||||
|
||||
const BlockVector &pbx = ParamProlongate(bx);
|
||||
|
||||
@@ -909,8 +909,8 @@ void ParametricBNLForm::ParamMult(const Vector &x, Vector &y) const
|
||||
}
|
||||
BlockVector &pby = prmneeds_prolongation ? prmaux2 : by;
|
||||
|
||||
xs.Update(pbx.GetData(), paramblock_offsets);
|
||||
ys.Update(pby.GetData(), paramblock_offsets);
|
||||
xs.Update(const_cast<BlockVector&>(pbx), paramblock_offsets);
|
||||
ys.Update(pby, paramblock_offsets);
|
||||
|
||||
MultParamBlocked(xsv,adv,xs,ys);
|
||||
|
||||
@@ -928,8 +928,8 @@ void ParametricBNLForm::ParamMult(const Vector &x, Vector &y) const
|
||||
void ParametricBNLForm::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
|
||||
BlockVector bx(x.GetData(), block_trueOffsets);
|
||||
BlockVector by(y.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(x), block_trueOffsets);
|
||||
BlockVector by(y, block_trueOffsets);
|
||||
|
||||
const BlockVector &pbx = Prolongate(bx);
|
||||
|
||||
@@ -939,8 +939,8 @@ void ParametricBNLForm::Mult(const Vector &x, Vector &y) const
|
||||
}
|
||||
BlockVector &pby = needs_prolongation ? aux2 : by;
|
||||
|
||||
xs.Update(pbx.GetData(), block_offsets);
|
||||
ys.Update(pby.GetData(), block_offsets);
|
||||
xs.Update(const_cast<BlockVector&>(pbx), block_offsets);
|
||||
ys.Update(pby, block_offsets);
|
||||
MultBlocked(xs,xdv,ys);
|
||||
|
||||
for (int s = 0; s < fes.Size(); s++)
|
||||
@@ -1198,7 +1198,7 @@ void ParametricBNLForm::ComputeGradientBlocked(const BlockVector &bx,
|
||||
|
||||
BlockOperator& ParametricBNLForm::GetGradient(const Vector &x) const
|
||||
{
|
||||
BlockVector bx(x.GetData(), block_trueOffsets);
|
||||
BlockVector bx(const_cast<Vector&>(x), block_trueOffsets);
|
||||
const BlockVector &pbx = Prolongate(bx);
|
||||
|
||||
ComputeGradientBlocked(pbx, xdv);
|
||||
|
||||
@@ -203,11 +203,11 @@ int main(int argc, char *argv[])
|
||||
nf->SetParamFields(prmbv); //set the density
|
||||
|
||||
// Compute the stiffness/tangent matrix for density prmbv=0.5.
|
||||
mfem::BlockOperator& A=nf->GetGradient(solbv);
|
||||
mfem::BlockOperator *A = &nf->GetGradient(solbv);
|
||||
mfem::HypreBoomerAMG* prec=new mfem::HypreBoomerAMG();
|
||||
prec->SetPrintLevel(print_level);
|
||||
// Use only block (0,0) as in this case we have a single field.
|
||||
prec->SetOperator(A.GetBlock(0,0));
|
||||
prec->SetOperator(A->GetBlock(0,0));
|
||||
|
||||
// Construct block preconditioner for the BNLForm.
|
||||
mfem::BlockDiagonalPreconditioner *blpr = new mfem::BlockDiagonalPreconditioner(
|
||||
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
gmres->SetMaxIter(100);
|
||||
gmres->SetPrintLevel(print_level);
|
||||
gmres->SetPreconditioner(*blpr);
|
||||
gmres->SetOperator(A);
|
||||
gmres->SetOperator(*A);
|
||||
|
||||
|
||||
// Solve the problem.
|
||||
@@ -319,10 +319,10 @@ int main(int argc, char *argv[])
|
||||
// Solve the physics.
|
||||
solbv=0.0;
|
||||
nf->Mult(solbv,resbv); resbv.Neg(); //compute RHS
|
||||
A=nf->GetGradient(solbv);
|
||||
A = &nf->GetGradient(solbv);
|
||||
prec->SetPrintLevel(0);
|
||||
prec->SetOperator(A.GetBlock(0,0));
|
||||
gmres->SetOperator(A);
|
||||
prec->SetOperator(A->GetBlock(0,0));
|
||||
gmres->SetOperator(*A);
|
||||
gmres->SetPrintLevel(0);
|
||||
gmres->Mult(resbv,solbv);
|
||||
// Compute the objective.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user