--- /srv/reproducible-results/rbuild-debian/r-b-build.dwA4fozE/b1/dune-grid-glue_2.9.0-3_armhf.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.dwA4fozE/b2/dune-grid-glue_2.9.0-3_armhf.changes ├── Files │ @@ -1,4 +1,4 @@ │ │ 36155d08d84a69666f94c1975d2f31a1 886240 debug optional libdune-grid-glue-dev-dbgsym_2.9.0-3_armhf.deb │ df2521e3591b8c827a44f6d1e81012d3 99252 libdevel optional libdune-grid-glue-dev_2.9.0-3_armhf.deb │ - 2aa9d227de318bd1ea2ed0b5b368b2ff 782340 doc optional libdune-grid-glue-doc_2.9.0-3_all.deb │ + 3ddb45c61829849e6415e74c2ce85499 781796 doc optional libdune-grid-glue-doc_2.9.0-3_all.deb ├── libdune-grid-glue-doc_2.9.0-3_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2023-01-13 13:23:40.000000 debian-binary │ │ --rw-r--r-- 0 0 0 7224 2023-01-13 13:23:40.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 774924 2023-01-13 13:23:40.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 7212 2023-01-13 13:23:40.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 774392 2023-01-13 13:23:40.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ │ │ │ ├── line order │ │ │ │ │ @@ -2,26 +2,26 @@ │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/changelog.gz │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/copyright │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00002.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00002_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ │ +usr/share/doc/libdune-grid-glue-doc/doxygen/a00008_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00011.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00011_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00014.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00014_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00020.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00020_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ │ -usr/share/doc/libdune-grid-glue-doc/doxygen/a00026_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ │ @@ -41,28 +41,28 @@ │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00059.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00059_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00062.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00062_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00065.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00065_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ │ +usr/share/doc/libdune-grid-glue-doc/doxygen/a00068_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ │ -usr/share/doc/libdune-grid-glue-doc/doxygen/a00074_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00077_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00083.html │ │ │ │ │ +usr/share/doc/libdune-grid-glue-doc/doxygen/a00083_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00089.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ │ -usr/share/doc/libdune-grid-glue-doc/doxygen/a00095_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00101.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00103.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00104.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00105.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00106.html │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -5,72 +5,72 @@ │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 768 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/changelog.Debian.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1157 2022-12-23 06:52:03.000000 ./usr/share/doc/libdune-grid-glue-doc/changelog.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2569 2023-01-12 15:07:38.000000 ./usr/share/doc/libdune-grid-glue-doc/copyright │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6934 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 80989 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5124 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16170 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5293 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10399 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 68932 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5982 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13843 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4890 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 16166 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5600 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 51914 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10399 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 68932 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5124 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16170 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7874 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 117804 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5982 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13843 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5256 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 26879 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10978 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40196 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5188 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8044 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6298 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8760 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7846 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29152 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5256 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 26879 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5293 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5188 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8044 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7846 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29152 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7157 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 44297 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7719 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 73289 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5782 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 27205 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7157 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 44297 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7719 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 73289 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7444 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10647 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7444 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10647 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6298 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8760 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10978 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40196 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 8009 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00053.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 94248 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00053_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5232 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 43609 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5191 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 47646 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5365 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 70686 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6394 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 35781 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9744 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6144 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45120 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5882 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 58890 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5725 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18783 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4035 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4284 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5159 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22438 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5725 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18783 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5770 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 36815 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5159 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22438 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4035 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6394 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 35781 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11104 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5882 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 58890 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6144 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45120 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5168 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11104 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11998 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 148477 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5770 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 36815 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4284 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9744 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11998 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 148477 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5689 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00101.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4421 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00103.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 66344 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00104.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5563 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00105.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 14779 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00106.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13251 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00107.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6137 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00108.html │ │ │ │ @@ -222,15 +222,15 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2352 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_65f347cff0208f20f00d27c542208238_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6730 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_68eff8a27dcb1cd0ff0ecf490070d3de.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13683 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_68eff8a27dcb1cd0ff0ecf490070d3de_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6242 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_eaad0bdad6fc03850e65b1fdad9faad4.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7180 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_eaad0bdad6fc03850e65b1fdad9faad4_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 746 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/doc.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 33676 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/doxygen.css │ │ │ │ --rw-r--r-- 0 root (0) root (0) 28669 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dune-grid-glue.tag.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 28666 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dune-grid-glue.tag.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4452 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dynsections.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 15406 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/files.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 616 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/folderclosed.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 597 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/folderopen.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3051 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3616 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_b.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13286 2023-01-13 13:23:40.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_c.html │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002.html │ │ │ │ @@ -80,27 +80,27 @@ │ │ │ │ #include <type_traits>
│ │ │ │ #include <dune/common/deprecated.hh>
│ │ │ │ #include <dune/common/exceptions.hh>
│ │ │ │ #include <dune/common/iteratorfacades.hh>
│ │ │ │ #include <dune/common/promotiontraits.hh>
│ │ │ │ #include <dune/common/shared_ptr.hh>
│ │ │ │ #include <dune/common/stdstreams.hh>
│ │ │ │ -#include "adapter/gridgluecommunicate.hh"
│ │ │ │ -#include <dune/grid-glue/merging/merger.hh>
│ │ │ │ +#include "adapter/gridgluecommunicate.hh"
│ │ │ │ +#include <dune/grid-glue/merging/merger.hh>
│ │ │ │ #include <dune/common/parallel/mpitraits.hh>
│ │ │ │ #include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ #include <dune/common/parallel/indexset.hh>
│ │ │ │ #include <dune/common/parallel/plocalindex.hh>
│ │ │ │ #include <dune/common/parallel/remoteindices.hh>
│ │ │ │ #include <dune/common/parallel/communicator.hh>
│ │ │ │ #include <dune/common/parallel/interface.hh>
│ │ │ │ -#include "adapter/rangegenerators.hh"
│ │ │ │ -#include "adapter/gridglue.cc"
│ │ │ │ +#include "adapter/rangegenerators.hh"
│ │ │ │ +#include "adapter/gridglue.cc"
│ │ │ │ #include "adapter/intersection.hh"
│ │ │ │ -#include "adapter/intersectioniterator.hh"
│ │ │ │ +#include "adapter/intersectioniterator.hh"
│ │ │ │ #include "adapter/intersectionindexset.hh"
│ │ │ │ │ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002_source.html │ │ │ │ @@ -83,16 +83,16 @@ │ │ │ │
19#include <dune/common/deprecated.hh>
│ │ │ │
20#include <dune/common/exceptions.hh>
│ │ │ │
21#include <dune/common/iteratorfacades.hh>
│ │ │ │
22#include <dune/common/promotiontraits.hh>
│ │ │ │
23#include <dune/common/shared_ptr.hh>
│ │ │ │
24#include <dune/common/stdstreams.hh>
│ │ │ │
25
│ │ │ │ -
26#include "adapter/gridgluecommunicate.hh"
│ │ │ │ -
27#include <dune/grid-glue/merging/merger.hh>
│ │ │ │ +
26#include "adapter/gridgluecommunicate.hh"
│ │ │ │ +
27#include <dune/grid-glue/merging/merger.hh>
│ │ │ │
28
│ │ │ │
29#include <dune/common/parallel/mpitraits.hh>
│ │ │ │
30#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │
31#include <dune/common/parallel/indexset.hh>
│ │ │ │
32#include <dune/common/parallel/plocalindex.hh>
│ │ │ │
33#include <dune/common/parallel/remoteindices.hh>
│ │ │ │
34#include <dune/common/parallel/communicator.hh>
│ │ │ │ @@ -355,30 +355,30 @@ │ │ │ │
396 }
│ │ │ │
397
│ │ │ │
398};
│ │ │ │
399
│ │ │ │
400} // end namespace GridGlue
│ │ │ │
401} // end namespace Dune
│ │ │ │
402
│ │ │ │ -
403#include "adapter/rangegenerators.hh"
│ │ │ │ +
403#include "adapter/rangegenerators.hh"
│ │ │ │
404
│ │ │ │ -
405#include "adapter/gridglue.cc"
│ │ │ │ +
405#include "adapter/gridglue.cc"
│ │ │ │
406
│ │ │ │
407#include "adapter/intersection.hh"
│ │ │ │ -
408#include "adapter/intersectioniterator.hh"
│ │ │ │ +
408#include "adapter/intersectioniterator.hh"
│ │ │ │
409#include "adapter/intersectionindexset.hh"
│ │ │ │
410
│ │ │ │
411#endif // DUNE_GRIDGLUE_GRIDGLUE_HH
│ │ │ │ -
intersectioniterator.hh
Implement iterators over GridGlue intersections.
│ │ │ │ -
gridglue.cc
│ │ │ │ +
gridgluecommunicate.hh
Describes the parallel communication interface class for Dune::GridGlue.
│ │ │ │ +
rangegenerators.hh
│ │ │ │
intersectionindexset.hh
│ │ │ │ -
gridgluecommunicate.hh
Describes the parallel communication interface class for Dune::GridGlue.
│ │ │ │ +
intersectioniterator.hh
Implement iterators over GridGlue intersections.
│ │ │ │
intersection.hh
Model of the Intersection concept provided by GridGlue.
│ │ │ │ -
rangegenerators.hh
│ │ │ │ -
merger.hh
│ │ │ │ +
gridglue.cc
│ │ │ │ +
merger.hh
│ │ │ │
Dune
Definition: gridglue.hh:37
│ │ │ │
Dune::GridGlue::GridGlue
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:67
│ │ │ │
Dune::GridGlue::GridGlue::Coords
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition: gridglue.hh:174
│ │ │ │
Dune::GridGlue::GridGlue::getIntersection
Intersection getIntersection(int i) const
Definition: gridglue.hh:388
│ │ │ │
Dune::GridGlue::GridGlue::Grid1Vertex
GridVertex< 1 > Grid1Vertex
The type of the Grid1 vertices.
Definition: gridglue.hh:194
│ │ │ │
Dune::GridGlue::GridGlue::IndexSet
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition: gridglue.hh:206
│ │ │ │
Dune::GridGlue::GridGlue::IndexType
unsigned int IndexType
Definition: gridglue.hh:147
│ │ │ │ ├── html2text {} │ │ │ │ │ @@ -326,23 +326,23 @@ │ │ │ │ │ 405#include "adapter/gridglue.cc" │ │ │ │ │ 406 │ │ │ │ │ 407#include "adapter/intersection.hh" │ │ │ │ │ 408#include "adapter/intersectioniterator.hh" │ │ │ │ │ 409#include "adapter/intersectionindexset.hh" │ │ │ │ │ 410 │ │ │ │ │ 411#endif // DUNE_GRIDGLUE_GRIDGLUE_HH │ │ │ │ │ -intersectioniterator.hh │ │ │ │ │ -Implement iterators over GridGlue intersections. │ │ │ │ │ -gridglue.cc │ │ │ │ │ -intersectionindexset.hh │ │ │ │ │ gridgluecommunicate.hh │ │ │ │ │ Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ +rangegenerators.hh │ │ │ │ │ +intersectionindexset.hh │ │ │ │ │ +intersectioniterator.hh │ │ │ │ │ +Implement iterators over GridGlue intersections. │ │ │ │ │ intersection.hh │ │ │ │ │ Model of the Intersection concept provided by GridGlue. │ │ │ │ │ -rangegenerators.hh │ │ │ │ │ +gridglue.cc │ │ │ │ │ merger.hh │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ Dune::GridGlue::GridGlue │ │ │ │ │ sequential adapter to couple two grids at specified close together boundaries │ │ │ │ │ Definition: gridglue.hh:67 │ │ │ │ │ Dune::GridGlue::GridGlue::Coords │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectioniterator.hh File Reference │ │ │ │ +dune-grid-glue: gridgluecommunicate.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,39 +64,73 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
intersectioniterator.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions
│ │ │ │ +
gridgluecommunicate.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Implement iterators over GridGlue intersections. │ │ │ │ +

Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ More...

│ │ │ │ -
#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +
#include <type_traits>
│ │ │ │ +#include <dune/common/bartonnackmanifcheck.hh>
│ │ │ │ +#include <dune/common/parallel/communicator.hh>
│ │ │ │ +#include <dune/grid/common/datahandleif.hh>
│ │ │ │ +#include <dune/grid/common/gridenums.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::GridGlue< P0, P1 >
│ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside >
struct  Dune::GridGlue::GlobalId
 
class  Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp >
 describes the features of a data handle for communication in parallel runs using the GridGlue::communicate methods. More...
 
class  Dune::GridGlue::StreamingMessageBuffer< DT >
 
class  Dune::GridGlue::CommunicationOperator< dir >
 forward gather scatter to user defined CommInfo class More...
 
struct  Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp >
 collects all GridGlue data requried for communication More...
 
struct  Dune::CommPolicy< ::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > >
 specialization of the CommPolicy struct, required for the ParallelIndexsets More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

typedef std::pair< int, int > Dune::GridGlue::RankPair
 
typedef CommunicationOperator< Dune::ForwardCommunication > Dune::GridGlue::ForwardOperator
 
typedef CommunicationOperator< Dune::BackwardCommunication > Dune::GridGlue::BackwardOperator
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

std::ostream & Dune::GridGlue::operator<< (std::ostream &os, const GlobalId &id)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implement iterators over GridGlue intersections.

│ │ │ │ +

Describes the parallel communication interface class for Dune::GridGlue.

│ │ │ │
Author
Christian Engwer
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,27 +5,62 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -intersectioniterator.hh File Reference │ │ │ │ │ -Implement iterators over GridGlue intersections. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +gridgluecommunicate.hh File Reference │ │ │ │ │ +Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::GridGlue::IntersectionIterator<_P0,_P1,_inside,_outside_> │ │ │ │ │ +struct  Dune::GridGlue::GlobalId │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GridGlue::CommDataHandle<_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +  describes the features of a data handle for communication in parallel │ │ │ │ │ + runs using the GridGlue::communicate methods. More... │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GridGlue::StreamingMessageBuffer<_DT_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GridGlue::CommunicationOperator<_dir_> │ │ │ │ │ +  forward gather scatter to user defined CommInfo class More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +  collects all GridGlue data requried for communication More... │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp, │ │ │ │ │ + DataTypeImp_>_> │ │ │ │ │ +  specialization of the CommPolicy struct, required for the │ │ │ │ │ + ParallelIndexsets More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ + Typedefs │ │ │ │ │ + typedef std::pair< int, int > Dune::GridGlue::RankPair │ │ │ │ │ +  │ │ │ │ │ +typedef CommunicationOperator< Dune:: │ │ │ │ │ + ForwardCommunication > Dune::GridGlue::ForwardOperator │ │ │ │ │ +  │ │ │ │ │ +typedef CommunicationOperator< Dune:: │ │ │ │ │ + BackwardCommunication > Dune::GridGlue::BackwardOperator │ │ │ │ │ +  │ │ │ │ │ + Functions │ │ │ │ │ +std::ostream & Dune::GridGlue::operator<< (std::ostream &os, const GlobalId │ │ │ │ │ + &id) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implement iterators over GridGlue intersections. │ │ │ │ │ +Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ Author │ │ │ │ │ Christian Engwer │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectioniterator.hh Source File │ │ │ │ +dune-grid-glue: gridgluecommunicate.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,85 +62,323 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
intersectioniterator.hh
│ │ │ │ +
gridgluecommunicate.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ -
13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ +
5#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ +
6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ +
7
│ │ │ │ +
13#include <type_traits>
│ │ │ │
14
│ │ │ │ - │ │ │ │ -
16
│ │ │ │ -
17namespace Dune {
│ │ │ │ -
18 namespace GridGlue {
│ │ │ │ +
15#include <dune/common/bartonnackmanifcheck.hh>
│ │ │ │ +
16#include <dune/common/parallel/communicator.hh>
│ │ │ │ +
17#include <dune/grid/common/datahandleif.hh>
│ │ │ │ +
18#include <dune/grid/common/gridenums.hh>
│ │ │ │
19
│ │ │ │ -
21 template<typename P0, typename P1, int inside, int outside>
│ │ │ │ - │ │ │ │ -
23 public Dune::ForwardIteratorFacade< IntersectionIterator<P0,P1,inside,outside>,
│ │ │ │ -
24 const Intersection<P0,P1,inside,outside> >
│ │ │ │ -
25 {
│ │ │ │ -
26 public:
│ │ │ │ -
27
│ │ │ │ -
28 typedef ::Dune::GridGlue::GridGlue<P0, P1> GridGlue;
│ │ │ │ -
29 typedef ::Dune::GridGlue::Intersection<P0,P1,inside,outside> Intersection;
│ │ │ │ -
30
│ │ │ │ -
31 IntersectionIterator(const GridGlue * glue, unsigned int i)
│ │ │ │ -
32 : glue_(glue),
│ │ │ │ -
33 index_(i),
│ │ │ │ -
34 intersection_(glue_, & glue_->intersections_[index_])
│ │ │ │ -
35 {}
│ │ │ │ -
36
│ │ │ │ - │ │ │ │ -
38 {
│ │ │ │ -
39 assert(("never dereference the end iterator" &&
│ │ │ │ -
40 index_ != glue_->index__sz));
│ │ │ │ -
41 return intersection_;
│ │ │ │ +
20
│ │ │ │ +
21namespace Dune {
│ │ │ │ +
22 namespace GridGlue {
│ │ │ │ +
23
│ │ │ │ +
24 typedef std::pair<int, int> RankPair;
│ │ │ │ +
25 struct GlobalId : public std::pair<RankPair, unsigned int>
│ │ │ │ +
26 {
│ │ │ │ + │ │ │ │ +
31 this->first.first = 0;
│ │ │ │ +
32 this->first.second = 0;
│ │ │ │ +
33 this->second = 0;
│ │ │ │ +
34 }
│ │ │ │ +
38 GlobalId(int i) {
│ │ │ │ +
39 this->first.first = i;
│ │ │ │ +
40 this->first.second = i;
│ │ │ │ +
41 this->second = 0;
│ │ │ │
42 }
│ │ │ │ -
43
│ │ │ │ -
44 void increment()
│ │ │ │ -
45 {
│ │ │ │ -
46 intersection_ = Intersection(glue_, & glue_->intersections_[++index_]);
│ │ │ │ -
47 }
│ │ │ │ -
48
│ │ │ │ -
49 bool equals(const IntersectionIterator& iter) const
│ │ │ │ -
50 {
│ │ │ │ -
51 return iter.index_ == index_;
│ │ │ │ +
48 GlobalId(int i, int j, unsigned int n) {
│ │ │ │ +
49 this->first.first = std::min(i,j);
│ │ │ │ +
50 this->first.second = std::max(i,j);
│ │ │ │ +
51 this->second = n;
│ │ │ │
52 }
│ │ │ │ -
53
│ │ │ │ -
54 private:
│ │ │ │ -
55
│ │ │ │ -
56 const GridGlue* glue_;
│ │ │ │ -
57 unsigned int index_;
│ │ │ │ -
58
│ │ │ │ -
59 Intersection intersection_;
│ │ │ │ -
60 };
│ │ │ │ -
61
│ │ │ │ -
62 } // end namespace GridGlue
│ │ │ │ -
63} // end namespace Dune
│ │ │ │ -
64
│ │ │ │ -
65#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ -
Central component of the module implementing the coupling of two grids.
│ │ │ │ +
53 };
│ │ │ │ +
54
│ │ │ │ +
55 inline std::ostream& operator<<(std::ostream& os, const GlobalId & id)
│ │ │ │ +
56 {
│ │ │ │ +
57 os << "("
│ │ │ │ +
58 << id.first.first << "," << id.first.second << ","
│ │ │ │ +
59 << id.second << ")";
│ │ │ │ +
60 return os;
│ │ │ │ +
61 }
│ │ │ │ +
62
│ │ │ │ +
75 template <class DataHandleImp, class DataTypeImp>
│ │ │ │ + │ │ │ │ +
77 {
│ │ │ │ +
78 public:
│ │ │ │ +
80 typedef DataTypeImp DataType;
│ │ │ │ +
81
│ │ │ │ +
82 protected:
│ │ │ │ +
83 // one should not create an explicit instance of this inteface object
│ │ │ │ + │ │ │ │ +
85
│ │ │ │ +
86 public:
│ │ │ │ +
87
│ │ │ │ +
91 template<class RISType>
│ │ │ │ +
92 size_t size (RISType& i) const
│ │ │ │ +
93 {
│ │ │ │ +
94 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(i)));
│ │ │ │ +
95 return asImp().size(i);
│ │ │ │ +
96 }
│ │ │ │ +
97
│ │ │ │ +
103 template<class MessageBufferImp, class EntityType, class RISType>
│ │ │ │ +
104 void gather (MessageBufferImp& buff, const EntityType& e, const RISType & i) const
│ │ │ │ +
105 {
│ │ │ │ +
106 MessageBufferIF<MessageBufferImp> buffIF(buff);
│ │ │ │ +
107 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e,i)));
│ │ │ │ +
108 }
│ │ │ │ +
109
│ │ │ │ +
117 template<class MessageBufferImp, class EntityType, class RISType>
│ │ │ │ +
118 void scatter (MessageBufferImp& buff, const EntityType& e, const RISType & i, size_t n)
│ │ │ │ +
119 {
│ │ │ │ +
120 MessageBufferIF<MessageBufferImp> buffIF(buff);
│ │ │ │ +
121 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,i,n)));
│ │ │ │ +
122 }
│ │ │ │ +
123
│ │ │ │ +
124 private:
│ │ │ │ +
126 DataHandleImp& asImp () {
│ │ │ │ +
127 return static_cast<DataHandleImp &> (*this);
│ │ │ │ +
128 }
│ │ │ │ +
130 const DataHandleImp& asImp () const
│ │ │ │ +
131 {
│ │ │ │ +
132 return static_cast<const DataHandleImp &>(*this);
│ │ │ │ +
133 }
│ │ │ │ +
134 }; // end class CommDataHandleIF
│ │ │ │ +
135
│ │ │ │ +
140 template<typename DT>
│ │ │ │ + │ │ │ │ +
142 public:
│ │ │ │ +
143 typedef DT value_type;
│ │ │ │ +
144
│ │ │ │ +
145 // Constructor
│ │ │ │ + │ │ │ │ +
147 {
│ │ │ │ +
148 a=p;
│ │ │ │ +
149 i=0;
│ │ │ │ +
150 j=0;
│ │ │ │ +
151 }
│ │ │ │ +
152
│ │ │ │ +
153 // write data to message buffer, acts like a stream !
│ │ │ │ +
154 template<class Y>
│ │ │ │ +
155 void write (const Y& data)
│ │ │ │ +
156 {
│ │ │ │ +
157 static_assert(std::is_same<DT,Y>::value, "DataType mismatch");
│ │ │ │ +
158 a[i++] = data;
│ │ │ │ +
159 }
│ │ │ │ +
160
│ │ │ │ +
161 // read data from message buffer, acts like a stream !
│ │ │ │ +
162 template<class Y>
│ │ │ │ +
163 void read (Y& data) const
│ │ │ │ +
164 {
│ │ │ │ +
165 static_assert(std::is_same<DT,Y>::value, "DataType mismatch");
│ │ │ │ +
166 data = a[j++];
│ │ │ │ +
167 }
│ │ │ │ +
168
│ │ │ │ +
169 size_t counter() const { return i; }
│ │ │ │ +
170
│ │ │ │ +
171 void clear()
│ │ │ │ +
172 {
│ │ │ │ +
173 i = 0;
│ │ │ │ +
174 j = 0;
│ │ │ │ +
175 }
│ │ │ │ +
176
│ │ │ │ +
177 // we need access to these variables in an assertion
│ │ │ │ +
178#ifdef NDEBUG
│ │ │ │ +
179 private:
│ │ │ │ +
180#endif
│ │ │ │ +
181 DT *a;
│ │ │ │ +
182 size_t i;
│ │ │ │ +
183 mutable size_t j;
│ │ │ │ +
184 };
│ │ │ │ +
185
│ │ │ │ +
192 template<int dir>
│ │ │ │ + │ │ │ │ +
194 {
│ │ │ │ +
195 public:
│ │ │ │ +
196 template<class CommInfo>
│ │ │ │ +
197 static const typename CommInfo::DataType& gather(const CommInfo& commInfo, size_t i, size_t j = 0)
│ │ │ │ +
198 {
│ │ │ │ +
199 // get Intersection
│ │ │ │ +
200 typedef typename CommInfo::GridGlue::Intersection Intersection;
│ │ │ │ +
201 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ +
202
│ │ │ │ +
203 // fill buffer if we have a new intersection
│ │ │ │ +
204 if (j == 0)
│ │ │ │ +
205 {
│ │ │ │ +
206 commInfo.mbuffer.clear();
│ │ │ │ +
207 if (dir == Dune::ForwardCommunication)
│ │ │ │ +
208 {
│ │ │ │ +
209 // read from grid0
│ │ │ │ +
210 if(ris.self())
│ │ │ │ +
211 commInfo.data->gather(commInfo.mbuffer, ris.inside(), ris);
│ │ │ │ +
212 }
│ │ │ │ +
213 else // (dir == Dune::BackwardCommunication)
│ │ │ │ +
214 {
│ │ │ │ +
215 // read from grid1
│ │ │ │ +
216 if(ris.neighbor())
│ │ │ │ +
217 commInfo.data->gather(commInfo.mbuffer, ris.outside(), ris.flip());
│ │ │ │ +
218 }
│ │ │ │ +
219 }
│ │ │ │ +
220
│ │ │ │ +
221 // return the j'th value in the buffer
│ │ │ │ +
222 assert(j < commInfo.mbuffer.i);
│ │ │ │ +
223 return commInfo.buffer[j];
│ │ │ │ +
224 }
│ │ │ │ +
225
│ │ │ │ +
226 template<class CommInfo>
│ │ │ │ +
227 static void scatter(CommInfo& commInfo, const typename CommInfo::DataType& v, std::size_t i, std::size_t j = 0)
│ │ │ │ +
228 {
│ │ │ │ +
229 // extract GridGlue objects...
│ │ │ │ +
230 typedef typename CommInfo::GridGlue::Intersection Intersection;
│ │ │ │ +
231 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ +
232
│ │ │ │ +
233 // get size if we have a new intersection
│ │ │ │ +
234 if (j == 0)
│ │ │ │ +
235 {
│ │ │ │ +
236 commInfo.mbuffer.clear();
│ │ │ │ +
237 commInfo.currentsize = commInfo.data->size(ris);
│ │ │ │ +
238 }
│ │ │ │ +
239
│ │ │ │ +
240 // write entry to buffer
│ │ │ │ +
241 commInfo.buffer[j] = v;
│ │ │ │ +
242
│ │ │ │ +
243 // write back the buffer if we are at the end of this intersection
│ │ │ │ +
244 if (j == commInfo.currentsize-1)
│ │ │ │ +
245 {
│ │ │ │ +
246 if (dir == Dune::ForwardCommunication)
│ │ │ │ +
247 {
│ │ │ │ +
248 // write to grid1
│ │ │ │ +
249 if(ris.neighbor())
│ │ │ │ +
250 commInfo.data->scatter(commInfo.mbuffer, ris.outside(), ris.flip(), commInfo.currentsize);
│ │ │ │ +
251 }
│ │ │ │ +
252 else // (dir == Dune::BackwardCommunication)
│ │ │ │ +
253 {
│ │ │ │ +
254 // write to grid0
│ │ │ │ +
255 if(ris.self())
│ │ │ │ +
256 commInfo.data->scatter(commInfo.mbuffer, ris.inside(), ris, commInfo.currentsize);
│ │ │ │ +
257 }
│ │ │ │ +
258 assert(commInfo.mbuffer.j <= commInfo.currentsize);
│ │ │ │ +
259 }
│ │ │ │ +
260 }
│ │ │ │ +
261 };
│ │ │ │ +
262
│ │ │ │ + │ │ │ │ + │ │ │ │ +
265
│ │ │ │ +
270 template <typename GG, class DataHandleImp, class DataTypeImp>
│ │ │ │ +
271 struct CommInfo
│ │ │ │ +
272 {
│ │ │ │ +
273 typedef DataTypeImp value_type;
│ │ │ │ +
274 typedef GG GridGlue;
│ │ │ │ +
275 typedef DataTypeImp DataType;
│ │ │ │ +
276
│ │ │ │ + │ │ │ │ +
278 {}
│ │ │ │ +
279
│ │ │ │ +
280 // tunnel information to the policy and the operators
│ │ │ │ + │ │ │ │ + │ │ │ │ +
283
│ │ │ │ +
284 // state variables
│ │ │ │ +
285 std::vector<DataType> buffer;
│ │ │ │ +
286 mutable ::Dune::GridGlue::StreamingMessageBuffer<DataType> mbuffer;
│ │ │ │ + │ │ │ │ +
288 Dune::CommunicationDirection dir;
│ │ │ │ +
289 };
│ │ │ │ +
290
│ │ │ │ +
291 } // end namespace GridGlue
│ │ │ │ +
292
│ │ │ │ +
293#if HAVE_MPI
│ │ │ │ +
298 template<typename GG, class DataHandleImp, class DataTypeImp>
│ │ │ │ +
299 struct CommPolicy< ::Dune::GridGlue::CommInfo<GG, DataHandleImp, DataTypeImp> >
│ │ │ │ +
300 {
│ │ │ │ +
304 typedef ::Dune::GridGlue::CommInfo<GG, DataHandleImp, DataTypeImp> Type;
│ │ │ │ +
305
│ │ │ │ +
309 typedef DataTypeImp IndexedType;
│ │ │ │ +
310
│ │ │ │ +
314 // typedef SizeOne IndexedTypeFlag;
│ │ │ │ +
315 typedef VariableSize IndexedTypeFlag;
│ │ │ │ +
316
│ │ │ │ +
320 static size_t getSize(const Type& commInfo, size_t i)
│ │ │ │ +
321 {
│ │ │ │ +
322 // get Intersection
│ │ │ │ +
323 typedef typename Type::GridGlue::Intersection Intersection;
│ │ │ │ +
324 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ +
325
│ │ │ │ +
326 // ask data handle for size
│ │ │ │ +
327 return commInfo.data->size(ris);
│ │ │ │ +
328 }
│ │ │ │ +
329 };
│ │ │ │ +
330#endif
│ │ │ │ +
331
│ │ │ │ +
332} // end namespace Dune
│ │ │ │ +
333#endif
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:67
│ │ │ │ - │ │ │ │ -
Definition: intersectioniterator.hh:25
│ │ │ │ -
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersectioniterator.hh:28
│ │ │ │ -
const Intersection & dereference() const
Definition: intersectioniterator.hh:37
│ │ │ │ -
void increment()
Definition: intersectioniterator.hh:44
│ │ │ │ -
::Dune::GridGlue::Intersection< P0, P1, inside, outside > Intersection
Definition: intersectioniterator.hh:29
│ │ │ │ -
IntersectionIterator(const GridGlue *glue, unsigned int i)
Definition: intersectioniterator.hh:31
│ │ │ │ -
bool equals(const IntersectionIterator &iter) const
Definition: intersectioniterator.hh:49
│ │ │ │ +
CommunicationOperator< Dune::BackwardCommunication > BackwardOperator
Definition: gridgluecommunicate.hh:264
│ │ │ │ +
CommunicationOperator< Dune::ForwardCommunication > ForwardOperator
Definition: gridgluecommunicate.hh:263
│ │ │ │ +
std::pair< int, int > RankPair
Definition: gridgluecommunicate.hh:24
│ │ │ │ +
std::ostream & operator<<(std::ostream &os, const GlobalId &id)
Definition: gridgluecommunicate.hh:55
│ │ │ │ +
The intersection of two entities of the two patches of a GridGlue.
Definition: intersection.hh:261
│ │ │ │ +
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition: intersection.hh:483
│ │ │ │ +
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition: intersection.hh:393
│ │ │ │ +
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition: intersection.hh:319
│ │ │ │ +
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition: intersection.hh:399
│ │ │ │ +
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition: intersection.hh:328
│ │ │ │ +
Definition: gridgluecommunicate.hh:26
│ │ │ │ +
GlobalId(int i)
Definition: gridgluecommunicate.hh:38
│ │ │ │ +
GlobalId()
Definition: gridgluecommunicate.hh:30
│ │ │ │ +
GlobalId(int i, int j, unsigned int n)
Definition: gridgluecommunicate.hh:48
│ │ │ │ +
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:77
│ │ │ │ +
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:92
│ │ │ │ +
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:118
│ │ │ │ +
void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) const
pack data from user to message buffer
Definition: gridgluecommunicate.hh:104
│ │ │ │ +
DataTypeImp DataType
data type of data to communicate
Definition: gridgluecommunicate.hh:80
│ │ │ │ +
CommDataHandle()
Definition: gridgluecommunicate.hh:84
│ │ │ │ +
Definition: gridgluecommunicate.hh:141
│ │ │ │ +
size_t j
Definition: gridgluecommunicate.hh:183
│ │ │ │ +
StreamingMessageBuffer(DT *p)
Definition: gridgluecommunicate.hh:146
│ │ │ │ +
DT * a
Definition: gridgluecommunicate.hh:181
│ │ │ │ +
size_t counter() const
Definition: gridgluecommunicate.hh:169
│ │ │ │ +
void write(const Y &data)
Definition: gridgluecommunicate.hh:155
│ │ │ │ +
void read(Y &data) const
Definition: gridgluecommunicate.hh:163
│ │ │ │ +
DT value_type
Definition: gridgluecommunicate.hh:143
│ │ │ │ +
size_t i
Definition: gridgluecommunicate.hh:182
│ │ │ │ +
void clear()
Definition: gridgluecommunicate.hh:171
│ │ │ │ +
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:194
│ │ │ │ +
static void scatter(CommInfo &commInfo, const typename CommInfo::DataType &v, std::size_t i, std::size_t j=0)
Definition: gridgluecommunicate.hh:227
│ │ │ │ +
static const CommInfo::DataType & gather(const CommInfo &commInfo, size_t i, size_t j=0)
Definition: gridgluecommunicate.hh:197
│ │ │ │ +
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:272
│ │ │ │ +
Dune::CommunicationDirection dir
Definition: gridgluecommunicate.hh:288
│ │ │ │ +
DataTypeImp value_type
Definition: gridgluecommunicate.hh:273
│ │ │ │ +
DataTypeImp DataType
Definition: gridgluecommunicate.hh:275
│ │ │ │ +
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:282
│ │ │ │ +
GG GridGlue
Definition: gridgluecommunicate.hh:274
│ │ │ │ +
size_t currentsize
Definition: gridgluecommunicate.hh:287
│ │ │ │ +
CommInfo()
Definition: gridgluecommunicate.hh:277
│ │ │ │ +
mutable ::Dune::GridGlue::StreamingMessageBuffer< DataType > mbuffer
Definition: gridgluecommunicate.hh:286
│ │ │ │ +
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:281
│ │ │ │ +
std::vector< DataType > buffer
Definition: gridgluecommunicate.hh:285
│ │ │ │ +
static size_t getSize(const Type &commInfo, size_t i)
Get the number of objects at an intersection.
Definition: gridgluecommunicate.hh:320
│ │ │ │ +
DataTypeImp IndexedType
The datatype that should be communicated.
Definition: gridgluecommunicate.hh:309
│ │ │ │ +
::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Type
The type of the GridGlueCommInfo.
Definition: gridgluecommunicate.hh:304
│ │ │ │ +
VariableSize IndexedTypeFlag
Each intersection can communicate a different number of objects.
Definition: gridgluecommunicate.hh:315
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,100 +5,443 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -intersectioniterator.hh │ │ │ │ │ +gridgluecommunicate.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ - 13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ + 5#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ + 6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ + 7 │ │ │ │ │ + 13#include │ │ │ │ │ 14 │ │ │ │ │ - 15#include │ │ │ │ │ - 16 │ │ │ │ │ - 17namespace Dune { │ │ │ │ │ - 18 namespace GridGlue { │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ 19 │ │ │ │ │ - 21 template │ │ │ │ │ -22 class IntersectionIterator : │ │ │ │ │ - 23 public Dune::ForwardIteratorFacade< │ │ │ │ │ -IntersectionIterator, │ │ │ │ │ - 24 const Intersection > │ │ │ │ │ - 25 { │ │ │ │ │ - 26 public: │ │ │ │ │ - 27 │ │ │ │ │ -28 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ -29 typedef ::Dune::GridGlue::Intersection Intersection; │ │ │ │ │ - 30 │ │ │ │ │ -31 IntersectionIterator(const GridGlue * glue, unsigned int i) │ │ │ │ │ - 32 : glue_(glue), │ │ │ │ │ - 33 index_(i), │ │ │ │ │ - 34 intersection_(glue_, & glue_->intersections_[index_]) │ │ │ │ │ - 35 {} │ │ │ │ │ - 36 │ │ │ │ │ -37 const Intersection& dereference() const │ │ │ │ │ - 38 { │ │ │ │ │ - 39 assert(("never dereference the end iterator" && │ │ │ │ │ - 40 index_ != glue_->index__sz)); │ │ │ │ │ - 41 return intersection_; │ │ │ │ │ + 20 │ │ │ │ │ + 21namespace Dune { │ │ │ │ │ + 22 namespace GridGlue { │ │ │ │ │ + 23 │ │ │ │ │ +24 typedef std::pair RankPair; │ │ │ │ │ +25 struct GlobalId : public std::pair │ │ │ │ │ + 26 { │ │ │ │ │ +30 GlobalId() { │ │ │ │ │ + 31 this->first.first = 0; │ │ │ │ │ + 32 this->first.second = 0; │ │ │ │ │ + 33 this->second = 0; │ │ │ │ │ + 34 } │ │ │ │ │ +38 GlobalId(int i) { │ │ │ │ │ + 39 this->first.first = i; │ │ │ │ │ + 40 this->first.second = i; │ │ │ │ │ + 41 this->second = 0; │ │ │ │ │ 42 } │ │ │ │ │ - 43 │ │ │ │ │ -44 void increment() │ │ │ │ │ - 45 { │ │ │ │ │ - 46 intersection_ = Intersection(glue_, & glue_->intersections_[++index_]); │ │ │ │ │ - 47 } │ │ │ │ │ - 48 │ │ │ │ │ -49 bool equals(const IntersectionIterator& iter) const │ │ │ │ │ - 50 { │ │ │ │ │ - 51 return iter.index_ == index_; │ │ │ │ │ +48 GlobalId(int i, int j, unsigned int n) { │ │ │ │ │ + 49 this->first.first = std::min(i,j); │ │ │ │ │ + 50 this->first.second = std::max(i,j); │ │ │ │ │ + 51 this->second = n; │ │ │ │ │ 52 } │ │ │ │ │ - 53 │ │ │ │ │ - 54 private: │ │ │ │ │ - 55 │ │ │ │ │ - 56 const GridGlue* glue_; │ │ │ │ │ - 57 unsigned int index_; │ │ │ │ │ - 58 │ │ │ │ │ - 59 Intersection intersection_; │ │ │ │ │ - 60 }; │ │ │ │ │ - 61 │ │ │ │ │ - 62 } // end namespace GridGlue │ │ │ │ │ - 63} // end namespace Dune │ │ │ │ │ - 64 │ │ │ │ │ - 65#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ -gridglue.hh │ │ │ │ │ -Central component of the module implementing the coupling of two grids. │ │ │ │ │ + 53 }; │ │ │ │ │ + 54 │ │ │ │ │ +55 inline std::ostream& operator<<(std::ostream& os, const GlobalId & id) │ │ │ │ │ + 56 { │ │ │ │ │ + 57 os << "(" │ │ │ │ │ + 58 << id.first.first << "," << id.first.second << "," │ │ │ │ │ + 59 << id.second << ")"; │ │ │ │ │ + 60 return os; │ │ │ │ │ + 61 } │ │ │ │ │ + 62 │ │ │ │ │ + 75 template │ │ │ │ │ +76 class CommDataHandle │ │ │ │ │ + 77 { │ │ │ │ │ + 78 public: │ │ │ │ │ +80 typedef DataTypeImp DataType; │ │ │ │ │ + 81 │ │ │ │ │ + 82 protected: │ │ │ │ │ + 83 // one should not create an explicit instance of this inteface object │ │ │ │ │ +84 CommDataHandle() {} │ │ │ │ │ + 85 │ │ │ │ │ + 86 public: │ │ │ │ │ + 87 │ │ │ │ │ + 91 template │ │ │ │ │ +92 size_t size (RISType& i) const │ │ │ │ │ + 93 { │ │ │ │ │ + 94 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(i))); │ │ │ │ │ + 95 return asImp().size(i); │ │ │ │ │ + 96 } │ │ │ │ │ + 97 │ │ │ │ │ + 103 template │ │ │ │ │ +104 void gather (MessageBufferImp& buff, const EntityType& e, const RISType & │ │ │ │ │ +i) const │ │ │ │ │ + 105 { │ │ │ │ │ + 106 MessageBufferIF buffIF(buff); │ │ │ │ │ + 107 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e,i))); │ │ │ │ │ + 108 } │ │ │ │ │ + 109 │ │ │ │ │ + 117 template │ │ │ │ │ +118 void scatter (MessageBufferImp& buff, const EntityType& e, const RISType & │ │ │ │ │ +i, size_t n) │ │ │ │ │ + 119 { │ │ │ │ │ + 120 MessageBufferIF buffIF(buff); │ │ │ │ │ + 121 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,i,n))); │ │ │ │ │ + 122 } │ │ │ │ │ + 123 │ │ │ │ │ + 124 private: │ │ │ │ │ + 126 DataHandleImp& asImp () { │ │ │ │ │ + 127 return static_cast (*this); │ │ │ │ │ + 128 } │ │ │ │ │ + 130 const DataHandleImp& asImp () const │ │ │ │ │ + 131 { │ │ │ │ │ + 132 return static_cast(*this); │ │ │ │ │ + 133 } │ │ │ │ │ + 134 }; // end class CommDataHandleIF │ │ │ │ │ + 135 │ │ │ │ │ + 140 template │ │ │ │ │ +141 class StreamingMessageBuffer { │ │ │ │ │ + 142 public: │ │ │ │ │ +143 typedef DT value_type; │ │ │ │ │ + 144 │ │ │ │ │ + 145 // Constructor │ │ │ │ │ +146 StreamingMessageBuffer (DT *p) │ │ │ │ │ + 147 { │ │ │ │ │ + 148 a=p; │ │ │ │ │ + 149 i=0; │ │ │ │ │ + 150 j=0; │ │ │ │ │ + 151 } │ │ │ │ │ + 152 │ │ │ │ │ + 153 // write data to message buffer, acts like a stream ! │ │ │ │ │ + 154 template │ │ │ │ │ +155 void write (const Y& data) │ │ │ │ │ + 156 { │ │ │ │ │ + 157 static_assert(std::is_same::value, "DataType mismatch"); │ │ │ │ │ + 158 a[i++] = data; │ │ │ │ │ + 159 } │ │ │ │ │ + 160 │ │ │ │ │ + 161 // read data from message buffer, acts like a stream ! │ │ │ │ │ + 162 template │ │ │ │ │ +163 void read (Y& data) const │ │ │ │ │ + 164 { │ │ │ │ │ + 165 static_assert(std::is_same::value, "DataType mismatch"); │ │ │ │ │ + 166 data = a[j++]; │ │ │ │ │ + 167 } │ │ │ │ │ + 168 │ │ │ │ │ +169 size_t counter() const { return i; } │ │ │ │ │ + 170 │ │ │ │ │ +171 void clear() │ │ │ │ │ + 172 { │ │ │ │ │ + 173 i = 0; │ │ │ │ │ + 174 j = 0; │ │ │ │ │ + 175 } │ │ │ │ │ + 176 │ │ │ │ │ + 177 // we need access to these variables in an assertion │ │ │ │ │ + 178#ifdef NDEBUG │ │ │ │ │ + 179 private: │ │ │ │ │ + 180#endif │ │ │ │ │ +181 DT *a; │ │ │ │ │ +182 size_t i; │ │ │ │ │ +183 mutable size_t j; │ │ │ │ │ + 184 }; │ │ │ │ │ + 185 │ │ │ │ │ + 192 template │ │ │ │ │ +193 class CommunicationOperator │ │ │ │ │ + 194 { │ │ │ │ │ + 195 public: │ │ │ │ │ + 196 template │ │ │ │ │ +197 static const typename CommInfo::DataType& gather(const CommInfo& commInfo, │ │ │ │ │ +size_t i, size_t j = 0) │ │ │ │ │ + 198 { │ │ │ │ │ + 199 // get Intersection │ │ │ │ │ + 200 typedef typename CommInfo::GridGlue::Intersection Intersection; │ │ │ │ │ + 201 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ + 202 │ │ │ │ │ + 203 // fill buffer if we have a new intersection │ │ │ │ │ + 204 if (j == 0) │ │ │ │ │ + 205 { │ │ │ │ │ + 206 commInfo.mbuffer.clear(); │ │ │ │ │ + 207 if (dir == Dune::ForwardCommunication) │ │ │ │ │ + 208 { │ │ │ │ │ + 209 // read from grid0 │ │ │ │ │ + 210 if(ris.self()) │ │ │ │ │ + 211 commInfo.data->gather(commInfo.mbuffer, ris.inside(), ris); │ │ │ │ │ + 212 } │ │ │ │ │ + 213 else // (dir == Dune::BackwardCommunication) │ │ │ │ │ + 214 { │ │ │ │ │ + 215 // read from grid1 │ │ │ │ │ + 216 if(ris.neighbor()) │ │ │ │ │ + 217 commInfo.data->gather(commInfo.mbuffer, ris.outside(), ris.flip()); │ │ │ │ │ + 218 } │ │ │ │ │ + 219 } │ │ │ │ │ + 220 │ │ │ │ │ + 221 // return the j'th value in the buffer │ │ │ │ │ + 222 assert(j < commInfo.mbuffer.i); │ │ │ │ │ + 223 return commInfo.buffer[j]; │ │ │ │ │ + 224 } │ │ │ │ │ + 225 │ │ │ │ │ + 226 template │ │ │ │ │ +227 static void scatter(CommInfo& commInfo, const typename CommInfo::DataType& │ │ │ │ │ +v, std::size_t i, std::size_t j = 0) │ │ │ │ │ + 228 { │ │ │ │ │ + 229 // extract GridGlue objects... │ │ │ │ │ + 230 typedef typename CommInfo::GridGlue::Intersection Intersection; │ │ │ │ │ + 231 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ + 232 │ │ │ │ │ + 233 // get size if we have a new intersection │ │ │ │ │ + 234 if (j == 0) │ │ │ │ │ + 235 { │ │ │ │ │ + 236 commInfo.mbuffer.clear(); │ │ │ │ │ + 237 commInfo.currentsize = commInfo.data->size(ris); │ │ │ │ │ + 238 } │ │ │ │ │ + 239 │ │ │ │ │ + 240 // write entry to buffer │ │ │ │ │ + 241 commInfo.buffer[j] = v; │ │ │ │ │ + 242 │ │ │ │ │ + 243 // write back the buffer if we are at the end of this intersection │ │ │ │ │ + 244 if (j == commInfo.currentsize-1) │ │ │ │ │ + 245 { │ │ │ │ │ + 246 if (dir == Dune::ForwardCommunication) │ │ │ │ │ + 247 { │ │ │ │ │ + 248 // write to grid1 │ │ │ │ │ + 249 if(ris.neighbor()) │ │ │ │ │ + 250 commInfo.data->scatter(commInfo.mbuffer, ris.outside(), ris.flip(), │ │ │ │ │ +commInfo.currentsize); │ │ │ │ │ + 251 } │ │ │ │ │ + 252 else // (dir == Dune::BackwardCommunication) │ │ │ │ │ + 253 { │ │ │ │ │ + 254 // write to grid0 │ │ │ │ │ + 255 if(ris.self()) │ │ │ │ │ + 256 commInfo.data->scatter(commInfo.mbuffer, ris.inside(), ris, │ │ │ │ │ +commInfo.currentsize); │ │ │ │ │ + 257 } │ │ │ │ │ + 258 assert(commInfo.mbuffer.j <= commInfo.currentsize); │ │ │ │ │ + 259 } │ │ │ │ │ + 260 } │ │ │ │ │ + 261 }; │ │ │ │ │ + 262 │ │ │ │ │ +263 typedef CommunicationOperator ForwardOperator; │ │ │ │ │ +264 typedef CommunicationOperator │ │ │ │ │ +BackwardOperator; │ │ │ │ │ + 265 │ │ │ │ │ + 270 template │ │ │ │ │ +271 struct CommInfo │ │ │ │ │ + 272 { │ │ │ │ │ +273 typedef DataTypeImp value_type; │ │ │ │ │ +274 typedef GG GridGlue; │ │ │ │ │ +275 typedef DataTypeImp DataType; │ │ │ │ │ + 276 │ │ │ │ │ +277 CommInfo() : buffer(100), mbuffer(&buffer[0]) │ │ │ │ │ + 278 {} │ │ │ │ │ + 279 │ │ │ │ │ + 280 // tunnel information to the policy and the operators │ │ │ │ │ +281 const GridGlue * gridglue; │ │ │ │ │ +282 ::Dune::GridGlue::CommDataHandle * data; │ │ │ │ │ + 283 │ │ │ │ │ + 284 // state variables │ │ │ │ │ +285 std::vector buffer; │ │ │ │ │ +286 mutable ::Dune::GridGlue::StreamingMessageBuffer mbuffer; │ │ │ │ │ +287 size_t currentsize; │ │ │ │ │ +288 Dune::CommunicationDirection dir; │ │ │ │ │ + 289 }; │ │ │ │ │ + 290 │ │ │ │ │ + 291 } // end namespace GridGlue │ │ │ │ │ + 292 │ │ │ │ │ + 293#if HAVE_MPI │ │ │ │ │ + 298 template │ │ │ │ │ +299 struct CommPolicy< ::Dune::GridGlue::CommInfo > │ │ │ │ │ + 300 { │ │ │ │ │ +304 typedef ::Dune::GridGlue::CommInfo Type; │ │ │ │ │ + 305 │ │ │ │ │ +309 typedef DataTypeImp IndexedType; │ │ │ │ │ + 310 │ │ │ │ │ + 314 // typedef SizeOne IndexedTypeFlag; │ │ │ │ │ +315 typedef VariableSize IndexedTypeFlag; │ │ │ │ │ + 316 │ │ │ │ │ +320 static size_t getSize(const Type& commInfo, size_t i) │ │ │ │ │ + 321 { │ │ │ │ │ + 322 // get Intersection │ │ │ │ │ + 323 typedef typename Type::GridGlue::Intersection Intersection; │ │ │ │ │ + 324 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ + 325 │ │ │ │ │ + 326 // ask data handle for size │ │ │ │ │ + 327 return commInfo.data->size(ris); │ │ │ │ │ + 328 } │ │ │ │ │ + 329 }; │ │ │ │ │ + 330#endif │ │ │ │ │ + 331 │ │ │ │ │ + 332} // end namespace Dune │ │ │ │ │ + 333#endif │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::GridGlue │ │ │ │ │ -sequential adapter to couple two grids at specified close together boundaries │ │ │ │ │ -Definition: gridglue.hh:67 │ │ │ │ │ -Dune::GridGlue::Intersection<_P0,_P1,_inside,_outside_> │ │ │ │ │ -Dune::GridGlue::IntersectionIterator │ │ │ │ │ -Definition: intersectioniterator.hh:25 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::GridGlue │ │ │ │ │ -::Dune::GridGlue::GridGlue< P0, P1 > GridGlue │ │ │ │ │ -Definition: intersectioniterator.hh:28 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::dereference │ │ │ │ │ -const Intersection & dereference() const │ │ │ │ │ -Definition: intersectioniterator.hh:37 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::increment │ │ │ │ │ -void increment() │ │ │ │ │ -Definition: intersectioniterator.hh:44 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::Intersection │ │ │ │ │ -::Dune::GridGlue::Intersection< P0, P1, inside, outside > Intersection │ │ │ │ │ -Definition: intersectioniterator.hh:29 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::IntersectionIterator │ │ │ │ │ -IntersectionIterator(const GridGlue *glue, unsigned int i) │ │ │ │ │ -Definition: intersectioniterator.hh:31 │ │ │ │ │ -Dune::GridGlue::IntersectionIterator::equals │ │ │ │ │ -bool equals(const IntersectionIterator &iter) const │ │ │ │ │ -Definition: intersectioniterator.hh:49 │ │ │ │ │ +Dune::GridGlue::BackwardOperator │ │ │ │ │ +CommunicationOperator< Dune::BackwardCommunication > BackwardOperator │ │ │ │ │ +Definition: gridgluecommunicate.hh:264 │ │ │ │ │ +Dune::GridGlue::ForwardOperator │ │ │ │ │ +CommunicationOperator< Dune::ForwardCommunication > ForwardOperator │ │ │ │ │ +Definition: gridgluecommunicate.hh:263 │ │ │ │ │ +Dune::GridGlue::RankPair │ │ │ │ │ +std::pair< int, int > RankPair │ │ │ │ │ +Definition: gridgluecommunicate.hh:24 │ │ │ │ │ +Dune::GridGlue::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &os, const GlobalId &id) │ │ │ │ │ +Definition: gridgluecommunicate.hh:55 │ │ │ │ │ +Dune::GridGlue::Intersection │ │ │ │ │ +The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ +Definition: intersection.hh:261 │ │ │ │ │ +Dune::GridGlue::Intersection::flip │ │ │ │ │ +Intersection< P0, P1, O, I > flip() const │ │ │ │ │ +Return a copy of the intersection with inside and outside switched. │ │ │ │ │ +Definition: intersection.hh:483 │ │ │ │ │ +Dune::GridGlue::Intersection::self │ │ │ │ │ +bool self() const │ │ │ │ │ +For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ +Definition: intersection.hh:393 │ │ │ │ │ +Dune::GridGlue::Intersection::inside │ │ │ │ │ +InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the inside of this intersection. │ │ │ │ │ +Definition: intersection.hh:319 │ │ │ │ │ +Dune::GridGlue::Intersection::neighbor │ │ │ │ │ +size_t neighbor(unsigned int g=0) const │ │ │ │ │ +Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ +Definition: intersection.hh:399 │ │ │ │ │ +Dune::GridGlue::Intersection::outside │ │ │ │ │ +OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the outside of this intersection. │ │ │ │ │ +Definition: intersection.hh:328 │ │ │ │ │ +Dune::GridGlue::GlobalId │ │ │ │ │ +Definition: gridgluecommunicate.hh:26 │ │ │ │ │ +Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ +GlobalId(int i) │ │ │ │ │ +Definition: gridgluecommunicate.hh:38 │ │ │ │ │ +Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ +GlobalId() │ │ │ │ │ +Definition: gridgluecommunicate.hh:30 │ │ │ │ │ +Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ +GlobalId(int i, int j, unsigned int n) │ │ │ │ │ +Definition: gridgluecommunicate.hh:48 │ │ │ │ │ +Dune::GridGlue::CommDataHandle │ │ │ │ │ +describes the features of a data handle for communication in parallel runs │ │ │ │ │ +using the GridGlue::commun... │ │ │ │ │ +Definition: gridgluecommunicate.hh:77 │ │ │ │ │ +Dune::GridGlue::CommDataHandle::size │ │ │ │ │ +size_t size(RISType &i) const │ │ │ │ │ +Definition: gridgluecommunicate.hh:92 │ │ │ │ │ +Dune::GridGlue::CommDataHandle::scatter │ │ │ │ │ +void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, │ │ │ │ │ +size_t n) │ │ │ │ │ +Definition: gridgluecommunicate.hh:118 │ │ │ │ │ +Dune::GridGlue::CommDataHandle::gather │ │ │ │ │ +void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) │ │ │ │ │ +const │ │ │ │ │ +pack data from user to message buffer │ │ │ │ │ +Definition: gridgluecommunicate.hh:104 │ │ │ │ │ +Dune::GridGlue::CommDataHandle::DataType │ │ │ │ │ +DataTypeImp DataType │ │ │ │ │ +data type of data to communicate │ │ │ │ │ +Definition: gridgluecommunicate.hh:80 │ │ │ │ │ +Dune::GridGlue::CommDataHandle::CommDataHandle │ │ │ │ │ +CommDataHandle() │ │ │ │ │ +Definition: gridgluecommunicate.hh:84 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer │ │ │ │ │ +Definition: gridgluecommunicate.hh:141 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::j │ │ │ │ │ +size_t j │ │ │ │ │ +Definition: gridgluecommunicate.hh:183 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::StreamingMessageBuffer │ │ │ │ │ +StreamingMessageBuffer(DT *p) │ │ │ │ │ +Definition: gridgluecommunicate.hh:146 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::a │ │ │ │ │ +DT * a │ │ │ │ │ +Definition: gridgluecommunicate.hh:181 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::counter │ │ │ │ │ +size_t counter() const │ │ │ │ │ +Definition: gridgluecommunicate.hh:169 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::write │ │ │ │ │ +void write(const Y &data) │ │ │ │ │ +Definition: gridgluecommunicate.hh:155 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::read │ │ │ │ │ +void read(Y &data) const │ │ │ │ │ +Definition: gridgluecommunicate.hh:163 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::value_type │ │ │ │ │ +DT value_type │ │ │ │ │ +Definition: gridgluecommunicate.hh:143 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::i │ │ │ │ │ +size_t i │ │ │ │ │ +Definition: gridgluecommunicate.hh:182 │ │ │ │ │ +Dune::GridGlue::StreamingMessageBuffer::clear │ │ │ │ │ +void clear() │ │ │ │ │ +Definition: gridgluecommunicate.hh:171 │ │ │ │ │ +Dune::GridGlue::CommunicationOperator │ │ │ │ │ +forward gather scatter to user defined CommInfo class │ │ │ │ │ +Definition: gridgluecommunicate.hh:194 │ │ │ │ │ +Dune::GridGlue::CommunicationOperator::scatter │ │ │ │ │ +static void scatter(CommInfo &commInfo, const typename CommInfo::DataType &v, │ │ │ │ │ +std::size_t i, std::size_t j=0) │ │ │ │ │ +Definition: gridgluecommunicate.hh:227 │ │ │ │ │ +Dune::GridGlue::CommunicationOperator::gather │ │ │ │ │ +static const CommInfo::DataType & gather(const CommInfo &commInfo, size_t i, │ │ │ │ │ +size_t j=0) │ │ │ │ │ +Definition: gridgluecommunicate.hh:197 │ │ │ │ │ +Dune::GridGlue::CommInfo │ │ │ │ │ +collects all GridGlue data requried for communication │ │ │ │ │ +Definition: gridgluecommunicate.hh:272 │ │ │ │ │ +Dune::GridGlue::CommInfo::dir │ │ │ │ │ +Dune::CommunicationDirection dir │ │ │ │ │ +Definition: gridgluecommunicate.hh:288 │ │ │ │ │ +Dune::GridGlue::CommInfo::value_type │ │ │ │ │ +DataTypeImp value_type │ │ │ │ │ +Definition: gridgluecommunicate.hh:273 │ │ │ │ │ +Dune::GridGlue::CommInfo::DataType │ │ │ │ │ +DataTypeImp DataType │ │ │ │ │ +Definition: gridgluecommunicate.hh:275 │ │ │ │ │ +Dune::GridGlue::CommInfo::data │ │ │ │ │ +::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data │ │ │ │ │ +Definition: gridgluecommunicate.hh:282 │ │ │ │ │ +Dune::GridGlue::CommInfo::GridGlue │ │ │ │ │ +GG GridGlue │ │ │ │ │ +Definition: gridgluecommunicate.hh:274 │ │ │ │ │ +Dune::GridGlue::CommInfo::currentsize │ │ │ │ │ +size_t currentsize │ │ │ │ │ +Definition: gridgluecommunicate.hh:287 │ │ │ │ │ +Dune::GridGlue::CommInfo::CommInfo │ │ │ │ │ +CommInfo() │ │ │ │ │ +Definition: gridgluecommunicate.hh:277 │ │ │ │ │ +Dune::GridGlue::CommInfo::mbuffer │ │ │ │ │ +mutable ::Dune::GridGlue::StreamingMessageBuffer< DataType > mbuffer │ │ │ │ │ +Definition: gridgluecommunicate.hh:286 │ │ │ │ │ +Dune::GridGlue::CommInfo::gridglue │ │ │ │ │ +const GridGlue * gridglue │ │ │ │ │ +Definition: gridgluecommunicate.hh:281 │ │ │ │ │ +Dune::GridGlue::CommInfo::buffer │ │ │ │ │ +std::vector< DataType > buffer │ │ │ │ │ +Definition: gridgluecommunicate.hh:285 │ │ │ │ │ +Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +>::getSize │ │ │ │ │ +static size_t getSize(const Type &commInfo, size_t i) │ │ │ │ │ +Get the number of objects at an intersection. │ │ │ │ │ +Definition: gridgluecommunicate.hh:320 │ │ │ │ │ +Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +>::IndexedType │ │ │ │ │ +DataTypeImp IndexedType │ │ │ │ │ +The datatype that should be communicated. │ │ │ │ │ +Definition: gridgluecommunicate.hh:309 │ │ │ │ │ +Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +>::Type │ │ │ │ │ +::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Type │ │ │ │ │ +The type of the GridGlueCommInfo. │ │ │ │ │ +Definition: gridgluecommunicate.hh:304 │ │ │ │ │ +Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ +>::IndexedTypeFlag │ │ │ │ │ +VariableSize IndexedTypeFlag │ │ │ │ │ +Each intersection can communicate a different number of objects. │ │ │ │ │ +Definition: gridgluecommunicate.hh:315 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridglue.cc File Reference │ │ │ │ +dune-grid-glue: rangegenerators.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,38 +63,42 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
gridglue.cc File Reference
│ │ │ │ +
rangegenerators.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include "intersection.hh"
│ │ │ │ -#include <vector>
│ │ │ │ -#include <iterator>
│ │ │ │ -#include "../gridglue.hh"
│ │ │ │ -#include "../common/ringcomm.hh"
│ │ │ │ -#include <dune/common/unused.hh>
│ │ │ │ -
│ │ │ │ +
#include <dune/common/iteratorrange.hh>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::GridGlue::Reverse< reverse >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename T >
void Dune::GridGlue::printVector (const std::vector< T > &v, std::string name, int rank)
 
template<... >
IteratorRange<... > Dune::GridGlue::intersections (const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
 Iterate over all intersections of a GridGlue. More...
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,28 +5,28 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -gridglue.cc File Reference │ │ │ │ │ -#include "intersection.hh" │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "../gridglue.hh" │ │ │ │ │ -#include "../common/ringcomm.hh" │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +rangegenerators.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::GridGlue::Reverse<_reverse_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::printVector (const std::vector< T > &v, std::string name, │ │ │ │ │ - int rank) │ │ │ │ │ +template<... > │ │ │ │ │ +IteratorRange<... > Dune::GridGlue::intersections (const GridGlue<... > &glue, │ │ │ │ │ + const Reverse<... > &reverse=!reversed) │ │ │ │ │ +  Iterate over all intersections of a GridGlue. More... │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluecommunicate.hh File Reference │ │ │ │ +dune-grid-glue: intersectioniterator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,73 +64,39 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
│ │ │ │ -
gridgluecommunicate.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
intersectioniterator.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ +

Implement iterators over GridGlue intersections. │ │ │ │ More...

│ │ │ │ -
#include <type_traits>
│ │ │ │ -#include <dune/common/bartonnackmanifcheck.hh>
│ │ │ │ -#include <dune/common/parallel/communicator.hh>
│ │ │ │ -#include <dune/grid/common/datahandleif.hh>
│ │ │ │ -#include <dune/grid/common/gridenums.hh>
│ │ │ │ +
#include <dune/grid-glue/gridglue.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::GridGlue::GlobalId
 
class  Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp >
 describes the features of a data handle for communication in parallel runs using the GridGlue::communicate methods. More...
 
class  Dune::GridGlue::StreamingMessageBuffer< DT >
 
class  Dune::GridGlue::CommunicationOperator< dir >
 forward gather scatter to user defined CommInfo class More...
 
struct  Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp >
 collects all GridGlue data requried for communication More...
 
struct  Dune::CommPolicy< ::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > >
 specialization of the CommPolicy struct, required for the ParallelIndexsets More...
class  Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Typedefs

typedef std::pair< int, int > Dune::GridGlue::RankPair
 
typedef CommunicationOperator< Dune::ForwardCommunication > Dune::GridGlue::ForwardOperator
 
typedef CommunicationOperator< Dune::BackwardCommunication > Dune::GridGlue::BackwardOperator
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

std::ostream & Dune::GridGlue::operator<< (std::ostream &os, const GlobalId &id)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Describes the parallel communication interface class for Dune::GridGlue.

│ │ │ │ +

Implement iterators over GridGlue intersections.

│ │ │ │
Author
Christian Engwer
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,62 +5,27 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -gridgluecommunicate.hh File Reference │ │ │ │ │ -Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +intersectioniterator.hh File Reference │ │ │ │ │ +Implement iterators over GridGlue intersections. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::GridGlue::GlobalId │ │ │ │ │ -  │ │ │ │ │ - class  Dune::GridGlue::CommDataHandle<_DataHandleImp,_DataTypeImp_> │ │ │ │ │ -  describes the features of a data handle for communication in parallel │ │ │ │ │ - runs using the GridGlue::communicate methods. More... │ │ │ │ │ -  │ │ │ │ │ - class  Dune::GridGlue::StreamingMessageBuffer<_DT_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::GridGlue::CommunicationOperator<_dir_> │ │ │ │ │ -  forward gather scatter to user defined CommInfo class More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ -  collects all GridGlue data requried for communication More... │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp, │ │ │ │ │ - DataTypeImp_>_> │ │ │ │ │ -  specialization of the CommPolicy struct, required for the │ │ │ │ │ - ParallelIndexsets More... │ │ │ │ │ +class  Dune::GridGlue::IntersectionIterator<_P0,_P1,_inside,_outside_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ - Typedefs │ │ │ │ │ - typedef std::pair< int, int > Dune::GridGlue::RankPair │ │ │ │ │ -  │ │ │ │ │ -typedef CommunicationOperator< Dune:: │ │ │ │ │ - ForwardCommunication > Dune::GridGlue::ForwardOperator │ │ │ │ │ -  │ │ │ │ │ -typedef CommunicationOperator< Dune:: │ │ │ │ │ - BackwardCommunication > Dune::GridGlue::BackwardOperator │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ -std::ostream & Dune::GridGlue::operator<< (std::ostream &os, const GlobalId │ │ │ │ │ - &id) │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ +Implement iterators over GridGlue intersections. │ │ │ │ │ Author │ │ │ │ │ Christian Engwer │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluecommunicate.hh Source File │ │ │ │ +dune-grid-glue: intersectioniterator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,323 +62,85 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
gridgluecommunicate.hh
│ │ │ │ +
intersectioniterator.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
5#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ -
6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ -
7
│ │ │ │ -
13#include <type_traits>
│ │ │ │ +
12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ +
13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │
14
│ │ │ │ -
15#include <dune/common/bartonnackmanifcheck.hh>
│ │ │ │ -
16#include <dune/common/parallel/communicator.hh>
│ │ │ │ -
17#include <dune/grid/common/datahandleif.hh>
│ │ │ │ -
18#include <dune/grid/common/gridenums.hh>
│ │ │ │ + │ │ │ │ +
16
│ │ │ │ +
17namespace Dune {
│ │ │ │ +
18 namespace GridGlue {
│ │ │ │
19
│ │ │ │ -
20
│ │ │ │ -
21namespace Dune {
│ │ │ │ -
22 namespace GridGlue {
│ │ │ │ -
23
│ │ │ │ -
24 typedef std::pair<int, int> RankPair;
│ │ │ │ -
25 struct GlobalId : public std::pair<RankPair, unsigned int>
│ │ │ │ -
26 {
│ │ │ │ - │ │ │ │ -
31 this->first.first = 0;
│ │ │ │ -
32 this->first.second = 0;
│ │ │ │ -
33 this->second = 0;
│ │ │ │ -
34 }
│ │ │ │ -
38 GlobalId(int i) {
│ │ │ │ -
39 this->first.first = i;
│ │ │ │ -
40 this->first.second = i;
│ │ │ │ -
41 this->second = 0;
│ │ │ │ +
21 template<typename P0, typename P1, int inside, int outside>
│ │ │ │ + │ │ │ │ +
23 public Dune::ForwardIteratorFacade< IntersectionIterator<P0,P1,inside,outside>,
│ │ │ │ +
24 const Intersection<P0,P1,inside,outside> >
│ │ │ │ +
25 {
│ │ │ │ +
26 public:
│ │ │ │ +
27
│ │ │ │ +
28 typedef ::Dune::GridGlue::GridGlue<P0, P1> GridGlue;
│ │ │ │ +
29 typedef ::Dune::GridGlue::Intersection<P0,P1,inside,outside> Intersection;
│ │ │ │ +
30
│ │ │ │ +
31 IntersectionIterator(const GridGlue * glue, unsigned int i)
│ │ │ │ +
32 : glue_(glue),
│ │ │ │ +
33 index_(i),
│ │ │ │ +
34 intersection_(glue_, & glue_->intersections_[index_])
│ │ │ │ +
35 {}
│ │ │ │ +
36
│ │ │ │ + │ │ │ │ +
38 {
│ │ │ │ +
39 assert(("never dereference the end iterator" &&
│ │ │ │ +
40 index_ != glue_->index__sz));
│ │ │ │ +
41 return intersection_;
│ │ │ │
42 }
│ │ │ │ -
48 GlobalId(int i, int j, unsigned int n) {
│ │ │ │ -
49 this->first.first = std::min(i,j);
│ │ │ │ -
50 this->first.second = std::max(i,j);
│ │ │ │ -
51 this->second = n;
│ │ │ │ +
43
│ │ │ │ +
44 void increment()
│ │ │ │ +
45 {
│ │ │ │ +
46 intersection_ = Intersection(glue_, & glue_->intersections_[++index_]);
│ │ │ │ +
47 }
│ │ │ │ +
48
│ │ │ │ +
49 bool equals(const IntersectionIterator& iter) const
│ │ │ │ +
50 {
│ │ │ │ +
51 return iter.index_ == index_;
│ │ │ │
52 }
│ │ │ │ -
53 };
│ │ │ │ -
54
│ │ │ │ -
55 inline std::ostream& operator<<(std::ostream& os, const GlobalId & id)
│ │ │ │ -
56 {
│ │ │ │ -
57 os << "("
│ │ │ │ -
58 << id.first.first << "," << id.first.second << ","
│ │ │ │ -
59 << id.second << ")";
│ │ │ │ -
60 return os;
│ │ │ │ -
61 }
│ │ │ │ -
62
│ │ │ │ -
75 template <class DataHandleImp, class DataTypeImp>
│ │ │ │ - │ │ │ │ -
77 {
│ │ │ │ -
78 public:
│ │ │ │ -
80 typedef DataTypeImp DataType;
│ │ │ │ -
81
│ │ │ │ -
82 protected:
│ │ │ │ -
83 // one should not create an explicit instance of this inteface object
│ │ │ │ - │ │ │ │ -
85
│ │ │ │ -
86 public:
│ │ │ │ -
87
│ │ │ │ -
91 template<class RISType>
│ │ │ │ -
92 size_t size (RISType& i) const
│ │ │ │ -
93 {
│ │ │ │ -
94 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(i)));
│ │ │ │ -
95 return asImp().size(i);
│ │ │ │ -
96 }
│ │ │ │ -
97
│ │ │ │ -
103 template<class MessageBufferImp, class EntityType, class RISType>
│ │ │ │ -
104 void gather (MessageBufferImp& buff, const EntityType& e, const RISType & i) const
│ │ │ │ -
105 {
│ │ │ │ -
106 MessageBufferIF<MessageBufferImp> buffIF(buff);
│ │ │ │ -
107 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e,i)));
│ │ │ │ -
108 }
│ │ │ │ -
109
│ │ │ │ -
117 template<class MessageBufferImp, class EntityType, class RISType>
│ │ │ │ -
118 void scatter (MessageBufferImp& buff, const EntityType& e, const RISType & i, size_t n)
│ │ │ │ -
119 {
│ │ │ │ -
120 MessageBufferIF<MessageBufferImp> buffIF(buff);
│ │ │ │ -
121 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,i,n)));
│ │ │ │ -
122 }
│ │ │ │ -
123
│ │ │ │ -
124 private:
│ │ │ │ -
126 DataHandleImp& asImp () {
│ │ │ │ -
127 return static_cast<DataHandleImp &> (*this);
│ │ │ │ -
128 }
│ │ │ │ -
130 const DataHandleImp& asImp () const
│ │ │ │ -
131 {
│ │ │ │ -
132 return static_cast<const DataHandleImp &>(*this);
│ │ │ │ -
133 }
│ │ │ │ -
134 }; // end class CommDataHandleIF
│ │ │ │ -
135
│ │ │ │ -
140 template<typename DT>
│ │ │ │ - │ │ │ │ -
142 public:
│ │ │ │ -
143 typedef DT value_type;
│ │ │ │ -
144
│ │ │ │ -
145 // Constructor
│ │ │ │ - │ │ │ │ -
147 {
│ │ │ │ -
148 a=p;
│ │ │ │ -
149 i=0;
│ │ │ │ -
150 j=0;
│ │ │ │ -
151 }
│ │ │ │ -
152
│ │ │ │ -
153 // write data to message buffer, acts like a stream !
│ │ │ │ -
154 template<class Y>
│ │ │ │ -
155 void write (const Y& data)
│ │ │ │ -
156 {
│ │ │ │ -
157 static_assert(std::is_same<DT,Y>::value, "DataType mismatch");
│ │ │ │ -
158 a[i++] = data;
│ │ │ │ -
159 }
│ │ │ │ -
160
│ │ │ │ -
161 // read data from message buffer, acts like a stream !
│ │ │ │ -
162 template<class Y>
│ │ │ │ -
163 void read (Y& data) const
│ │ │ │ -
164 {
│ │ │ │ -
165 static_assert(std::is_same<DT,Y>::value, "DataType mismatch");
│ │ │ │ -
166 data = a[j++];
│ │ │ │ -
167 }
│ │ │ │ -
168
│ │ │ │ -
169 size_t counter() const { return i; }
│ │ │ │ -
170
│ │ │ │ -
171 void clear()
│ │ │ │ -
172 {
│ │ │ │ -
173 i = 0;
│ │ │ │ -
174 j = 0;
│ │ │ │ -
175 }
│ │ │ │ -
176
│ │ │ │ -
177 // we need access to these variables in an assertion
│ │ │ │ -
178#ifdef NDEBUG
│ │ │ │ -
179 private:
│ │ │ │ -
180#endif
│ │ │ │ -
181 DT *a;
│ │ │ │ -
182 size_t i;
│ │ │ │ -
183 mutable size_t j;
│ │ │ │ -
184 };
│ │ │ │ -
185
│ │ │ │ -
192 template<int dir>
│ │ │ │ - │ │ │ │ -
194 {
│ │ │ │ -
195 public:
│ │ │ │ -
196 template<class CommInfo>
│ │ │ │ -
197 static const typename CommInfo::DataType& gather(const CommInfo& commInfo, size_t i, size_t j = 0)
│ │ │ │ -
198 {
│ │ │ │ -
199 // get Intersection
│ │ │ │ -
200 typedef typename CommInfo::GridGlue::Intersection Intersection;
│ │ │ │ -
201 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ -
202
│ │ │ │ -
203 // fill buffer if we have a new intersection
│ │ │ │ -
204 if (j == 0)
│ │ │ │ -
205 {
│ │ │ │ -
206 commInfo.mbuffer.clear();
│ │ │ │ -
207 if (dir == Dune::ForwardCommunication)
│ │ │ │ -
208 {
│ │ │ │ -
209 // read from grid0
│ │ │ │ -
210 if(ris.self())
│ │ │ │ -
211 commInfo.data->gather(commInfo.mbuffer, ris.inside(), ris);
│ │ │ │ -
212 }
│ │ │ │ -
213 else // (dir == Dune::BackwardCommunication)
│ │ │ │ -
214 {
│ │ │ │ -
215 // read from grid1
│ │ │ │ -
216 if(ris.neighbor())
│ │ │ │ -
217 commInfo.data->gather(commInfo.mbuffer, ris.outside(), ris.flip());
│ │ │ │ -
218 }
│ │ │ │ -
219 }
│ │ │ │ -
220
│ │ │ │ -
221 // return the j'th value in the buffer
│ │ │ │ -
222 assert(j < commInfo.mbuffer.i);
│ │ │ │ -
223 return commInfo.buffer[j];
│ │ │ │ -
224 }
│ │ │ │ -
225
│ │ │ │ -
226 template<class CommInfo>
│ │ │ │ -
227 static void scatter(CommInfo& commInfo, const typename CommInfo::DataType& v, std::size_t i, std::size_t j = 0)
│ │ │ │ -
228 {
│ │ │ │ -
229 // extract GridGlue objects...
│ │ │ │ -
230 typedef typename CommInfo::GridGlue::Intersection Intersection;
│ │ │ │ -
231 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ -
232
│ │ │ │ -
233 // get size if we have a new intersection
│ │ │ │ -
234 if (j == 0)
│ │ │ │ -
235 {
│ │ │ │ -
236 commInfo.mbuffer.clear();
│ │ │ │ -
237 commInfo.currentsize = commInfo.data->size(ris);
│ │ │ │ -
238 }
│ │ │ │ -
239
│ │ │ │ -
240 // write entry to buffer
│ │ │ │ -
241 commInfo.buffer[j] = v;
│ │ │ │ -
242
│ │ │ │ -
243 // write back the buffer if we are at the end of this intersection
│ │ │ │ -
244 if (j == commInfo.currentsize-1)
│ │ │ │ -
245 {
│ │ │ │ -
246 if (dir == Dune::ForwardCommunication)
│ │ │ │ -
247 {
│ │ │ │ -
248 // write to grid1
│ │ │ │ -
249 if(ris.neighbor())
│ │ │ │ -
250 commInfo.data->scatter(commInfo.mbuffer, ris.outside(), ris.flip(), commInfo.currentsize);
│ │ │ │ -
251 }
│ │ │ │ -
252 else // (dir == Dune::BackwardCommunication)
│ │ │ │ -
253 {
│ │ │ │ -
254 // write to grid0
│ │ │ │ -
255 if(ris.self())
│ │ │ │ -
256 commInfo.data->scatter(commInfo.mbuffer, ris.inside(), ris, commInfo.currentsize);
│ │ │ │ -
257 }
│ │ │ │ -
258 assert(commInfo.mbuffer.j <= commInfo.currentsize);
│ │ │ │ -
259 }
│ │ │ │ -
260 }
│ │ │ │ -
261 };
│ │ │ │ -
262
│ │ │ │ - │ │ │ │ - │ │ │ │ -
265
│ │ │ │ -
270 template <typename GG, class DataHandleImp, class DataTypeImp>
│ │ │ │ -
271 struct CommInfo
│ │ │ │ -
272 {
│ │ │ │ -
273 typedef DataTypeImp value_type;
│ │ │ │ -
274 typedef GG GridGlue;
│ │ │ │ -
275 typedef DataTypeImp DataType;
│ │ │ │ -
276
│ │ │ │ - │ │ │ │ -
278 {}
│ │ │ │ -
279
│ │ │ │ -
280 // tunnel information to the policy and the operators
│ │ │ │ - │ │ │ │ - │ │ │ │ -
283
│ │ │ │ -
284 // state variables
│ │ │ │ -
285 std::vector<DataType> buffer;
│ │ │ │ -
286 mutable ::Dune::GridGlue::StreamingMessageBuffer<DataType> mbuffer;
│ │ │ │ - │ │ │ │ -
288 Dune::CommunicationDirection dir;
│ │ │ │ -
289 };
│ │ │ │ -
290
│ │ │ │ -
291 } // end namespace GridGlue
│ │ │ │ -
292
│ │ │ │ -
293#if HAVE_MPI
│ │ │ │ -
298 template<typename GG, class DataHandleImp, class DataTypeImp>
│ │ │ │ -
299 struct CommPolicy< ::Dune::GridGlue::CommInfo<GG, DataHandleImp, DataTypeImp> >
│ │ │ │ -
300 {
│ │ │ │ -
304 typedef ::Dune::GridGlue::CommInfo<GG, DataHandleImp, DataTypeImp> Type;
│ │ │ │ -
305
│ │ │ │ -
309 typedef DataTypeImp IndexedType;
│ │ │ │ -
310
│ │ │ │ -
314 // typedef SizeOne IndexedTypeFlag;
│ │ │ │ -
315 typedef VariableSize IndexedTypeFlag;
│ │ │ │ -
316
│ │ │ │ -
320 static size_t getSize(const Type& commInfo, size_t i)
│ │ │ │ -
321 {
│ │ │ │ -
322 // get Intersection
│ │ │ │ -
323 typedef typename Type::GridGlue::Intersection Intersection;
│ │ │ │ -
324 Intersection ris(commInfo.gridglue->getIntersection(i));
│ │ │ │ -
325
│ │ │ │ -
326 // ask data handle for size
│ │ │ │ -
327 return commInfo.data->size(ris);
│ │ │ │ -
328 }
│ │ │ │ -
329 };
│ │ │ │ -
330#endif
│ │ │ │ -
331
│ │ │ │ -
332} // end namespace Dune
│ │ │ │ -
333#endif
│ │ │ │ +
53
│ │ │ │ +
54 private:
│ │ │ │ +
55
│ │ │ │ +
56 const GridGlue* glue_;
│ │ │ │ +
57 unsigned int index_;
│ │ │ │ +
58
│ │ │ │ +
59 Intersection intersection_;
│ │ │ │ +
60 };
│ │ │ │ +
61
│ │ │ │ +
62 } // end namespace GridGlue
│ │ │ │ +
63} // end namespace Dune
│ │ │ │ +
64
│ │ │ │ +
65#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ +
Central component of the module implementing the coupling of two grids.
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
CommunicationOperator< Dune::BackwardCommunication > BackwardOperator
Definition: gridgluecommunicate.hh:264
│ │ │ │ -
CommunicationOperator< Dune::ForwardCommunication > ForwardOperator
Definition: gridgluecommunicate.hh:263
│ │ │ │ -
std::pair< int, int > RankPair
Definition: gridgluecommunicate.hh:24
│ │ │ │ -
std::ostream & operator<<(std::ostream &os, const GlobalId &id)
Definition: gridgluecommunicate.hh:55
│ │ │ │ -
The intersection of two entities of the two patches of a GridGlue.
Definition: intersection.hh:261
│ │ │ │ -
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition: intersection.hh:483
│ │ │ │ -
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition: intersection.hh:393
│ │ │ │ -
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition: intersection.hh:319
│ │ │ │ -
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition: intersection.hh:399
│ │ │ │ -
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition: intersection.hh:328
│ │ │ │ -
Definition: gridgluecommunicate.hh:26
│ │ │ │ -
GlobalId(int i)
Definition: gridgluecommunicate.hh:38
│ │ │ │ -
GlobalId()
Definition: gridgluecommunicate.hh:30
│ │ │ │ -
GlobalId(int i, int j, unsigned int n)
Definition: gridgluecommunicate.hh:48
│ │ │ │ -
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition: gridgluecommunicate.hh:77
│ │ │ │ -
size_t size(RISType &i) const
Definition: gridgluecommunicate.hh:92
│ │ │ │ -
void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, size_t n)
Definition: gridgluecommunicate.hh:118
│ │ │ │ -
void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) const
pack data from user to message buffer
Definition: gridgluecommunicate.hh:104
│ │ │ │ -
DataTypeImp DataType
data type of data to communicate
Definition: gridgluecommunicate.hh:80
│ │ │ │ -
CommDataHandle()
Definition: gridgluecommunicate.hh:84
│ │ │ │ -
Definition: gridgluecommunicate.hh:141
│ │ │ │ -
size_t j
Definition: gridgluecommunicate.hh:183
│ │ │ │ -
StreamingMessageBuffer(DT *p)
Definition: gridgluecommunicate.hh:146
│ │ │ │ -
DT * a
Definition: gridgluecommunicate.hh:181
│ │ │ │ -
size_t counter() const
Definition: gridgluecommunicate.hh:169
│ │ │ │ -
void write(const Y &data)
Definition: gridgluecommunicate.hh:155
│ │ │ │ -
void read(Y &data) const
Definition: gridgluecommunicate.hh:163
│ │ │ │ -
DT value_type
Definition: gridgluecommunicate.hh:143
│ │ │ │ -
size_t i
Definition: gridgluecommunicate.hh:182
│ │ │ │ -
void clear()
Definition: gridgluecommunicate.hh:171
│ │ │ │ -
forward gather scatter to user defined CommInfo class
Definition: gridgluecommunicate.hh:194
│ │ │ │ -
static void scatter(CommInfo &commInfo, const typename CommInfo::DataType &v, std::size_t i, std::size_t j=0)
Definition: gridgluecommunicate.hh:227
│ │ │ │ -
static const CommInfo::DataType & gather(const CommInfo &commInfo, size_t i, size_t j=0)
Definition: gridgluecommunicate.hh:197
│ │ │ │ -
collects all GridGlue data requried for communication
Definition: gridgluecommunicate.hh:272
│ │ │ │ -
Dune::CommunicationDirection dir
Definition: gridgluecommunicate.hh:288
│ │ │ │ -
DataTypeImp value_type
Definition: gridgluecommunicate.hh:273
│ │ │ │ -
DataTypeImp DataType
Definition: gridgluecommunicate.hh:275
│ │ │ │ -
::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data
Definition: gridgluecommunicate.hh:282
│ │ │ │ -
GG GridGlue
Definition: gridgluecommunicate.hh:274
│ │ │ │ -
size_t currentsize
Definition: gridgluecommunicate.hh:287
│ │ │ │ -
CommInfo()
Definition: gridgluecommunicate.hh:277
│ │ │ │ -
mutable ::Dune::GridGlue::StreamingMessageBuffer< DataType > mbuffer
Definition: gridgluecommunicate.hh:286
│ │ │ │ -
const GridGlue * gridglue
Definition: gridgluecommunicate.hh:281
│ │ │ │ -
std::vector< DataType > buffer
Definition: gridgluecommunicate.hh:285
│ │ │ │ -
static size_t getSize(const Type &commInfo, size_t i)
Get the number of objects at an intersection.
Definition: gridgluecommunicate.hh:320
│ │ │ │ -
DataTypeImp IndexedType
The datatype that should be communicated.
Definition: gridgluecommunicate.hh:309
│ │ │ │ -
::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Type
The type of the GridGlueCommInfo.
Definition: gridgluecommunicate.hh:304
│ │ │ │ -
VariableSize IndexedTypeFlag
Each intersection can communicate a different number of objects.
Definition: gridgluecommunicate.hh:315
│ │ │ │ +
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:67
│ │ │ │ + │ │ │ │ +
Definition: intersectioniterator.hh:25
│ │ │ │ +
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersectioniterator.hh:28
│ │ │ │ +
const Intersection & dereference() const
Definition: intersectioniterator.hh:37
│ │ │ │ +
void increment()
Definition: intersectioniterator.hh:44
│ │ │ │ +
::Dune::GridGlue::Intersection< P0, P1, inside, outside > Intersection
Definition: intersectioniterator.hh:29
│ │ │ │ +
IntersectionIterator(const GridGlue *glue, unsigned int i)
Definition: intersectioniterator.hh:31
│ │ │ │ +
bool equals(const IntersectionIterator &iter) const
Definition: intersectioniterator.hh:49
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,443 +5,100 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -gridgluecommunicate.hh │ │ │ │ │ +intersectioniterator.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 5#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ - 6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ - 7 │ │ │ │ │ - 13#include │ │ │ │ │ + 12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ + 13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ 14 │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17namespace Dune { │ │ │ │ │ + 18 namespace GridGlue { │ │ │ │ │ 19 │ │ │ │ │ - 20 │ │ │ │ │ - 21namespace Dune { │ │ │ │ │ - 22 namespace GridGlue { │ │ │ │ │ - 23 │ │ │ │ │ -24 typedef std::pair RankPair; │ │ │ │ │ -25 struct GlobalId : public std::pair │ │ │ │ │ - 26 { │ │ │ │ │ -30 GlobalId() { │ │ │ │ │ - 31 this->first.first = 0; │ │ │ │ │ - 32 this->first.second = 0; │ │ │ │ │ - 33 this->second = 0; │ │ │ │ │ - 34 } │ │ │ │ │ -38 GlobalId(int i) { │ │ │ │ │ - 39 this->first.first = i; │ │ │ │ │ - 40 this->first.second = i; │ │ │ │ │ - 41 this->second = 0; │ │ │ │ │ + 21 template │ │ │ │ │ +22 class IntersectionIterator : │ │ │ │ │ + 23 public Dune::ForwardIteratorFacade< │ │ │ │ │ +IntersectionIterator, │ │ │ │ │ + 24 const Intersection > │ │ │ │ │ + 25 { │ │ │ │ │ + 26 public: │ │ │ │ │ + 27 │ │ │ │ │ +28 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ +29 typedef ::Dune::GridGlue::Intersection Intersection; │ │ │ │ │ + 30 │ │ │ │ │ +31 IntersectionIterator(const GridGlue * glue, unsigned int i) │ │ │ │ │ + 32 : glue_(glue), │ │ │ │ │ + 33 index_(i), │ │ │ │ │ + 34 intersection_(glue_, & glue_->intersections_[index_]) │ │ │ │ │ + 35 {} │ │ │ │ │ + 36 │ │ │ │ │ +37 const Intersection& dereference() const │ │ │ │ │ + 38 { │ │ │ │ │ + 39 assert(("never dereference the end iterator" && │ │ │ │ │ + 40 index_ != glue_->index__sz)); │ │ │ │ │ + 41 return intersection_; │ │ │ │ │ 42 } │ │ │ │ │ -48 GlobalId(int i, int j, unsigned int n) { │ │ │ │ │ - 49 this->first.first = std::min(i,j); │ │ │ │ │ - 50 this->first.second = std::max(i,j); │ │ │ │ │ - 51 this->second = n; │ │ │ │ │ + 43 │ │ │ │ │ +44 void increment() │ │ │ │ │ + 45 { │ │ │ │ │ + 46 intersection_ = Intersection(glue_, & glue_->intersections_[++index_]); │ │ │ │ │ + 47 } │ │ │ │ │ + 48 │ │ │ │ │ +49 bool equals(const IntersectionIterator& iter) const │ │ │ │ │ + 50 { │ │ │ │ │ + 51 return iter.index_ == index_; │ │ │ │ │ 52 } │ │ │ │ │ - 53 }; │ │ │ │ │ - 54 │ │ │ │ │ -55 inline std::ostream& operator<<(std::ostream& os, const GlobalId & id) │ │ │ │ │ - 56 { │ │ │ │ │ - 57 os << "(" │ │ │ │ │ - 58 << id.first.first << "," << id.first.second << "," │ │ │ │ │ - 59 << id.second << ")"; │ │ │ │ │ - 60 return os; │ │ │ │ │ - 61 } │ │ │ │ │ - 62 │ │ │ │ │ - 75 template │ │ │ │ │ -76 class CommDataHandle │ │ │ │ │ - 77 { │ │ │ │ │ - 78 public: │ │ │ │ │ -80 typedef DataTypeImp DataType; │ │ │ │ │ - 81 │ │ │ │ │ - 82 protected: │ │ │ │ │ - 83 // one should not create an explicit instance of this inteface object │ │ │ │ │ -84 CommDataHandle() {} │ │ │ │ │ - 85 │ │ │ │ │ - 86 public: │ │ │ │ │ - 87 │ │ │ │ │ - 91 template │ │ │ │ │ -92 size_t size (RISType& i) const │ │ │ │ │ - 93 { │ │ │ │ │ - 94 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(i))); │ │ │ │ │ - 95 return asImp().size(i); │ │ │ │ │ - 96 } │ │ │ │ │ - 97 │ │ │ │ │ - 103 template │ │ │ │ │ -104 void gather (MessageBufferImp& buff, const EntityType& e, const RISType & │ │ │ │ │ -i) const │ │ │ │ │ - 105 { │ │ │ │ │ - 106 MessageBufferIF buffIF(buff); │ │ │ │ │ - 107 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().gather(buffIF,e,i))); │ │ │ │ │ - 108 } │ │ │ │ │ - 109 │ │ │ │ │ - 117 template │ │ │ │ │ -118 void scatter (MessageBufferImp& buff, const EntityType& e, const RISType & │ │ │ │ │ -i, size_t n) │ │ │ │ │ - 119 { │ │ │ │ │ - 120 MessageBufferIF buffIF(buff); │ │ │ │ │ - 121 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().scatter(buffIF,e,i,n))); │ │ │ │ │ - 122 } │ │ │ │ │ - 123 │ │ │ │ │ - 124 private: │ │ │ │ │ - 126 DataHandleImp& asImp () { │ │ │ │ │ - 127 return static_cast (*this); │ │ │ │ │ - 128 } │ │ │ │ │ - 130 const DataHandleImp& asImp () const │ │ │ │ │ - 131 { │ │ │ │ │ - 132 return static_cast(*this); │ │ │ │ │ - 133 } │ │ │ │ │ - 134 }; // end class CommDataHandleIF │ │ │ │ │ - 135 │ │ │ │ │ - 140 template │ │ │ │ │ -141 class StreamingMessageBuffer { │ │ │ │ │ - 142 public: │ │ │ │ │ -143 typedef DT value_type; │ │ │ │ │ - 144 │ │ │ │ │ - 145 // Constructor │ │ │ │ │ -146 StreamingMessageBuffer (DT *p) │ │ │ │ │ - 147 { │ │ │ │ │ - 148 a=p; │ │ │ │ │ - 149 i=0; │ │ │ │ │ - 150 j=0; │ │ │ │ │ - 151 } │ │ │ │ │ - 152 │ │ │ │ │ - 153 // write data to message buffer, acts like a stream ! │ │ │ │ │ - 154 template │ │ │ │ │ -155 void write (const Y& data) │ │ │ │ │ - 156 { │ │ │ │ │ - 157 static_assert(std::is_same::value, "DataType mismatch"); │ │ │ │ │ - 158 a[i++] = data; │ │ │ │ │ - 159 } │ │ │ │ │ - 160 │ │ │ │ │ - 161 // read data from message buffer, acts like a stream ! │ │ │ │ │ - 162 template │ │ │ │ │ -163 void read (Y& data) const │ │ │ │ │ - 164 { │ │ │ │ │ - 165 static_assert(std::is_same::value, "DataType mismatch"); │ │ │ │ │ - 166 data = a[j++]; │ │ │ │ │ - 167 } │ │ │ │ │ - 168 │ │ │ │ │ -169 size_t counter() const { return i; } │ │ │ │ │ - 170 │ │ │ │ │ -171 void clear() │ │ │ │ │ - 172 { │ │ │ │ │ - 173 i = 0; │ │ │ │ │ - 174 j = 0; │ │ │ │ │ - 175 } │ │ │ │ │ - 176 │ │ │ │ │ - 177 // we need access to these variables in an assertion │ │ │ │ │ - 178#ifdef NDEBUG │ │ │ │ │ - 179 private: │ │ │ │ │ - 180#endif │ │ │ │ │ -181 DT *a; │ │ │ │ │ -182 size_t i; │ │ │ │ │ -183 mutable size_t j; │ │ │ │ │ - 184 }; │ │ │ │ │ - 185 │ │ │ │ │ - 192 template │ │ │ │ │ -193 class CommunicationOperator │ │ │ │ │ - 194 { │ │ │ │ │ - 195 public: │ │ │ │ │ - 196 template │ │ │ │ │ -197 static const typename CommInfo::DataType& gather(const CommInfo& commInfo, │ │ │ │ │ -size_t i, size_t j = 0) │ │ │ │ │ - 198 { │ │ │ │ │ - 199 // get Intersection │ │ │ │ │ - 200 typedef typename CommInfo::GridGlue::Intersection Intersection; │ │ │ │ │ - 201 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ - 202 │ │ │ │ │ - 203 // fill buffer if we have a new intersection │ │ │ │ │ - 204 if (j == 0) │ │ │ │ │ - 205 { │ │ │ │ │ - 206 commInfo.mbuffer.clear(); │ │ │ │ │ - 207 if (dir == Dune::ForwardCommunication) │ │ │ │ │ - 208 { │ │ │ │ │ - 209 // read from grid0 │ │ │ │ │ - 210 if(ris.self()) │ │ │ │ │ - 211 commInfo.data->gather(commInfo.mbuffer, ris.inside(), ris); │ │ │ │ │ - 212 } │ │ │ │ │ - 213 else // (dir == Dune::BackwardCommunication) │ │ │ │ │ - 214 { │ │ │ │ │ - 215 // read from grid1 │ │ │ │ │ - 216 if(ris.neighbor()) │ │ │ │ │ - 217 commInfo.data->gather(commInfo.mbuffer, ris.outside(), ris.flip()); │ │ │ │ │ - 218 } │ │ │ │ │ - 219 } │ │ │ │ │ - 220 │ │ │ │ │ - 221 // return the j'th value in the buffer │ │ │ │ │ - 222 assert(j < commInfo.mbuffer.i); │ │ │ │ │ - 223 return commInfo.buffer[j]; │ │ │ │ │ - 224 } │ │ │ │ │ - 225 │ │ │ │ │ - 226 template │ │ │ │ │ -227 static void scatter(CommInfo& commInfo, const typename CommInfo::DataType& │ │ │ │ │ -v, std::size_t i, std::size_t j = 0) │ │ │ │ │ - 228 { │ │ │ │ │ - 229 // extract GridGlue objects... │ │ │ │ │ - 230 typedef typename CommInfo::GridGlue::Intersection Intersection; │ │ │ │ │ - 231 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ - 232 │ │ │ │ │ - 233 // get size if we have a new intersection │ │ │ │ │ - 234 if (j == 0) │ │ │ │ │ - 235 { │ │ │ │ │ - 236 commInfo.mbuffer.clear(); │ │ │ │ │ - 237 commInfo.currentsize = commInfo.data->size(ris); │ │ │ │ │ - 238 } │ │ │ │ │ - 239 │ │ │ │ │ - 240 // write entry to buffer │ │ │ │ │ - 241 commInfo.buffer[j] = v; │ │ │ │ │ - 242 │ │ │ │ │ - 243 // write back the buffer if we are at the end of this intersection │ │ │ │ │ - 244 if (j == commInfo.currentsize-1) │ │ │ │ │ - 245 { │ │ │ │ │ - 246 if (dir == Dune::ForwardCommunication) │ │ │ │ │ - 247 { │ │ │ │ │ - 248 // write to grid1 │ │ │ │ │ - 249 if(ris.neighbor()) │ │ │ │ │ - 250 commInfo.data->scatter(commInfo.mbuffer, ris.outside(), ris.flip(), │ │ │ │ │ -commInfo.currentsize); │ │ │ │ │ - 251 } │ │ │ │ │ - 252 else // (dir == Dune::BackwardCommunication) │ │ │ │ │ - 253 { │ │ │ │ │ - 254 // write to grid0 │ │ │ │ │ - 255 if(ris.self()) │ │ │ │ │ - 256 commInfo.data->scatter(commInfo.mbuffer, ris.inside(), ris, │ │ │ │ │ -commInfo.currentsize); │ │ │ │ │ - 257 } │ │ │ │ │ - 258 assert(commInfo.mbuffer.j <= commInfo.currentsize); │ │ │ │ │ - 259 } │ │ │ │ │ - 260 } │ │ │ │ │ - 261 }; │ │ │ │ │ - 262 │ │ │ │ │ -263 typedef CommunicationOperator ForwardOperator; │ │ │ │ │ -264 typedef CommunicationOperator │ │ │ │ │ -BackwardOperator; │ │ │ │ │ - 265 │ │ │ │ │ - 270 template │ │ │ │ │ -271 struct CommInfo │ │ │ │ │ - 272 { │ │ │ │ │ -273 typedef DataTypeImp value_type; │ │ │ │ │ -274 typedef GG GridGlue; │ │ │ │ │ -275 typedef DataTypeImp DataType; │ │ │ │ │ - 276 │ │ │ │ │ -277 CommInfo() : buffer(100), mbuffer(&buffer[0]) │ │ │ │ │ - 278 {} │ │ │ │ │ - 279 │ │ │ │ │ - 280 // tunnel information to the policy and the operators │ │ │ │ │ -281 const GridGlue * gridglue; │ │ │ │ │ -282 ::Dune::GridGlue::CommDataHandle * data; │ │ │ │ │ - 283 │ │ │ │ │ - 284 // state variables │ │ │ │ │ -285 std::vector buffer; │ │ │ │ │ -286 mutable ::Dune::GridGlue::StreamingMessageBuffer mbuffer; │ │ │ │ │ -287 size_t currentsize; │ │ │ │ │ -288 Dune::CommunicationDirection dir; │ │ │ │ │ - 289 }; │ │ │ │ │ - 290 │ │ │ │ │ - 291 } // end namespace GridGlue │ │ │ │ │ - 292 │ │ │ │ │ - 293#if HAVE_MPI │ │ │ │ │ - 298 template │ │ │ │ │ -299 struct CommPolicy< ::Dune::GridGlue::CommInfo > │ │ │ │ │ - 300 { │ │ │ │ │ -304 typedef ::Dune::GridGlue::CommInfo Type; │ │ │ │ │ - 305 │ │ │ │ │ -309 typedef DataTypeImp IndexedType; │ │ │ │ │ - 310 │ │ │ │ │ - 314 // typedef SizeOne IndexedTypeFlag; │ │ │ │ │ -315 typedef VariableSize IndexedTypeFlag; │ │ │ │ │ - 316 │ │ │ │ │ -320 static size_t getSize(const Type& commInfo, size_t i) │ │ │ │ │ - 321 { │ │ │ │ │ - 322 // get Intersection │ │ │ │ │ - 323 typedef typename Type::GridGlue::Intersection Intersection; │ │ │ │ │ - 324 Intersection ris(commInfo.gridglue->getIntersection(i)); │ │ │ │ │ - 325 │ │ │ │ │ - 326 // ask data handle for size │ │ │ │ │ - 327 return commInfo.data->size(ris); │ │ │ │ │ - 328 } │ │ │ │ │ - 329 }; │ │ │ │ │ - 330#endif │ │ │ │ │ - 331 │ │ │ │ │ - 332} // end namespace Dune │ │ │ │ │ - 333#endif │ │ │ │ │ + 53 │ │ │ │ │ + 54 private: │ │ │ │ │ + 55 │ │ │ │ │ + 56 const GridGlue* glue_; │ │ │ │ │ + 57 unsigned int index_; │ │ │ │ │ + 58 │ │ │ │ │ + 59 Intersection intersection_; │ │ │ │ │ + 60 }; │ │ │ │ │ + 61 │ │ │ │ │ + 62 } // end namespace GridGlue │ │ │ │ │ + 63} // end namespace Dune │ │ │ │ │ + 64 │ │ │ │ │ + 65#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ +gridglue.hh │ │ │ │ │ +Central component of the module implementing the coupling of two grids. │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::BackwardOperator │ │ │ │ │ -CommunicationOperator< Dune::BackwardCommunication > BackwardOperator │ │ │ │ │ -Definition: gridgluecommunicate.hh:264 │ │ │ │ │ -Dune::GridGlue::ForwardOperator │ │ │ │ │ -CommunicationOperator< Dune::ForwardCommunication > ForwardOperator │ │ │ │ │ -Definition: gridgluecommunicate.hh:263 │ │ │ │ │ -Dune::GridGlue::RankPair │ │ │ │ │ -std::pair< int, int > RankPair │ │ │ │ │ -Definition: gridgluecommunicate.hh:24 │ │ │ │ │ -Dune::GridGlue::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &os, const GlobalId &id) │ │ │ │ │ -Definition: gridgluecommunicate.hh:55 │ │ │ │ │ -Dune::GridGlue::Intersection │ │ │ │ │ -The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ -Definition: intersection.hh:261 │ │ │ │ │ -Dune::GridGlue::Intersection::flip │ │ │ │ │ -Intersection< P0, P1, O, I > flip() const │ │ │ │ │ -Return a copy of the intersection with inside and outside switched. │ │ │ │ │ -Definition: intersection.hh:483 │ │ │ │ │ -Dune::GridGlue::Intersection::self │ │ │ │ │ -bool self() const │ │ │ │ │ -For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ -Definition: intersection.hh:393 │ │ │ │ │ -Dune::GridGlue::Intersection::inside │ │ │ │ │ -InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the inside of this intersection. │ │ │ │ │ -Definition: intersection.hh:319 │ │ │ │ │ -Dune::GridGlue::Intersection::neighbor │ │ │ │ │ -size_t neighbor(unsigned int g=0) const │ │ │ │ │ -Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ -Definition: intersection.hh:399 │ │ │ │ │ -Dune::GridGlue::Intersection::outside │ │ │ │ │ -OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the outside of this intersection. │ │ │ │ │ -Definition: intersection.hh:328 │ │ │ │ │ -Dune::GridGlue::GlobalId │ │ │ │ │ -Definition: gridgluecommunicate.hh:26 │ │ │ │ │ -Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ -GlobalId(int i) │ │ │ │ │ -Definition: gridgluecommunicate.hh:38 │ │ │ │ │ -Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ -GlobalId() │ │ │ │ │ -Definition: gridgluecommunicate.hh:30 │ │ │ │ │ -Dune::GridGlue::GlobalId::GlobalId │ │ │ │ │ -GlobalId(int i, int j, unsigned int n) │ │ │ │ │ -Definition: gridgluecommunicate.hh:48 │ │ │ │ │ -Dune::GridGlue::CommDataHandle │ │ │ │ │ -describes the features of a data handle for communication in parallel runs │ │ │ │ │ -using the GridGlue::commun... │ │ │ │ │ -Definition: gridgluecommunicate.hh:77 │ │ │ │ │ -Dune::GridGlue::CommDataHandle::size │ │ │ │ │ -size_t size(RISType &i) const │ │ │ │ │ -Definition: gridgluecommunicate.hh:92 │ │ │ │ │ -Dune::GridGlue::CommDataHandle::scatter │ │ │ │ │ -void scatter(MessageBufferImp &buff, const EntityType &e, const RISType &i, │ │ │ │ │ -size_t n) │ │ │ │ │ -Definition: gridgluecommunicate.hh:118 │ │ │ │ │ -Dune::GridGlue::CommDataHandle::gather │ │ │ │ │ -void gather(MessageBufferImp &buff, const EntityType &e, const RISType &i) │ │ │ │ │ -const │ │ │ │ │ -pack data from user to message buffer │ │ │ │ │ -Definition: gridgluecommunicate.hh:104 │ │ │ │ │ -Dune::GridGlue::CommDataHandle::DataType │ │ │ │ │ -DataTypeImp DataType │ │ │ │ │ -data type of data to communicate │ │ │ │ │ -Definition: gridgluecommunicate.hh:80 │ │ │ │ │ -Dune::GridGlue::CommDataHandle::CommDataHandle │ │ │ │ │ -CommDataHandle() │ │ │ │ │ -Definition: gridgluecommunicate.hh:84 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer │ │ │ │ │ -Definition: gridgluecommunicate.hh:141 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::j │ │ │ │ │ -size_t j │ │ │ │ │ -Definition: gridgluecommunicate.hh:183 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::StreamingMessageBuffer │ │ │ │ │ -StreamingMessageBuffer(DT *p) │ │ │ │ │ -Definition: gridgluecommunicate.hh:146 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::a │ │ │ │ │ -DT * a │ │ │ │ │ -Definition: gridgluecommunicate.hh:181 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::counter │ │ │ │ │ -size_t counter() const │ │ │ │ │ -Definition: gridgluecommunicate.hh:169 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::write │ │ │ │ │ -void write(const Y &data) │ │ │ │ │ -Definition: gridgluecommunicate.hh:155 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::read │ │ │ │ │ -void read(Y &data) const │ │ │ │ │ -Definition: gridgluecommunicate.hh:163 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::value_type │ │ │ │ │ -DT value_type │ │ │ │ │ -Definition: gridgluecommunicate.hh:143 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::i │ │ │ │ │ -size_t i │ │ │ │ │ -Definition: gridgluecommunicate.hh:182 │ │ │ │ │ -Dune::GridGlue::StreamingMessageBuffer::clear │ │ │ │ │ -void clear() │ │ │ │ │ -Definition: gridgluecommunicate.hh:171 │ │ │ │ │ -Dune::GridGlue::CommunicationOperator │ │ │ │ │ -forward gather scatter to user defined CommInfo class │ │ │ │ │ -Definition: gridgluecommunicate.hh:194 │ │ │ │ │ -Dune::GridGlue::CommunicationOperator::scatter │ │ │ │ │ -static void scatter(CommInfo &commInfo, const typename CommInfo::DataType &v, │ │ │ │ │ -std::size_t i, std::size_t j=0) │ │ │ │ │ -Definition: gridgluecommunicate.hh:227 │ │ │ │ │ -Dune::GridGlue::CommunicationOperator::gather │ │ │ │ │ -static const CommInfo::DataType & gather(const CommInfo &commInfo, size_t i, │ │ │ │ │ -size_t j=0) │ │ │ │ │ -Definition: gridgluecommunicate.hh:197 │ │ │ │ │ -Dune::GridGlue::CommInfo │ │ │ │ │ -collects all GridGlue data requried for communication │ │ │ │ │ -Definition: gridgluecommunicate.hh:272 │ │ │ │ │ -Dune::GridGlue::CommInfo::dir │ │ │ │ │ -Dune::CommunicationDirection dir │ │ │ │ │ -Definition: gridgluecommunicate.hh:288 │ │ │ │ │ -Dune::GridGlue::CommInfo::value_type │ │ │ │ │ -DataTypeImp value_type │ │ │ │ │ -Definition: gridgluecommunicate.hh:273 │ │ │ │ │ -Dune::GridGlue::CommInfo::DataType │ │ │ │ │ -DataTypeImp DataType │ │ │ │ │ -Definition: gridgluecommunicate.hh:275 │ │ │ │ │ -Dune::GridGlue::CommInfo::data │ │ │ │ │ -::Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > * data │ │ │ │ │ -Definition: gridgluecommunicate.hh:282 │ │ │ │ │ -Dune::GridGlue::CommInfo::GridGlue │ │ │ │ │ -GG GridGlue │ │ │ │ │ -Definition: gridgluecommunicate.hh:274 │ │ │ │ │ -Dune::GridGlue::CommInfo::currentsize │ │ │ │ │ -size_t currentsize │ │ │ │ │ -Definition: gridgluecommunicate.hh:287 │ │ │ │ │ -Dune::GridGlue::CommInfo::CommInfo │ │ │ │ │ -CommInfo() │ │ │ │ │ -Definition: gridgluecommunicate.hh:277 │ │ │ │ │ -Dune::GridGlue::CommInfo::mbuffer │ │ │ │ │ -mutable ::Dune::GridGlue::StreamingMessageBuffer< DataType > mbuffer │ │ │ │ │ -Definition: gridgluecommunicate.hh:286 │ │ │ │ │ -Dune::GridGlue::CommInfo::gridglue │ │ │ │ │ -const GridGlue * gridglue │ │ │ │ │ -Definition: gridgluecommunicate.hh:281 │ │ │ │ │ -Dune::GridGlue::CommInfo::buffer │ │ │ │ │ -std::vector< DataType > buffer │ │ │ │ │ -Definition: gridgluecommunicate.hh:285 │ │ │ │ │ -Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ ->::getSize │ │ │ │ │ -static size_t getSize(const Type &commInfo, size_t i) │ │ │ │ │ -Get the number of objects at an intersection. │ │ │ │ │ -Definition: gridgluecommunicate.hh:320 │ │ │ │ │ -Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ ->::IndexedType │ │ │ │ │ -DataTypeImp IndexedType │ │ │ │ │ -The datatype that should be communicated. │ │ │ │ │ -Definition: gridgluecommunicate.hh:309 │ │ │ │ │ -Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ ->::Type │ │ │ │ │ -::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Type │ │ │ │ │ -The type of the GridGlueCommInfo. │ │ │ │ │ -Definition: gridgluecommunicate.hh:304 │ │ │ │ │ -Dune::CommPolicy<_::Dune::GridGlue::CommInfo<_GG,_DataHandleImp,_DataTypeImp_> │ │ │ │ │ ->::IndexedTypeFlag │ │ │ │ │ -VariableSize IndexedTypeFlag │ │ │ │ │ -Each intersection can communicate a different number of objects. │ │ │ │ │ -Definition: gridgluecommunicate.hh:315 │ │ │ │ │ +Dune::GridGlue::GridGlue │ │ │ │ │ +sequential adapter to couple two grids at specified close together boundaries │ │ │ │ │ +Definition: gridglue.hh:67 │ │ │ │ │ +Dune::GridGlue::Intersection<_P0,_P1,_inside,_outside_> │ │ │ │ │ +Dune::GridGlue::IntersectionIterator │ │ │ │ │ +Definition: intersectioniterator.hh:25 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::GridGlue │ │ │ │ │ +::Dune::GridGlue::GridGlue< P0, P1 > GridGlue │ │ │ │ │ +Definition: intersectioniterator.hh:28 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::dereference │ │ │ │ │ +const Intersection & dereference() const │ │ │ │ │ +Definition: intersectioniterator.hh:37 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Definition: intersectioniterator.hh:44 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::Intersection │ │ │ │ │ +::Dune::GridGlue::Intersection< P0, P1, inside, outside > Intersection │ │ │ │ │ +Definition: intersectioniterator.hh:29 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::IntersectionIterator │ │ │ │ │ +IntersectionIterator(const GridGlue *glue, unsigned int i) │ │ │ │ │ +Definition: intersectioniterator.hh:31 │ │ │ │ │ +Dune::GridGlue::IntersectionIterator::equals │ │ │ │ │ +bool equals(const IntersectionIterator &iter) const │ │ │ │ │ +Definition: intersectioniterator.hh:49 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: rangegenerators.hh File Reference │ │ │ │ +dune-grid-glue: gridglueamirawriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,42 +64,42 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
rangegenerators.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
gridglueamirawriter.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/common/iteratorrange.hh>
│ │ │ │ + │ │ │ │ +

Write all remote intersections to a AmiraMesh file. │ │ │ │ +More...

│ │ │ │ +
#include <fstream>
│ │ │ │ +#include <sstream>
│ │ │ │ +#include <type_traits>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::GridGlue::Reverse< reverse >
class  Dune::GridGlue::GridGlueAmiraWriter
 Write remote intersections to a AmiraMesh file for debugging purposes. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<... >
IteratorRange<... > Dune::GridGlue::intersections (const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
 Iterate over all intersections of a GridGlue. More...
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Write all remote intersections to a AmiraMesh file.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,28 +5,29 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -rangegenerators.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +gridglueamirawriter.hh File Reference │ │ │ │ │ +Write all remote intersections to a AmiraMesh file. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct  Dune::GridGlue::Reverse<_reverse_> │ │ │ │ │ +class  Dune::GridGlue::GridGlueAmiraWriter │ │ │ │ │ +  Write remote intersections to a AmiraMesh file for debugging purposes. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template<... > │ │ │ │ │ -IteratorRange<... > Dune::GridGlue::intersections (const GridGlue<... > &glue, │ │ │ │ │ - const Reverse<... > &reverse=!reversed) │ │ │ │ │ -  Iterate over all intersections of a GridGlue. More... │ │ │ │ │ -  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Write all remote intersections to a AmiraMesh file. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: rangegenerators.hh Source File │ │ │ │ +dune-grid-glue: gridglueamirawriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,74 +62,162 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
rangegenerators.hh
│ │ │ │ +
gridglueamirawriter.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#ifndef DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH
│ │ │ │ -
5
│ │ │ │ -
6#include <dune/common/iteratorrange.hh>
│ │ │ │ -
7
│ │ │ │ -
8namespace Dune {
│ │ │ │ -
9namespace GridGlue {
│ │ │ │ +
8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ +
9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │
10
│ │ │ │ -
14template<bool reverse>
│ │ │ │ -
15struct Reverse
│ │ │ │ -
16 : std::integral_constant<bool, reverse>
│ │ │ │ -
17{
│ │ │ │ -
18 typedef Reverse type;
│ │ │ │ -
19
│ │ │ │ -
20 constexpr
│ │ │ │ - │ │ │ │ -
22 { return {}; }
│ │ │ │ -
23};
│ │ │ │ -
24
│ │ │ │ -
25#ifdef DOXYGEN
│ │ │ │ -
26
│ │ │ │ - │ │ │ │ +
11#include <fstream>
│ │ │ │ +
12#include <sstream>
│ │ │ │ +
13#include <type_traits>
│ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16namespace GridGlue {
│ │ │ │ +
17
│ │ │ │ + │ │ │ │ +
21{
│ │ │ │ +
22
│ │ │ │ +
26 template <class Glue, int side>
│ │ │ │ +
27 static void writeIntersections(const Glue& glue, const std::string& filename)
│ │ │ │ +
28 {
│ │ │ │ +
29 static_assert((side==0 || side==1), "'side' can only be 0 or 1");
│ │ │ │ +
30
│ │ │ │ +
31 std::ofstream fgrid;
│ │ │ │
32
│ │ │ │ -
66template<...>
│ │ │ │ -
67IteratorRange<...>
│ │ │ │ -
68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = !reversed);
│ │ │ │ -
69
│ │ │ │ -
70#else
│ │ │ │ -
71
│ │ │ │ -
72namespace {
│ │ │ │ -
73const Reverse<true> reversed = {};
│ │ │ │ -
74} /* namespace */
│ │ │ │ +
33 fgrid.open(filename.c_str());
│ │ │ │ +
34
│ │ │ │ +
35 using GridView = typename Glue::template GridView<side>;
│ │ │ │ +
36 const int dim = GridView::dimension;
│ │ │ │ +
37 const int domdimw = GridView::dimensionworld;
│ │ │ │ +
38
│ │ │ │ +
39 // coordinates have to be in R^3 in the VTK format
│ │ │ │ +
40 std::string coordinatePadding;
│ │ │ │ +
41 for (int i=domdimw; i<3; i++)
│ │ │ │ +
42 coordinatePadding += " 0";
│ │ │ │ +
43
│ │ │ │ +
44 int overlaps = glue.size();
│ │ │ │ +
45
│ │ │ │ +
46 if (dim==3) {
│ │ │ │ +
47
│ │ │ │ +
48 fgrid << "# HyperSurface 0.1 ASCII \n" << std::endl;
│ │ │ │ +
49 fgrid<<"\n";
│ │ │ │ +
50 fgrid<<"Parameters {\n";
│ │ │ │ +
51 fgrid<<" Materials {\n";
│ │ │ │ +
52 fgrid<<" outside {\n";
│ │ │ │ +
53 fgrid<<" Id 0\n";
│ │ │ │ +
54 fgrid<<" }\n";
│ │ │ │ +
55 fgrid<<" inside {\n";
│ │ │ │ +
56 fgrid<<" Id 1\n";
│ │ │ │ +
57 fgrid<<" }\n";
│ │ │ │ +
58 fgrid<<" }\n";
│ │ │ │ +
59 fgrid<<"\n";
│ │ │ │ +
60 fgrid<<"}\n";
│ │ │ │ +
61
│ │ │ │ +
62 // ////////////////////////////////////////////
│ │ │ │ +
63 // Write vertices
│ │ │ │ +
64 // ////////////////////////////////////////////
│ │ │ │ +
65
│ │ │ │ +
66 //use dim and not dim+1
│ │ │ │ +
67 fgrid<<"\nVertices "<< overlaps*(dim)<<"\n";
│ │ │ │ +
68 auto isEnd = glue.template iend<side>();
│ │ │ │ +
69 for (auto isIt = glue.template ibegin<side>(); isIt != isEnd; ++isIt)
│ │ │ │ +
70 {
│ │ │ │ +
71 const auto& geometry = isIt->geometry();
│ │ │ │ +
72 for (int i = 0; i < geometry.corners(); ++i)
│ │ │ │ +
73 fgrid << geometry.corner(i) << coordinatePadding << std::endl;
│ │ │ │ +
74 }
│ │ │ │
75
│ │ │ │ -
76template<typename P0, typename P1, bool reverse = false>
│ │ │ │ -
77IteratorRange< typename GridGlue<P0, P1>::template IntersectionIterator<reverse ? 1 : 0> >
│ │ │ │ -
78intersections(const GridGlue<P0, P1>& glue, const Reverse<reverse>& = {})
│ │ │ │ -
79{
│ │ │ │ -
80 const static int side = reverse ? 1 : 0;
│ │ │ │ -
81 return {glue.template ibegin<side>(), glue.template iend<side>()};
│ │ │ │ -
82}
│ │ │ │ -
83
│ │ │ │ -
84#endif // DOXYGEN
│ │ │ │ -
85
│ │ │ │ -
86} /* namespace GridGlue */
│ │ │ │ -
87} /* namespace Dune */
│ │ │ │ -
88
│ │ │ │ -
89#endif
│ │ │ │ +
76 // ////////////////////////////////////////////
│ │ │ │ +
77 // Write triangles
│ │ │ │ +
78 // ////////////////////////////////////////////
│ │ │ │ +
79
│ │ │ │ +
80 fgrid<<"NBranchingPoints 0\n";
│ │ │ │ +
81 fgrid<<"NVerticesOnCurves 0\n";
│ │ │ │ +
82 fgrid<<"BoundaryCurves 0\n";
│ │ │ │ +
83 fgrid<<"Patches 1\n";
│ │ │ │ +
84 fgrid<<"{\n";
│ │ │ │ +
85 fgrid<<"InnerRegion inside\n";
│ │ │ │ +
86 fgrid<<"OuterRegion outside\n";
│ │ │ │ +
87 fgrid<<"BoundaryID 0\n";
│ │ │ │ +
88 fgrid<<"BranchingPoints 0";
│ │ │ │ +
89 fgrid<<"\n";
│ │ │ │ +
90
│ │ │ │ +
91 fgrid<<"Triangles "<<overlaps<<std::endl;
│ │ │ │ +
92
│ │ │ │ +
93 for (int i=0;i<overlaps; i++)
│ │ │ │ +
94 fgrid<<i*dim+1<<" "<<i*dim+2<<" "<<i*dim+3<<std::endl;
│ │ │ │ +
95 fgrid<<"}\n";
│ │ │ │ +
96
│ │ │ │ +
97 } else if (dim==2) {
│ │ │ │ +
98
│ │ │ │ +
99 fgrid << "# AmiraMesh 3D ASCII 2.0 \n";
│ │ │ │ +
100 fgrid<<"\n";
│ │ │ │ +
101 fgrid<<"define Lines "<<3*overlaps<<"\n";
│ │ │ │ +
102 fgrid<<"nVertices "<<2*overlaps<<"\n";
│ │ │ │ +
103 fgrid<<"\n";
│ │ │ │ +
104 fgrid<<"Parameters {\n";
│ │ │ │ +
105 fgrid<<" ContentType \"HxLineSet\" \n";
│ │ │ │ +
106 fgrid<<"}\n";
│ │ │ │ +
107 fgrid<<"\n";
│ │ │ │ +
108 fgrid<<"Lines { int LineIdx } @1\n";
│ │ │ │ +
109 fgrid<<"Vertices { float[3] Coordinates } @2\n";
│ │ │ │ +
110 fgrid<<"\n";
│ │ │ │ +
111 fgrid<<"# Data section follows\n";
│ │ │ │ +
112 fgrid<<"@1 \n";
│ │ │ │ +
113 for (int i=0; i<overlaps;i++)
│ │ │ │ +
114 fgrid<<2*i<<"\n"<<2*i+1<<"\n"<<-1<<"\n";
│ │ │ │ +
115 fgrid<<"\n";
│ │ │ │ +
116 fgrid<<"@2 \n";
│ │ │ │ +
117
│ │ │ │ +
118 auto isEnd = glue.template iend<side>();
│ │ │ │ +
119 for (auto isIt = glue.template ibegin<side>(); isIt != isEnd; ++isIt) {
│ │ │ │ +
120 const auto& geometry = isIt->geometry();
│ │ │ │ +
121 for (int i = 0; i <2; ++i)
│ │ │ │ +
122 fgrid << geometry.corner(i) <<" "<<0<<"\n";
│ │ │ │ +
123 }
│ │ │ │ +
124 }
│ │ │ │ +
125
│ │ │ │ +
126 fgrid.close();
│ │ │ │ +
127 }
│ │ │ │ +
128
│ │ │ │ +
129public:
│ │ │ │ +
130 template<typename Glue>
│ │ │ │ +
131 static void write(const Glue& glue, const std::string& path, int appendix=1)
│ │ │ │ +
132 {
│ │ │ │ +
133 std::ostringstream name0;
│ │ │ │ +
134 name0 << path;
│ │ │ │ +
135 name0 << "/domain.surf" << std::setw(3) << std::setfill('0') << appendix;
│ │ │ │ +
136
│ │ │ │ +
137 // Write extracted grid and remote intersection on the grid1-side
│ │ │ │ +
138 writeIntersections<Glue,0>(glue,name0.str());
│ │ │ │ +
139
│ │ │ │ +
140 std::ostringstream name1;
│ │ │ │ +
141 name1 << path;
│ │ │ │ +
142 name1 << "/target.surf" << std::setw(3) << std::setfill('0') << appendix;
│ │ │ │ +
143
│ │ │ │ +
144 writeIntersections<Glue,1>(glue, name1.str());
│ │ │ │ +
145 }
│ │ │ │ +
146
│ │ │ │ +
147};
│ │ │ │ +
148
│ │ │ │ +
149} // namespace GridGlue
│ │ │ │ +
150} // namespace Dune
│ │ │ │ +
151
│ │ │ │ +
152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:67
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
Definition: rangegenerators.hh:17
│ │ │ │ -
const Reverse< true > reversed
Definition: rangegenerators.hh:31
│ │ │ │ -
Reverse type
Definition: rangegenerators.hh:18
│ │ │ │ -
constexpr Reverse<!reverse > operator!() const
Definition: rangegenerators.hh:21
│ │ │ │ +
Write remote intersections to a AmiraMesh file for debugging purposes.
Definition: gridglueamirawriter.hh:21
│ │ │ │ +
static void write(const Glue &glue, const std::string &path, int appendix=1)
Definition: gridglueamirawriter.hh:131
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,89 +5,166 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -rangegenerators.hh │ │ │ │ │ +gridglueamirawriter.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#ifndef DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH │ │ │ │ │ - 4#define DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7 │ │ │ │ │ - 8namespace Dune { │ │ │ │ │ - 9namespace GridGlue { │ │ │ │ │ + 8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ + 9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ 10 │ │ │ │ │ - 14template │ │ │ │ │ -15struct Reverse │ │ │ │ │ - 16 : std::integral_constant │ │ │ │ │ - 17{ │ │ │ │ │ -18 typedef Reverse type; │ │ │ │ │ - 19 │ │ │ │ │ - 20 constexpr │ │ │ │ │ -21 Reverse operator!() const │ │ │ │ │ - 22 { return {}; } │ │ │ │ │ - 23}; │ │ │ │ │ - 24 │ │ │ │ │ - 25#ifdef DOXYGEN │ │ │ │ │ - 26 │ │ │ │ │ -31const Reverse reversed; │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14 │ │ │ │ │ + 15namespace Dune { │ │ │ │ │ + 16namespace GridGlue { │ │ │ │ │ + 17 │ │ │ │ │ +20class GridGlueAmiraWriter │ │ │ │ │ + 21{ │ │ │ │ │ + 22 │ │ │ │ │ + 26 template │ │ │ │ │ + 27 static void writeIntersections(const Glue& glue, const std::string& │ │ │ │ │ +filename) │ │ │ │ │ + 28 { │ │ │ │ │ + 29 static_assert((side==0 || side==1), "'side' can only be 0 or 1"); │ │ │ │ │ + 30 │ │ │ │ │ + 31 std::ofstream fgrid; │ │ │ │ │ 32 │ │ │ │ │ - 66template<...> │ │ │ │ │ - 67IteratorRange<...> │ │ │ │ │ -68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = │ │ │ │ │ -!reversed); │ │ │ │ │ - 69 │ │ │ │ │ - 70#else │ │ │ │ │ - 71 │ │ │ │ │ - 72namespace { │ │ │ │ │ - 73const Reverse reversed = {}; │ │ │ │ │ - 74} /* namespace */ │ │ │ │ │ + 33 fgrid.open(filename.c_str()); │ │ │ │ │ + 34 │ │ │ │ │ + 35 using GridView = typename Glue::template GridView; │ │ │ │ │ + 36 const int dim = GridView::dimension; │ │ │ │ │ + 37 const int domdimw = GridView::dimensionworld; │ │ │ │ │ + 38 │ │ │ │ │ + 39 // coordinates have to be in R^3 in the VTK format │ │ │ │ │ + 40 std::string coordinatePadding; │ │ │ │ │ + 41 for (int i=domdimw; i<3; i++) │ │ │ │ │ + 42 coordinatePadding += " 0"; │ │ │ │ │ + 43 │ │ │ │ │ + 44 int overlaps = glue.size(); │ │ │ │ │ + 45 │ │ │ │ │ + 46 if (dim==3) { │ │ │ │ │ + 47 │ │ │ │ │ + 48 fgrid << "# HyperSurface 0.1 ASCII \n" << std::endl; │ │ │ │ │ + 49 fgrid<<"\n"; │ │ │ │ │ + 50 fgrid<<"Parameters {\n"; │ │ │ │ │ + 51 fgrid<<" Materials {\n"; │ │ │ │ │ + 52 fgrid<<" outside {\n"; │ │ │ │ │ + 53 fgrid<<" Id 0\n"; │ │ │ │ │ + 54 fgrid<<" }\n"; │ │ │ │ │ + 55 fgrid<<" inside {\n"; │ │ │ │ │ + 56 fgrid<<" Id 1\n"; │ │ │ │ │ + 57 fgrid<<" }\n"; │ │ │ │ │ + 58 fgrid<<" }\n"; │ │ │ │ │ + 59 fgrid<<"\n"; │ │ │ │ │ + 60 fgrid<<"}\n"; │ │ │ │ │ + 61 │ │ │ │ │ + 62 // //////////////////////////////////////////// │ │ │ │ │ + 63 // Write vertices │ │ │ │ │ + 64 // //////////////////////////////////////////// │ │ │ │ │ + 65 │ │ │ │ │ + 66 //use dim and not dim+1 │ │ │ │ │ + 67 fgrid<<"\nVertices "<< overlaps*(dim)<<"\n"; │ │ │ │ │ + 68 auto isEnd = glue.template iend(); │ │ │ │ │ + 69 for (auto isIt = glue.template ibegin(); isIt != isEnd; ++isIt) │ │ │ │ │ + 70 { │ │ │ │ │ + 71 const auto& geometry = isIt->geometry(); │ │ │ │ │ + 72 for (int i = 0; i < geometry.corners(); ++i) │ │ │ │ │ + 73 fgrid << geometry.corner(i) << coordinatePadding << std::endl; │ │ │ │ │ + 74 } │ │ │ │ │ 75 │ │ │ │ │ - 76template │ │ │ │ │ - 77IteratorRange< typename GridGlue::template │ │ │ │ │ -IntersectionIterator > │ │ │ │ │ - 78intersections(const GridGlue& glue, const Reverse& = {}) │ │ │ │ │ - 79{ │ │ │ │ │ - 80 const static int side = reverse ? 1 : 0; │ │ │ │ │ - 81 return {glue.template ibegin(), glue.template iend()}; │ │ │ │ │ - 82} │ │ │ │ │ - 83 │ │ │ │ │ - 84#endif // DOXYGEN │ │ │ │ │ - 85 │ │ │ │ │ - 86} /* namespace GridGlue */ │ │ │ │ │ - 87} /* namespace Dune */ │ │ │ │ │ - 88 │ │ │ │ │ - 89#endif │ │ │ │ │ + 76 // //////////////////////////////////////////// │ │ │ │ │ + 77 // Write triangles │ │ │ │ │ + 78 // //////////////////////////////////////////// │ │ │ │ │ + 79 │ │ │ │ │ + 80 fgrid<<"NBranchingPoints 0\n"; │ │ │ │ │ + 81 fgrid<<"NVerticesOnCurves 0\n"; │ │ │ │ │ + 82 fgrid<<"BoundaryCurves 0\n"; │ │ │ │ │ + 83 fgrid<<"Patches 1\n"; │ │ │ │ │ + 84 fgrid<<"{\n"; │ │ │ │ │ + 85 fgrid<<"InnerRegion inside\n"; │ │ │ │ │ + 86 fgrid<<"OuterRegion outside\n"; │ │ │ │ │ + 87 fgrid<<"BoundaryID 0\n"; │ │ │ │ │ + 88 fgrid<<"BranchingPoints 0"; │ │ │ │ │ + 89 fgrid<<"\n"; │ │ │ │ │ + 90 │ │ │ │ │ + 91 fgrid<<"Triangles "<(); │ │ │ │ │ + 119 for (auto isIt = glue.template ibegin(); isIt != isEnd; ++isIt) { │ │ │ │ │ + 120 const auto& geometry = isIt->geometry(); │ │ │ │ │ + 121 for (int i = 0; i <2; ++i) │ │ │ │ │ + 122 fgrid << geometry.corner(i) <<" "<<0<<"\n"; │ │ │ │ │ + 123 } │ │ │ │ │ + 124 } │ │ │ │ │ + 125 │ │ │ │ │ + 126 fgrid.close(); │ │ │ │ │ + 127 } │ │ │ │ │ + 128 │ │ │ │ │ + 129public: │ │ │ │ │ + 130 template │ │ │ │ │ +131 static void write(const Glue& glue, const std::string& path, int │ │ │ │ │ +appendix=1) │ │ │ │ │ + 132 { │ │ │ │ │ + 133 std::ostringstream name0; │ │ │ │ │ + 134 name0 << path; │ │ │ │ │ + 135 name0 << "/domain.surf" << std::setw(3) << std::setfill('0') << appendix; │ │ │ │ │ + 136 │ │ │ │ │ + 137 // Write extracted grid and remote intersection on the grid1-side │ │ │ │ │ + 138 writeIntersections(glue,name0.str()); │ │ │ │ │ + 139 │ │ │ │ │ + 140 std::ostringstream name1; │ │ │ │ │ + 141 name1 << path; │ │ │ │ │ + 142 name1 << "/target.surf" << std::setw(3) << std::setfill('0') << appendix; │ │ │ │ │ + 143 │ │ │ │ │ + 144 writeIntersections(glue, name1.str()); │ │ │ │ │ + 145 } │ │ │ │ │ + 146 │ │ │ │ │ + 147}; │ │ │ │ │ + 148 │ │ │ │ │ + 149} // namespace GridGlue │ │ │ │ │ + 150} // namespace Dune │ │ │ │ │ + 151 │ │ │ │ │ + 152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::intersections │ │ │ │ │ -IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ -> &reverse=!reversed) │ │ │ │ │ -Iterate over all intersections of a GridGlue. │ │ │ │ │ -Dune::GridGlue::GridGlue │ │ │ │ │ -sequential adapter to couple two grids at specified close together boundaries │ │ │ │ │ -Definition: gridglue.hh:67 │ │ │ │ │ -Dune::GridGlue::GridGlue::intersections │ │ │ │ │ -IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ -> &reverse=!reversed) │ │ │ │ │ -Iterate over all intersections of a GridGlue. │ │ │ │ │ -Dune::GridGlue::Reverse │ │ │ │ │ -Definition: rangegenerators.hh:17 │ │ │ │ │ -Dune::GridGlue::Reverse::reversed │ │ │ │ │ -const Reverse< true > reversed │ │ │ │ │ -Definition: rangegenerators.hh:31 │ │ │ │ │ -Dune::GridGlue::Reverse::type │ │ │ │ │ -Reverse type │ │ │ │ │ -Definition: rangegenerators.hh:18 │ │ │ │ │ -Dune::GridGlue::Reverse::operator! │ │ │ │ │ -constexpr Reverse operator!() const │ │ │ │ │ -Definition: rangegenerators.hh:21 │ │ │ │ │ +Dune::GridGlue::GridGlueAmiraWriter │ │ │ │ │ +Write remote intersections to a AmiraMesh file for debugging purposes. │ │ │ │ │ +Definition: gridglueamirawriter.hh:21 │ │ │ │ │ +Dune::GridGlue::GridGlueAmiraWriter::write │ │ │ │ │ +static void write(const Glue &glue, const std::string &path, int appendix=1) │ │ │ │ │ +Definition: gridglueamirawriter.hh:131 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridglueamirawriter.hh File Reference │ │ │ │ +dune-grid-glue: gridglue.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,43 +63,39 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
gridglueamirawriter.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
gridglue.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Write all remote intersections to a AmiraMesh file. │ │ │ │ -More...

│ │ │ │ -
#include <fstream>
│ │ │ │ -#include <sstream>
│ │ │ │ -#include <type_traits>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::GridGlue::GridGlueAmiraWriter
 Write remote intersections to a AmiraMesh file for debugging purposes. More...
 
│ │ │ │ +
#include "intersection.hh"
│ │ │ │ +#include <vector>
│ │ │ │ +#include <iterator>
│ │ │ │ +#include "../gridglue.hh"
│ │ │ │ +#include "../common/ringcomm.hh"
│ │ │ │ +#include <dune/common/unused.hh>
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<typename T >
void Dune::GridGlue::printVector (const std::vector< T > &v, std::string name, int rank)
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Write all remote intersections to a AmiraMesh file.

│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,29 +5,28 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -gridglueamirawriter.hh File Reference │ │ │ │ │ -Write all remote intersections to a AmiraMesh file. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -class  Dune::GridGlue::GridGlueAmiraWriter │ │ │ │ │ -  Write remote intersections to a AmiraMesh file for debugging purposes. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +gridglue.cc File Reference │ │ │ │ │ +#include "intersection.hh" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "../gridglue.hh" │ │ │ │ │ +#include "../common/ringcomm.hh" │ │ │ │ │ +#include │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Write all remote intersections to a AmiraMesh file. │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::printVector (const std::vector< T > &v, std::string name, │ │ │ │ │ + int rank) │ │ │ │ │ +  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projectionwriter_impl.hh File Reference │ │ │ │ +dune-grid-glue: crossproduct.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,59 +65,33 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
projectionwriter_impl.hh File Reference
│ │ │ │ +
crossproduct.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <fstream>
│ │ │ │ -
│ │ │ │ + │ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
namespace  Dune::GridGlue::ProjectionWriterImplementation
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<unsigned side, typename Coordinate , typename Corners >
void Dune::GridGlue::ProjectionWriterImplementation::write_points (const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
 
template<unsigned side, typename Coordinate , typename Normals >
void Dune::GridGlue::ProjectionWriterImplementation::write_normals (const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
 
template<typename Coordinate , typename Corners >
void Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_points (const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
 
template<typename Coordinate , typename Normals >
void Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_normals (const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
 
template<unsigned side, typename Coordinate >
void Dune::GridGlue::ProjectionWriterImplementation::write_success (const Projection< Coordinate > &projection, std::ostream &out)
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
 write projection in VTK format More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, const std::string &filename)
 write projection in VTK format More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::print (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
 Print information about the projection to std::cout stream. More...
 
template<class T , int dim>
static Dune::FieldVector< T, dim > Dune::GridGlue::crossProduct (const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
 compute cross product More...
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,60 +6,24 @@ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -projectionwriter_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +crossproduct.hh File Reference │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -namespace  Dune::GridGlue::ProjectionWriterImplementation │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::ProjectionWriterImplementation::write_points (const │ │ │ │ │ - Projection< Coordinate > &projection, const Corners &corners, std:: │ │ │ │ │ - ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::ProjectionWriterImplementation::write_normals (const │ │ │ │ │ - Projection< Coordinate > &projection, const Normals &normals, std:: │ │ │ │ │ - ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::ProjectionWriterImplementation:: │ │ │ │ │ - write_edge_intersection_points (const Projection< Coordinate > │ │ │ │ │ - &projection, const Corners &corners, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::ProjectionWriterImplementation:: │ │ │ │ │ - write_edge_intersection_normals (const Projection< Coordinate > │ │ │ │ │ - &projection, const Normals &normals, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::ProjectionWriterImplementation::write_success (const │ │ │ │ │ - Projection< Coordinate > &projection, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals, std::ostream &out) │ │ │ │ │ -  write projection in VTK format More... │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ -  write projection in VTK format More... │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals) │ │ │ │ │ -  Print information about the projection to std::cout stream. More... │ │ │ │ │ +template │ │ │ │ │ +static Dune::FieldVector< T, dim > Dune::GridGlue::crossProduct (const Dune:: │ │ │ │ │ + FieldVector< T, dim > &a, const Dune:: │ │ │ │ │ + FieldVector< T, dim > &b) │ │ │ │ │ +  compute cross product More... │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projectionwriter_impl.hh Source File │ │ │ │ +dune-grid-glue: crossproduct.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,195 +62,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
projectionwriter_impl.hh
│ │ │ │ +
crossproduct.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#include <fstream>
│ │ │ │ -
4
│ │ │ │ -
5namespace Dune {
│ │ │ │ -
6namespace GridGlue {
│ │ │ │ -
7
│ │ │ │ -
8namespace ProjectionWriterImplementation {
│ │ │ │ -
9
│ │ │ │ -
10template<unsigned side, typename Coordinate, typename Corners>
│ │ │ │ -
11void write_points(const Projection<Coordinate>& projection, const Corners& corners, std::ostream& out)
│ │ │ │ -
12{
│ │ │ │ -
13 using namespace ProjectionImplementation;
│ │ │ │ -
14 using std::get;
│ │ │ │ -
15 const unsigned other_side = 1 - side;
│ │ │ │ -
16
│ │ │ │ -
17 for (const auto& c : get<side>(corners))
│ │ │ │ -
18 out << c << "\n";
│ │ │ │ -
19
│ │ │ │ -
20 for (const auto& i : get<side>(projection.images())) {
│ │ │ │ -
21 const auto global = interpolate(i, get<other_side>(corners));
│ │ │ │ -
22 out << global << "\n";
│ │ │ │ -
23 }
│ │ │ │ -
24}
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
│ │ │ │ +
5
│ │ │ │ +
6namespace Dune {
│ │ │ │ +
7namespace GridGlue {
│ │ │ │ +
8
│ │ │ │ +
14template <class T, int dim>
│ │ │ │ +
15static Dune::FieldVector<T,dim> crossProduct(const Dune::FieldVector<T,dim>& a,
│ │ │ │ +
16 const Dune::FieldVector<T,dim>& b)
│ │ │ │ +
17{
│ │ │ │ +
18 if (dim!=3)
│ │ │ │ +
19 DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension " << dim);
│ │ │ │ +
20
│ │ │ │ +
21 Dune::FieldVector<T,dim> c;
│ │ │ │ +
22 c[0] = a[1]*b[2] - a[2]*b[1];
│ │ │ │ +
23 c[1] = a[2]*b[0] - a[0]*b[2];
│ │ │ │ +
24 c[2] = a[0]*b[1] - a[1]*b[0];
│ │ │ │
25
│ │ │ │ -
26template<unsigned side, typename Coordinate, typename Normals>
│ │ │ │ -
27void write_normals(const Projection<Coordinate>& projection, const Normals& normals, std::ostream& out)
│ │ │ │ -
28{
│ │ │ │ -
29 using namespace ProjectionImplementation;
│ │ │ │ -
30 using std::get;
│ │ │ │ -
31 const unsigned other_side = 1 - side;
│ │ │ │ -
32
│ │ │ │ -
33 for (const auto& n : get<side>(normals))
│ │ │ │ -
34 out << n << "\n";
│ │ │ │ -
35
│ │ │ │ -
36 for (const auto& x : get<side>(projection.images())) {
│ │ │ │ -
37 const auto n = interpolate_unit_normals(x, get<other_side>(normals));
│ │ │ │ -
38 out << n << "\n";
│ │ │ │ -
39 }
│ │ │ │ -
40}
│ │ │ │ -
41
│ │ │ │ -
42template<typename Coordinate, typename Corners>
│ │ │ │ -
43void write_edge_intersection_points(const Projection<Coordinate>& projection, const Corners& corners, std::ostream& out)
│ │ │ │ -
44{
│ │ │ │ -
45 using namespace ProjectionImplementation;
│ │ │ │ -
46 using std::get;
│ │ │ │ -
47
│ │ │ │ -
48 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) {
│ │ │ │ -
49 const auto& local = projection.edgeIntersections()[i].local;
│ │ │ │ -
50 out << interpolate(local[0], get<0>(corners)) << "\n"
│ │ │ │ -
51 << interpolate(local[1], get<1>(corners)) << "\n";
│ │ │ │ -
52 }
│ │ │ │ -
53}
│ │ │ │ -
54
│ │ │ │ -
55template<typename Coordinate, typename Normals>
│ │ │ │ -
56void write_edge_intersection_normals(const Projection<Coordinate>& projection, const Normals& normals, std::ostream& out)
│ │ │ │ -
57{
│ │ │ │ -
58 using namespace ProjectionImplementation;
│ │ │ │ -
59 using std::get;
│ │ │ │ -
60
│ │ │ │ -
61 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) {
│ │ │ │ -
62 const auto& local = projection.edgeIntersections()[i].local;
│ │ │ │ -
63 const auto n0 = interpolate_unit_normals(local[0], get<0>(normals));
│ │ │ │ -
64 const auto n1 = interpolate_unit_normals(local[1], get<1>(normals));
│ │ │ │ -
65
│ │ │ │ -
66 out << n0 << "\n"
│ │ │ │ -
67 << n1 << "\n";
│ │ │ │ -
68 }
│ │ │ │ -
69}
│ │ │ │ -
70
│ │ │ │ -
71template<unsigned side, typename Coordinate>
│ │ │ │ -
72void write_success(const Projection<Coordinate>& projection, std::ostream& out)
│ │ │ │ -
73{
│ │ │ │ -
74 using std::get;
│ │ │ │ -
75
│ │ │ │ -
76 out << side << "\n";
│ │ │ │ -
77
│ │ │ │ -
78 const auto& success = get<side>(projection.success());
│ │ │ │ -
79 for (std::size_t i = 0; i < success.size(); ++i)
│ │ │ │ -
80 out << (success[i] ? "1\n" : "0\n");
│ │ │ │ -
81}
│ │ │ │ -
82
│ │ │ │ -
83} /* namespace ProjectionWriterImplementation */
│ │ │ │ -
84
│ │ │ │ -
85template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
86void write(const Projection<Coordinate>& projection,
│ │ │ │ -
87 const Corners& corners,
│ │ │ │ -
88 const Normals& normals,
│ │ │ │ -
89 std::ostream& out)
│ │ │ │ -
90{
│ │ │ │ -
91 using namespace ProjectionWriterImplementation;
│ │ │ │ -
92
│ │ │ │ -
93 const auto numberOfEdgeIntersections = projection.numberOfEdgeIntersections();
│ │ │ │ -
94 const auto nPoints = 12 + 2 * numberOfEdgeIntersections;
│ │ │ │ -
95
│ │ │ │ -
96 out << "# vtk DataFile Version2.0\n"
│ │ │ │ -
97 << "Filename: projection\n"
│ │ │ │ -
98 << "ASCII\n"
│ │ │ │ -
99 << "DATASET UNSTRUCTURED_GRID\n"
│ │ │ │ -
100 << "POINTS " << nPoints << " double\n";
│ │ │ │ -
101 write_points<0>(projection, corners, out);
│ │ │ │ -
102 write_points<1>(projection, corners, out);
│ │ │ │ -
103 write_edge_intersection_points(projection, corners, out);
│ │ │ │ -
104 out << "CELLS " << (8 + numberOfEdgeIntersections) << " " << (26 + 3 * numberOfEdgeIntersections) << "\n";
│ │ │ │ -
105 out << "3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n"
│ │ │ │ -
106 << "3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n";
│ │ │ │ -
107 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ -
108 out << "2 " << (12 + 2*i) << " " << (12 + 2*i + 1) << "\n";
│ │ │ │ -
109 out << "CELL_TYPES " << (8 + numberOfEdgeIntersections) << "\n" "5\n3\n3\n3\n" "5\n3\n3\n3\n";
│ │ │ │ -
110 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ -
111 out << "3\n";
│ │ │ │ -
112 out << "CELL_DATA " << (8 + numberOfEdgeIntersections) << "\n";
│ │ │ │ -
113 out << "SCALARS success int 1\n"
│ │ │ │ -
114 << "LOOKUP_TABLE success\n";
│ │ │ │ -
115 write_success<0>(projection, out);
│ │ │ │ -
116 write_success<1>(projection, out);
│ │ │ │ -
117 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ -
118 out << "2\n";
│ │ │ │ -
119 out << "LOOKUP_TABLE success 2\n"
│ │ │ │ -
120 << "1.0 0.0 0.0 1.0\n"
│ │ │ │ -
121 << "0.0 1.0 0.0 1.0\n";
│ │ │ │ -
122 out << "POINT_DATA " << nPoints << "\n"
│ │ │ │ -
123 << "NORMALS normals double\n";
│ │ │ │ -
124 write_normals<0>(projection, normals, out);
│ │ │ │ -
125 write_normals<1>(projection, normals, out);
│ │ │ │ -
126 write_edge_intersection_normals(projection, normals, out);
│ │ │ │ -
127}
│ │ │ │ -
128
│ │ │ │ -
129template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
130void write(const Projection<Coordinate>& projection,
│ │ │ │ -
131 const Corners& corners,
│ │ │ │ -
132 const Normals& normals,
│ │ │ │ -
133 const std::string& filename)
│ │ │ │ -
134{
│ │ │ │ -
135 std::ofstream out(filename.c_str());
│ │ │ │ -
136 write(projection, corners, normals, out);
│ │ │ │ -
137}
│ │ │ │ -
138
│ │ │ │ -
139template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
140void print(const Projection<Coordinate>& projection,
│ │ │ │ -
141 const Corners& corners,
│ │ │ │ -
142 const Normals& normals)
│ │ │ │ -
143{
│ │ │ │ -
144 using namespace ProjectionWriterImplementation;
│ │ │ │ -
145
│ │ │ │ -
146 std::cout << "Side 0 corners and images:\n";
│ │ │ │ -
147 write_points<0>(projection, corners, std::cout);
│ │ │ │ -
148 std::cout << "Side 0 success:\n";
│ │ │ │ -
149 write_success<0>(projection, std::cout);
│ │ │ │ -
150 std::cout << "Side 1 corners and images:\n";
│ │ │ │ -
151 write_points<1>(projection, corners, std::cout);
│ │ │ │ -
152 std::cout << "Side 1 success:\n";
│ │ │ │ -
153 write_success<1>(projection, std::cout);
│ │ │ │ -
154 std::cout << "Side 0 normals and projected normals:\n";
│ │ │ │ -
155 write_normals<0>(projection, normals, std::cout);
│ │ │ │ -
156 std::cout << "Side 1 normals and projected normals:\n";
│ │ │ │ -
157 write_normals<1>(projection, normals, std::cout);
│ │ │ │ -
158 std::cout << projection.numberOfEdgeIntersections() << " edge intersections:\n";
│ │ │ │ -
159 write_edge_intersection_points(projection, corners, std::cout);
│ │ │ │ -
160}
│ │ │ │ -
161
│ │ │ │ -
162} /* namespace GridGlue */
│ │ │ │ -
163} /* namespace Dune */
│ │ │ │ +
26 return c;
│ │ │ │ +
27}
│ │ │ │ +
28
│ │ │ │ +
29} /* namespace GridGlue */
│ │ │ │ +
30} /* namespace Dune */
│ │ │ │ +
31
│ │ │ │ +
32#endif
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
void write(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
write projection in VTK format
Definition: projectionwriter_impl.hh:86
│ │ │ │ -
void print(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
Print information about the projection to std::cout stream.
Definition: projectionwriter_impl.hh:140
│ │ │ │ -
Corners::value_type interpolate(const Coordinate &x, const Corners &corners)
Definition: projection_impl.hh:70
│ │ │ │ -
Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals &normals)
Definition: projection_impl.hh:91
│ │ │ │ -
void write_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:27
│ │ │ │ -
void write_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:11
│ │ │ │ -
void write_success(const Projection< Coordinate > &projection, std::ostream &out)
Definition: projectionwriter_impl.hh:72
│ │ │ │ -
void write_edge_intersection_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:43
│ │ │ │ -
void write_edge_intersection_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:56
│ │ │ │ -
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:21
│ │ │ │ -
const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const
Indicate whether projection (inverse projection) is valid for each corner or not.
Definition: projection.hh:252
│ │ │ │ -
unsigned numberOfEdgeIntersections() const
Number of edge intersections.
Definition: projection.hh:262
│ │ │ │ -
const std::tuple< Images, Preimages > & images() const
Images and preimages of corners.
Definition: projection.hh:235
│ │ │ │ -
const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections() const
Edge-edge intersections.
Definition: projection.hh:273
│ │ │ │ +
static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
compute cross product
Definition: crossproduct.hh:15
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,246 +5,50 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projectionwriter_impl.hh │ │ │ │ │ +crossproduct.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#include │ │ │ │ │ - 4 │ │ │ │ │ - 5namespace Dune { │ │ │ │ │ - 6namespace GridGlue { │ │ │ │ │ - 7 │ │ │ │ │ -8namespace ProjectionWriterImplementation { │ │ │ │ │ - 9 │ │ │ │ │ - 10template │ │ │ │ │ -11void write_points(const Projection& projection, const Corners& │ │ │ │ │ -corners, std::ostream& out) │ │ │ │ │ - 12{ │ │ │ │ │ - 13 using namespace ProjectionImplementation; │ │ │ │ │ - 14 using std::get; │ │ │ │ │ - 15 const unsigned other_side = 1 - side; │ │ │ │ │ - 16 │ │ │ │ │ - 17 for (const auto& c : get(corners)) │ │ │ │ │ - 18 out << c << "\n"; │ │ │ │ │ - 19 │ │ │ │ │ - 20 for (const auto& i : get(projection.images())) { │ │ │ │ │ - 21 const auto global = interpolate(i, get(corners)); │ │ │ │ │ - 22 out << global << "\n"; │ │ │ │ │ - 23 } │ │ │ │ │ - 24} │ │ │ │ │ + 3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH │ │ │ │ │ + 4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1 │ │ │ │ │ + 5 │ │ │ │ │ + 6namespace Dune { │ │ │ │ │ + 7namespace GridGlue { │ │ │ │ │ + 8 │ │ │ │ │ + 14template │ │ │ │ │ +15static Dune::FieldVector crossProduct(const Dune::FieldVector& │ │ │ │ │ +a, │ │ │ │ │ + 16 const Dune::FieldVector& b) │ │ │ │ │ + 17{ │ │ │ │ │ + 18 if (dim!=3) │ │ │ │ │ + 19 DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension │ │ │ │ │ +" << dim); │ │ │ │ │ + 20 │ │ │ │ │ + 21 Dune::FieldVector c; │ │ │ │ │ + 22 c[0] = a[1]*b[2] - a[2]*b[1]; │ │ │ │ │ + 23 c[1] = a[2]*b[0] - a[0]*b[2]; │ │ │ │ │ + 24 c[2] = a[0]*b[1] - a[1]*b[0]; │ │ │ │ │ 25 │ │ │ │ │ - 26template │ │ │ │ │ -27void write_normals(const Projection& projection, const Normals& │ │ │ │ │ -normals, std::ostream& out) │ │ │ │ │ - 28{ │ │ │ │ │ - 29 using namespace ProjectionImplementation; │ │ │ │ │ - 30 using std::get; │ │ │ │ │ - 31 const unsigned other_side = 1 - side; │ │ │ │ │ - 32 │ │ │ │ │ - 33 for (const auto& n : get(normals)) │ │ │ │ │ - 34 out << n << "\n"; │ │ │ │ │ - 35 │ │ │ │ │ - 36 for (const auto& x : get(projection.images())) { │ │ │ │ │ - 37 const auto n = interpolate_unit_normals(x, get(normals)); │ │ │ │ │ - 38 out << n << "\n"; │ │ │ │ │ - 39 } │ │ │ │ │ - 40} │ │ │ │ │ - 41 │ │ │ │ │ - 42template │ │ │ │ │ -43void write_edge_intersection_points(const Projection& projection, │ │ │ │ │ -const Corners& corners, std::ostream& out) │ │ │ │ │ - 44{ │ │ │ │ │ - 45 using namespace ProjectionImplementation; │ │ │ │ │ - 46 using std::get; │ │ │ │ │ - 47 │ │ │ │ │ - 48 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ - 49 const auto& local = projection.edgeIntersections()[i].local; │ │ │ │ │ - 50 out << interpolate(local[0], get<0>(corners)) << "\n" │ │ │ │ │ - 51 << interpolate(local[1], get<1>(corners)) << "\n"; │ │ │ │ │ - 52 } │ │ │ │ │ - 53} │ │ │ │ │ - 54 │ │ │ │ │ - 55template │ │ │ │ │ -56void write_edge_intersection_normals(const Projection& │ │ │ │ │ -projection, const Normals& normals, std::ostream& out) │ │ │ │ │ - 57{ │ │ │ │ │ - 58 using namespace ProjectionImplementation; │ │ │ │ │ - 59 using std::get; │ │ │ │ │ - 60 │ │ │ │ │ - 61 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ - 62 const auto& local = projection.edgeIntersections()[i].local; │ │ │ │ │ - 63 const auto n0 = interpolate_unit_normals(local[0], get<0>(normals)); │ │ │ │ │ - 64 const auto n1 = interpolate_unit_normals(local[1], get<1>(normals)); │ │ │ │ │ - 65 │ │ │ │ │ - 66 out << n0 << "\n" │ │ │ │ │ - 67 << n1 << "\n"; │ │ │ │ │ - 68 } │ │ │ │ │ - 69} │ │ │ │ │ - 70 │ │ │ │ │ - 71template │ │ │ │ │ -72void write_success(const Projection& projection, std::ostream& │ │ │ │ │ -out) │ │ │ │ │ - 73{ │ │ │ │ │ - 74 using std::get; │ │ │ │ │ - 75 │ │ │ │ │ - 76 out << side << "\n"; │ │ │ │ │ - 77 │ │ │ │ │ - 78 const auto& success = get(projection.success()); │ │ │ │ │ - 79 for (std::size_t i = 0; i < success.size(); ++i) │ │ │ │ │ - 80 out << (success[i] ? "1\n" : "0\n"); │ │ │ │ │ - 81} │ │ │ │ │ - 82 │ │ │ │ │ - 83} /* namespace ProjectionWriterImplementation */ │ │ │ │ │ - 84 │ │ │ │ │ - 85template │ │ │ │ │ -86void write(const Projection& projection, │ │ │ │ │ - 87 const Corners& corners, │ │ │ │ │ - 88 const Normals& normals, │ │ │ │ │ - 89 std::ostream& out) │ │ │ │ │ - 90{ │ │ │ │ │ - 91 using namespace ProjectionWriterImplementation; │ │ │ │ │ - 92 │ │ │ │ │ - 93 const auto numberOfEdgeIntersections = projection.numberOfEdgeIntersections │ │ │ │ │ -(); │ │ │ │ │ - 94 const auto nPoints = 12 + 2 * numberOfEdgeIntersections; │ │ │ │ │ - 95 │ │ │ │ │ - 96 out << "# vtk DataFile Version2.0\n" │ │ │ │ │ - 97 << "Filename: projection\n" │ │ │ │ │ - 98 << "ASCII\n" │ │ │ │ │ - 99 << "DATASET UNSTRUCTURED_GRID\n" │ │ │ │ │ - 100 << "POINTS " << nPoints << " double\n"; │ │ │ │ │ - 101 write_points<0>(projection, corners, out); │ │ │ │ │ - 102 write_points<1>(projection, corners, out); │ │ │ │ │ - 103 write_edge_intersection_points(projection, corners, out); │ │ │ │ │ - 104 out << "CELLS " << (8 + numberOfEdgeIntersections) << " " << (26 + 3 * │ │ │ │ │ -numberOfEdgeIntersections) << "\n"; │ │ │ │ │ - 105 out << "3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n" │ │ │ │ │ - 106 << "3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n"; │ │ │ │ │ - 107 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ - 108 out << "2 " << (12 + 2*i) << " " << (12 + 2*i + 1) << "\n"; │ │ │ │ │ - 109 out << "CELL_TYPES " << (8 + numberOfEdgeIntersections) << "\n" │ │ │ │ │ -"5\n3\n3\n3\n" "5\n3\n3\n3\n"; │ │ │ │ │ - 110 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ - 111 out << "3\n"; │ │ │ │ │ - 112 out << "CELL_DATA " << (8 + numberOfEdgeIntersections) << "\n"; │ │ │ │ │ - 113 out << "SCALARS success int 1\n" │ │ │ │ │ - 114 << "LOOKUP_TABLE success\n"; │ │ │ │ │ - 115 write_success<0>(projection, out); │ │ │ │ │ - 116 write_success<1>(projection, out); │ │ │ │ │ - 117 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ - 118 out << "2\n"; │ │ │ │ │ - 119 out << "LOOKUP_TABLE success 2\n" │ │ │ │ │ - 120 << "1.0 0.0 0.0 1.0\n" │ │ │ │ │ - 121 << "0.0 1.0 0.0 1.0\n"; │ │ │ │ │ - 122 out << "POINT_DATA " << nPoints << "\n" │ │ │ │ │ - 123 << "NORMALS normals double\n"; │ │ │ │ │ - 124 write_normals<0>(projection, normals, out); │ │ │ │ │ - 125 write_normals<1>(projection, normals, out); │ │ │ │ │ - 126 write_edge_intersection_normals(projection, normals, out); │ │ │ │ │ - 127} │ │ │ │ │ - 128 │ │ │ │ │ - 129template │ │ │ │ │ -130void write(const Projection& projection, │ │ │ │ │ - 131 const Corners& corners, │ │ │ │ │ - 132 const Normals& normals, │ │ │ │ │ - 133 const std::string& filename) │ │ │ │ │ - 134{ │ │ │ │ │ - 135 std::ofstream out(filename.c_str()); │ │ │ │ │ - 136 write(projection, corners, normals, out); │ │ │ │ │ - 137} │ │ │ │ │ - 138 │ │ │ │ │ - 139template │ │ │ │ │ -140void print(const Projection& projection, │ │ │ │ │ - 141 const Corners& corners, │ │ │ │ │ - 142 const Normals& normals) │ │ │ │ │ - 143{ │ │ │ │ │ - 144 using namespace ProjectionWriterImplementation; │ │ │ │ │ - 145 │ │ │ │ │ - 146 std::cout << "Side 0 corners and images:\n"; │ │ │ │ │ - 147 write_points<0>(projection, corners, std::cout); │ │ │ │ │ - 148 std::cout << "Side 0 success:\n"; │ │ │ │ │ - 149 write_success<0>(projection, std::cout); │ │ │ │ │ - 150 std::cout << "Side 1 corners and images:\n"; │ │ │ │ │ - 151 write_points<1>(projection, corners, std::cout); │ │ │ │ │ - 152 std::cout << "Side 1 success:\n"; │ │ │ │ │ - 153 write_success<1>(projection, std::cout); │ │ │ │ │ - 154 std::cout << "Side 0 normals and projected normals:\n"; │ │ │ │ │ - 155 write_normals<0>(projection, normals, std::cout); │ │ │ │ │ - 156 std::cout << "Side 1 normals and projected normals:\n"; │ │ │ │ │ - 157 write_normals<1>(projection, normals, std::cout); │ │ │ │ │ - 158 std::cout << projection.numberOfEdgeIntersections() << " edge │ │ │ │ │ -intersections:\n"; │ │ │ │ │ - 159 write_edge_intersection_points(projection, corners, std::cout); │ │ │ │ │ - 160} │ │ │ │ │ - 161 │ │ │ │ │ - 162} /* namespace GridGlue */ │ │ │ │ │ - 163} /* namespace Dune */ │ │ │ │ │ + 26 return c; │ │ │ │ │ + 27} │ │ │ │ │ + 28 │ │ │ │ │ + 29} /* namespace GridGlue */ │ │ │ │ │ + 30} /* namespace Dune */ │ │ │ │ │ + 31 │ │ │ │ │ + 32#endif │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::write │ │ │ │ │ -void write(const Projection< Coordinate > &projection, const Corners &corners, │ │ │ │ │ -const Normals &normals, std::ostream &out) │ │ │ │ │ -write projection in VTK format │ │ │ │ │ -Definition: projectionwriter_impl.hh:86 │ │ │ │ │ -Dune::GridGlue::print │ │ │ │ │ -void print(const Projection< Coordinate > &projection, const Corners &corners, │ │ │ │ │ -const Normals &normals) │ │ │ │ │ -Print information about the projection to std::cout stream. │ │ │ │ │ -Definition: projectionwriter_impl.hh:140 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::interpolate │ │ │ │ │ -Corners::value_type interpolate(const Coordinate &x, const Corners &corners) │ │ │ │ │ -Definition: projection_impl.hh:70 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals │ │ │ │ │ -Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals │ │ │ │ │ -&normals) │ │ │ │ │ -Definition: projection_impl.hh:91 │ │ │ │ │ -Dune::GridGlue::ProjectionWriterImplementation::write_normals │ │ │ │ │ -void write_normals(const Projection< Coordinate > &projection, const Normals │ │ │ │ │ -&normals, std::ostream &out) │ │ │ │ │ -Definition: projectionwriter_impl.hh:27 │ │ │ │ │ -Dune::GridGlue::ProjectionWriterImplementation::write_points │ │ │ │ │ -void write_points(const Projection< Coordinate > &projection, const Corners │ │ │ │ │ -&corners, std::ostream &out) │ │ │ │ │ -Definition: projectionwriter_impl.hh:11 │ │ │ │ │ -Dune::GridGlue::ProjectionWriterImplementation::write_success │ │ │ │ │ -void write_success(const Projection< Coordinate > &projection, std::ostream │ │ │ │ │ -&out) │ │ │ │ │ -Definition: projectionwriter_impl.hh:72 │ │ │ │ │ -Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_points │ │ │ │ │ -void write_edge_intersection_points(const Projection< Coordinate > &projection, │ │ │ │ │ -const Corners &corners, std::ostream &out) │ │ │ │ │ -Definition: projectionwriter_impl.hh:43 │ │ │ │ │ -Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_normals │ │ │ │ │ -void write_edge_intersection_normals(const Projection< Coordinate > │ │ │ │ │ -&projection, const Normals &normals, std::ostream &out) │ │ │ │ │ -Definition: projectionwriter_impl.hh:56 │ │ │ │ │ -Dune::GridGlue::Projection │ │ │ │ │ -Projection of a line (triangle) on another line (triangle). │ │ │ │ │ -Definition: projection.hh:21 │ │ │ │ │ -Dune::GridGlue::Projection::success │ │ │ │ │ -const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const │ │ │ │ │ -Indicate whether projection (inverse projection) is valid for each corner or │ │ │ │ │ -not. │ │ │ │ │ -Definition: projection.hh:252 │ │ │ │ │ -Dune::GridGlue::Projection::numberOfEdgeIntersections │ │ │ │ │ -unsigned numberOfEdgeIntersections() const │ │ │ │ │ -Number of edge intersections. │ │ │ │ │ -Definition: projection.hh:262 │ │ │ │ │ -Dune::GridGlue::Projection::images │ │ │ │ │ -const std::tuple< Images, Preimages > & images() const │ │ │ │ │ -Images and preimages of corners. │ │ │ │ │ -Definition: projection.hh:235 │ │ │ │ │ -Dune::GridGlue::Projection::edgeIntersections │ │ │ │ │ -const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections │ │ │ │ │ -() const │ │ │ │ │ -Edge-edge intersections. │ │ │ │ │ -Definition: projection.hh:273 │ │ │ │ │ +Dune::GridGlue::crossProduct │ │ │ │ │ +static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim │ │ │ │ │ +> &a, const Dune::FieldVector< T, dim > &b) │ │ │ │ │ +compute cross product │ │ │ │ │ +Definition: crossproduct.hh:15 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: crossproduct.hh File Reference │ │ │ │ +dune-grid-glue: areawriter_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,35 +63,56 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
crossproduct.hh File Reference
│ │ │ │ +
areawriter_impl.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ +
#include <fstream>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/geometry/type.hh>
│ │ │ │ +#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::GridGlue::AreaWriterImplementation::FacetLayout< dimgrid >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
namespace  Dune::GridGlue::AreaWriterImplementation
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class T , int dim>
static Dune::FieldVector< T, dim > Dune::GridGlue::crossProduct (const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
 compute cross product More...
 
template<typename GridView >
void Dune::GridGlue::AreaWriterImplementation::write_facet_geometry (const GridView &gv, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string &filename)
 
template<typename Glue >
void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string &base)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,25 +5,44 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -crossproduct.hh File Reference │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +areawriter_impl.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +struct  Dune::GridGlue::AreaWriterImplementation::FacetLayout<_dimgrid_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +namespace  Dune::GridGlue::AreaWriterImplementation │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -static Dune::FieldVector< T, dim > Dune::GridGlue::crossProduct (const Dune:: │ │ │ │ │ - FieldVector< T, dim > &a, const Dune:: │ │ │ │ │ - FieldVector< T, dim > &b) │ │ │ │ │ -  compute cross product More... │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::AreaWriterImplementation::write_facet_geometry (const │ │ │ │ │ + GridView &gv, std::ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string │ │ │ │ │ + &filename) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string │ │ │ │ │ + &base) │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: crossproduct.hh Source File │ │ │ │ +dune-grid-glue: areawriter_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,46 +62,169 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
crossproduct.hh
│ │ │ │ +
areawriter_impl.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
│ │ │ │ +
3#include <fstream>
│ │ │ │ +
4#include <vector>
│ │ │ │
5
│ │ │ │ -
6namespace Dune {
│ │ │ │ -
7namespace GridGlue {
│ │ │ │ -
8
│ │ │ │ -
14template <class T, int dim>
│ │ │ │ -
15static Dune::FieldVector<T,dim> crossProduct(const Dune::FieldVector<T,dim>& a,
│ │ │ │ -
16 const Dune::FieldVector<T,dim>& b)
│ │ │ │ +
6#include <dune/common/fvector.hh>
│ │ │ │ +
7#include <dune/geometry/type.hh>
│ │ │ │ +
8#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +
9
│ │ │ │ +
10namespace Dune {
│ │ │ │ +
11namespace GridGlue {
│ │ │ │ +
12
│ │ │ │ +
13namespace AreaWriterImplementation {
│ │ │ │ +
14
│ │ │ │ +
15template<int dimgrid>
│ │ │ │ + │ │ │ │
17{
│ │ │ │ -
18 if (dim!=3)
│ │ │ │ -
19 DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension " << dim);
│ │ │ │ -
20
│ │ │ │ -
21 Dune::FieldVector<T,dim> c;
│ │ │ │ -
22 c[0] = a[1]*b[2] - a[2]*b[1];
│ │ │ │ -
23 c[1] = a[2]*b[0] - a[0]*b[2];
│ │ │ │ -
24 c[2] = a[0]*b[1] - a[1]*b[0];
│ │ │ │ -
25
│ │ │ │ -
26 return c;
│ │ │ │ -
27}
│ │ │ │ +
18 bool contains(Dune::GeometryType gt) const
│ │ │ │ +
19 {
│ │ │ │ +
20 return gt.dim() == dimgrid - 1;
│ │ │ │ +
21 }
│ │ │ │ +
22};
│ │ │ │ +
23
│ │ │ │ +
24template<typename GridView>
│ │ │ │ +
25void write_facet_geometry(const GridView& gv, std::ostream& out)
│ │ │ │ +
26{
│ │ │ │ +
27 using Coordinate = Dune::FieldVector<double, 3>;
│ │ │ │
28
│ │ │ │ -
29} /* namespace GridGlue */
│ │ │ │ -
30} /* namespace Dune */
│ │ │ │ -
31
│ │ │ │ -
32#endif
│ │ │ │ +
29 std::vector<Coordinate> corners;
│ │ │ │ +
30 for (const auto& facet : facets(gv)) {
│ │ │ │ +
31 const auto geometry = facet.geometry();
│ │ │ │ +
32 for (int i = 0; i < geometry.corners(); ++i) {
│ │ │ │ +
33 /* VTK always needs 3-dim coordinates... */
│ │ │ │ +
34 const auto c0 = geometry.corner(i);
│ │ │ │ +
35 Coordinate c1;
│ │ │ │ +
36 for (int d = 0; d < GridView::dimensionworld; ++d)
│ │ │ │ +
37 c1[d] = c0[d];
│ │ │ │ +
38 for (int d = GridView::dimensionworld; d < Coordinate::dimension; ++d)
│ │ │ │ +
39 c1[d] = double(0);
│ │ │ │ +
40 corners.push_back(c1);
│ │ │ │ +
41 }
│ │ │ │ +
42 }
│ │ │ │ +
43
│ │ │ │ +
44 {
│ │ │ │ +
45 out << "DATASET UNSTRUCTURED_GRID\n"
│ │ │ │ +
46 << "POINTS " << corners.size() << " double\n";
│ │ │ │ +
47 for (const auto& c : corners)
│ │ │ │ +
48 out << c << "\n";
│ │ │ │ +
49 }
│ │ │ │ +
50 {
│ │ │ │ +
51 out << "CELLS " << gv.size(1) << " " << (gv.size(1) + corners.size()) << "\n";
│ │ │ │ +
52 std::size_t c = 0;
│ │ │ │ +
53 for (const auto& facet : facets(gv)) {
│ │ │ │ +
54 const auto geometry = facet.geometry();
│ │ │ │ +
55 out << geometry.corners();
│ │ │ │ +
56 for (int i = 0; i < geometry.corners(); ++i, ++c)
│ │ │ │ +
57 out << " " << c;
│ │ │ │ +
58 out << "\n";
│ │ │ │ +
59 }
│ │ │ │ +
60 }
│ │ │ │ +
61 {
│ │ │ │ +
62 out << "CELL_TYPES " << gv.size(1) << "\n";
│ │ │ │ +
63 for (const auto& facet : facets(gv)) {
│ │ │ │ +
64 const auto type = facet.type();
│ │ │ │ +
65 if (type.isVertex())
│ │ │ │ +
66 out << "1\n";
│ │ │ │ +
67 else if (type.isLine())
│ │ │ │ +
68 out << "2\n";
│ │ │ │ +
69 else if (type.isTriangle())
│ │ │ │ +
70 out << "5\n";
│ │ │ │ +
71 else if (type.isQuadrilateral())
│ │ │ │ +
72 out << "9\n";
│ │ │ │ +
73 else if (type.isTetrahedron())
│ │ │ │ +
74 out << "10\n";
│ │ │ │ +
75 else
│ │ │ │ +
76 DUNE_THROW(Dune::Exception, "Unhandled geometry type");
│ │ │ │ +
77 }
│ │ │ │ +
78 }
│ │ │ │ +
79}
│ │ │ │ +
80
│ │ │ │ +
81} /* namespace AreaWriterImplementation */
│ │ │ │ +
82
│ │ │ │ +
83template<int side, typename Glue>
│ │ │ │ +
84void write_glue_area_vtk(const Glue& glue, std::ostream& out)
│ │ │ │ +
85{
│ │ │ │ +
86 using GridView = typename std::decay< decltype(glue.template gridView<side>()) >::type;
│ │ │ │ +
87 using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, AreaWriterImplementation::FacetLayout>;
│ │ │ │ +
88 using ctype = typename GridView::ctype;
│ │ │ │ +
89
│ │ │ │ +
90 const GridView gv = glue.template gridView<side>();
│ │ │ │ +
91 Mapper mapper(gv);
│ │ │ │ +
92 std::vector<ctype> coveredArea(mapper.size(), ctype(0));
│ │ │ │ +
93 std::vector<ctype> totalArea(mapper.size(), ctype(1));
│ │ │ │ +
94
│ │ │ │ +
95 for (const auto& in : intersections(glue, Reverse<side == 1>())) {
│ │ │ │ +
96 const auto element = in.inside();
│ │ │ │ +
97 const auto index = mapper.subIndex(element, in.indexInInside(), 1);
│ │ │ │ +
98 coveredArea[index] += in.geometryInInside().volume();
│ │ │ │ +
99
│ │ │ │ +
100 const auto& refElement = Dune::ReferenceElements<ctype, GridView::dimension>::general(element.type());
│ │ │ │ +
101 const auto& subGeometry = refElement.template geometry<1>(in.indexInInside());
│ │ │ │ +
102 totalArea[index] = subGeometry.volume();
│ │ │ │ +
103 }
│ │ │ │ +
104
│ │ │ │ +
105 for (std::size_t i = 0; i < coveredArea.size(); ++i)
│ │ │ │ +
106 coveredArea[i] /= totalArea[i];
│ │ │ │ +
107
│ │ │ │ +
108 out << "# vtk DataFile Version 2.0\n"
│ │ │ │ +
109 << "Filename: Glue Area\n"
│ │ │ │ +
110 << "ASCII\n";
│ │ │ │ +
111
│ │ │ │ + │ │ │ │ +
113
│ │ │ │ +
114 out << "CELL_DATA " << coveredArea.size() << "\n"
│ │ │ │ +
115 << "SCALARS CoveredArea double 1\n"
│ │ │ │ +
116 << "LOOKUP_TABLE default\n";
│ │ │ │ +
117 for (const auto& value : coveredArea)
│ │ │ │ +
118 out << value << "\n";
│ │ │ │ +
119}
│ │ │ │ +
120
│ │ │ │ +
121template<int side, typename Glue>
│ │ │ │ +
122void write_glue_area_vtk(const Glue& glue, const std::string& filename)
│ │ │ │ +
123{
│ │ │ │ +
124 std::ofstream out(filename.c_str());
│ │ │ │ +
125 write_glue_area_vtk<side>(glue, out);
│ │ │ │ +
126}
│ │ │ │ +
127
│ │ │ │ +
128template<typename Glue>
│ │ │ │ +
129void write_glue_areas_vtk(const Glue& glue, const std::string& base)
│ │ │ │ +
130{
│ │ │ │ +
131 {
│ │ │ │ +
132 std::string filename = base;
│ │ │ │ +
133 filename += "-inside.vtk";
│ │ │ │ +
134 write_glue_area_vtk<0>(glue, filename);
│ │ │ │ +
135 }
│ │ │ │ +
136 {
│ │ │ │ +
137 std::string filename = base;
│ │ │ │ +
138 filename += "-outside.vtk";
│ │ │ │ +
139 write_glue_area_vtk<1>(glue, filename);
│ │ │ │ +
140 }
│ │ │ │ +
141}
│ │ │ │ +
142
│ │ │ │ +
143} /* namespace GridGlue */
│ │ │ │ +
144} /* namespace Dune */
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
compute cross product
Definition: crossproduct.hh:15
│ │ │ │ +
void write_glue_area_vtk(const Glue &glue, std::ostream &out)
Definition: areawriter_impl.hh:84
│ │ │ │ +
void write_glue_areas_vtk(const Glue &glue, const std::string &base)
Definition: areawriter_impl.hh:129
│ │ │ │ +
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ +
void write_facet_geometry(const GridView &gv, std::ostream &out)
Definition: areawriter_impl.hh:25
│ │ │ │ +
Definition: rangegenerators.hh:17
│ │ │ │ + │ │ │ │ +
bool contains(Dune::GeometryType gt) const
Definition: areawriter_impl.hh:18
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,50 +5,185 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -crossproduct.hh │ │ │ │ │ +areawriter_impl.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH │ │ │ │ │ - 4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1 │ │ │ │ │ + 3#include │ │ │ │ │ + 4#include │ │ │ │ │ 5 │ │ │ │ │ - 6namespace Dune { │ │ │ │ │ - 7namespace GridGlue { │ │ │ │ │ - 8 │ │ │ │ │ - 14template │ │ │ │ │ -15static Dune::FieldVector crossProduct(const Dune::FieldVector& │ │ │ │ │ -a, │ │ │ │ │ - 16 const Dune::FieldVector& b) │ │ │ │ │ + 6#include │ │ │ │ │ + 7#include │ │ │ │ │ + 8#include │ │ │ │ │ + 9 │ │ │ │ │ + 10namespace Dune { │ │ │ │ │ + 11namespace GridGlue { │ │ │ │ │ + 12 │ │ │ │ │ +13namespace AreaWriterImplementation { │ │ │ │ │ + 14 │ │ │ │ │ + 15template │ │ │ │ │ +16struct FacetLayout │ │ │ │ │ 17{ │ │ │ │ │ - 18 if (dim!=3) │ │ │ │ │ - 19 DUNE_THROW(Dune::NotImplemented, "crossProduct does not work for dimension │ │ │ │ │ -" << dim); │ │ │ │ │ - 20 │ │ │ │ │ - 21 Dune::FieldVector c; │ │ │ │ │ - 22 c[0] = a[1]*b[2] - a[2]*b[1]; │ │ │ │ │ - 23 c[1] = a[2]*b[0] - a[0]*b[2]; │ │ │ │ │ - 24 c[2] = a[0]*b[1] - a[1]*b[0]; │ │ │ │ │ - 25 │ │ │ │ │ - 26 return c; │ │ │ │ │ - 27} │ │ │ │ │ +18 bool contains(Dune::GeometryType gt) const │ │ │ │ │ + 19 { │ │ │ │ │ + 20 return gt.dim() == dimgrid - 1; │ │ │ │ │ + 21 } │ │ │ │ │ + 22}; │ │ │ │ │ + 23 │ │ │ │ │ + 24template │ │ │ │ │ +25void write_facet_geometry(const GridView& gv, std::ostream& out) │ │ │ │ │ + 26{ │ │ │ │ │ + 27 using Coordinate = Dune::FieldVector; │ │ │ │ │ 28 │ │ │ │ │ - 29} /* namespace GridGlue */ │ │ │ │ │ - 30} /* namespace Dune */ │ │ │ │ │ - 31 │ │ │ │ │ - 32#endif │ │ │ │ │ + 29 std::vector corners; │ │ │ │ │ + 30 for (const auto& facet : facets(gv)) { │ │ │ │ │ + 31 const auto geometry = facet.geometry(); │ │ │ │ │ + 32 for (int i = 0; i < geometry.corners(); ++i) { │ │ │ │ │ + 33 /* VTK always needs 3-dim coordinates... */ │ │ │ │ │ + 34 const auto c0 = geometry.corner(i); │ │ │ │ │ + 35 Coordinate c1; │ │ │ │ │ + 36 for (int d = 0; d < GridView::dimensionworld; ++d) │ │ │ │ │ + 37 c1[d] = c0[d]; │ │ │ │ │ + 38 for (int d = GridView::dimensionworld; d < Coordinate::dimension; ++d) │ │ │ │ │ + 39 c1[d] = double(0); │ │ │ │ │ + 40 corners.push_back(c1); │ │ │ │ │ + 41 } │ │ │ │ │ + 42 } │ │ │ │ │ + 43 │ │ │ │ │ + 44 { │ │ │ │ │ + 45 out << "DATASET UNSTRUCTURED_GRID\n" │ │ │ │ │ + 46 << "POINTS " << corners.size() << " double\n"; │ │ │ │ │ + 47 for (const auto& c : corners) │ │ │ │ │ + 48 out << c << "\n"; │ │ │ │ │ + 49 } │ │ │ │ │ + 50 { │ │ │ │ │ + 51 out << "CELLS " << gv.size(1) << " " << (gv.size(1) + corners.size()) << │ │ │ │ │ +"\n"; │ │ │ │ │ + 52 std::size_t c = 0; │ │ │ │ │ + 53 for (const auto& facet : facets(gv)) { │ │ │ │ │ + 54 const auto geometry = facet.geometry(); │ │ │ │ │ + 55 out << geometry.corners(); │ │ │ │ │ + 56 for (int i = 0; i < geometry.corners(); ++i, ++c) │ │ │ │ │ + 57 out << " " << c; │ │ │ │ │ + 58 out << "\n"; │ │ │ │ │ + 59 } │ │ │ │ │ + 60 } │ │ │ │ │ + 61 { │ │ │ │ │ + 62 out << "CELL_TYPES " << gv.size(1) << "\n"; │ │ │ │ │ + 63 for (const auto& facet : facets(gv)) { │ │ │ │ │ + 64 const auto type = facet.type(); │ │ │ │ │ + 65 if (type.isVertex()) │ │ │ │ │ + 66 out << "1\n"; │ │ │ │ │ + 67 else if (type.isLine()) │ │ │ │ │ + 68 out << "2\n"; │ │ │ │ │ + 69 else if (type.isTriangle()) │ │ │ │ │ + 70 out << "5\n"; │ │ │ │ │ + 71 else if (type.isQuadrilateral()) │ │ │ │ │ + 72 out << "9\n"; │ │ │ │ │ + 73 else if (type.isTetrahedron()) │ │ │ │ │ + 74 out << "10\n"; │ │ │ │ │ + 75 else │ │ │ │ │ + 76 DUNE_THROW(Dune::Exception, "Unhandled geometry type"); │ │ │ │ │ + 77 } │ │ │ │ │ + 78 } │ │ │ │ │ + 79} │ │ │ │ │ + 80 │ │ │ │ │ + 81} /* namespace AreaWriterImplementation */ │ │ │ │ │ + 82 │ │ │ │ │ + 83template │ │ │ │ │ +84void write_glue_area_vtk(const Glue& glue, std::ostream& out) │ │ │ │ │ + 85{ │ │ │ │ │ + 86 using GridView = typename std::decay< decltype(glue.template gridView │ │ │ │ │ +()) >::type; │ │ │ │ │ + 87 using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper; │ │ │ │ │ + 88 using ctype = typename GridView::ctype; │ │ │ │ │ + 89 │ │ │ │ │ + 90 const GridView gv = glue.template gridView(); │ │ │ │ │ + 91 Mapper mapper(gv); │ │ │ │ │ + 92 std::vector coveredArea(mapper.size(), ctype(0)); │ │ │ │ │ + 93 std::vector totalArea(mapper.size(), ctype(1)); │ │ │ │ │ + 94 │ │ │ │ │ + 95 for (const auto& in : intersections(glue, Reverse())) { │ │ │ │ │ + 96 const auto element = in.inside(); │ │ │ │ │ + 97 const auto index = mapper.subIndex(element, in.indexInInside(), 1); │ │ │ │ │ + 98 coveredArea[index] += in.geometryInInside().volume(); │ │ │ │ │ + 99 │ │ │ │ │ + 100 const auto& refElement = Dune::ReferenceElements::general(element.type()); │ │ │ │ │ + 101 const auto& subGeometry = refElement.template geometry<1>(in.indexInInside │ │ │ │ │ +()); │ │ │ │ │ + 102 totalArea[index] = subGeometry.volume(); │ │ │ │ │ + 103 } │ │ │ │ │ + 104 │ │ │ │ │ + 105 for (std::size_t i = 0; i < coveredArea.size(); ++i) │ │ │ │ │ + 106 coveredArea[i] /= totalArea[i]; │ │ │ │ │ + 107 │ │ │ │ │ + 108 out << "# vtk DataFile Version 2.0\n" │ │ │ │ │ + 109 << "Filename: Glue Area\n" │ │ │ │ │ + 110 << "ASCII\n"; │ │ │ │ │ + 111 │ │ │ │ │ + 112 AreaWriterImplementation::write_facet_geometry(gv, out); │ │ │ │ │ + 113 │ │ │ │ │ + 114 out << "CELL_DATA " << coveredArea.size() << "\n" │ │ │ │ │ + 115 << "SCALARS CoveredArea double 1\n" │ │ │ │ │ + 116 << "LOOKUP_TABLE default\n"; │ │ │ │ │ + 117 for (const auto& value : coveredArea) │ │ │ │ │ + 118 out << value << "\n"; │ │ │ │ │ + 119} │ │ │ │ │ + 120 │ │ │ │ │ + 121template │ │ │ │ │ +122void write_glue_area_vtk(const Glue& glue, const std::string& filename) │ │ │ │ │ + 123{ │ │ │ │ │ + 124 std::ofstream out(filename.c_str()); │ │ │ │ │ + 125 write_glue_area_vtk(glue, out); │ │ │ │ │ + 126} │ │ │ │ │ + 127 │ │ │ │ │ + 128template │ │ │ │ │ +129void write_glue_areas_vtk(const Glue& glue, const std::string& base) │ │ │ │ │ + 130{ │ │ │ │ │ + 131 { │ │ │ │ │ + 132 std::string filename = base; │ │ │ │ │ + 133 filename += "-inside.vtk"; │ │ │ │ │ + 134 write_glue_area_vtk<0>(glue, filename); │ │ │ │ │ + 135 } │ │ │ │ │ + 136 { │ │ │ │ │ + 137 std::string filename = base; │ │ │ │ │ + 138 filename += "-outside.vtk"; │ │ │ │ │ + 139 write_glue_area_vtk<1>(glue, filename); │ │ │ │ │ + 140 } │ │ │ │ │ + 141} │ │ │ │ │ + 142 │ │ │ │ │ + 143} /* namespace GridGlue */ │ │ │ │ │ + 144} /* namespace Dune */ │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::crossProduct │ │ │ │ │ -static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim │ │ │ │ │ -> &a, const Dune::FieldVector< T, dim > &b) │ │ │ │ │ -compute cross product │ │ │ │ │ -Definition: crossproduct.hh:15 │ │ │ │ │ +Dune::GridGlue::write_glue_area_vtk │ │ │ │ │ +void write_glue_area_vtk(const Glue &glue, std::ostream &out) │ │ │ │ │ +Definition: areawriter_impl.hh:84 │ │ │ │ │ +Dune::GridGlue::write_glue_areas_vtk │ │ │ │ │ +void write_glue_areas_vtk(const Glue &glue, const std::string &base) │ │ │ │ │ +Definition: areawriter_impl.hh:129 │ │ │ │ │ +Dune::GridGlue::intersections │ │ │ │ │ +IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ +> &reverse=!reversed) │ │ │ │ │ +Iterate over all intersections of a GridGlue. │ │ │ │ │ +Dune::GridGlue::AreaWriterImplementation::write_facet_geometry │ │ │ │ │ +void write_facet_geometry(const GridView &gv, std::ostream &out) │ │ │ │ │ +Definition: areawriter_impl.hh:25 │ │ │ │ │ +Dune::GridGlue::Reverse │ │ │ │ │ +Definition: rangegenerators.hh:17 │ │ │ │ │ +Dune::GridGlue::AreaWriterImplementation::FacetLayout │ │ │ │ │ +Definition: areawriter_impl.hh:17 │ │ │ │ │ +Dune::GridGlue::AreaWriterImplementation::FacetLayout::contains │ │ │ │ │ +bool contains(Dune::GeometryType gt) const │ │ │ │ │ +Definition: areawriter_impl.hh:18 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter.hh File Reference │ │ │ │ +dune-grid-glue: ringcomm.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,43 +64,77 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ +Macros | │ │ │ │ Functions
│ │ │ │ -
areawriter.hh File Reference
│ │ │ │ +
ringcomm.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <ostream>
│ │ │ │ -#include <string>
│ │ │ │ -#include "areawriter_impl.hh"
│ │ │ │ +
#include <mpi.h>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/common/hybridutilities.hh>
│ │ │ │ +#include <dune/geometry/type.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
namespace  Dune::Parallel
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Macros

#define CheckMPIStatus(A, B)   {}
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string &filename)
 
template<typename Glue >
void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string &base)
 
template<typename OP , typename... Args>
void Dune::Parallel::MPI_AllApply (MPI_Comm mpicomm, OP &&op, const Args &... data)
 apply an operator locally to a difstributed data set More...
 
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ CheckMPIStatus

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define CheckMPIStatus( A,
 
)   {}
│ │ │ │ +
│ │ │ │ +
Todo:
Implement MPI Status check with exception handling
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,33 +5,40 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -areawriter.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "areawriter_impl.hh" │ │ │ │ │ +Namespaces | Macros | Functions │ │ │ │ │ +ringcomm.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ -namespace  Dune::GridGlue │ │ │ │ │ +namespace  Dune::Parallel │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string │ │ │ │ │ - &filename) │ │ │ │ │ + Macros │ │ │ │ │ +#define CheckMPIStatus(A, B)   {} │ │ │ │ │   │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string │ │ │ │ │ - &base) │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +void Dune::Parallel::MPI_AllApply (MPI_Comm mpicomm, OP &&op, const Args &... │ │ │ │ │ + data) │ │ │ │ │ +  apply an operator locally to a difstributed data set More... │ │ │ │ │   │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ CheckMPIStatus ***** │ │ │ │ │ +#define CheckMPIStatus (  A, │ │ │ │ │ +  B  │ │ │ │ │ + )    {} │ │ │ │ │ + Todo: │ │ │ │ │ + Implement MPI Status check with exception handling │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter.hh Source File │ │ │ │ +dune-grid-glue: ringcomm.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,47 +62,305 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
areawriter.hh
│ │ │ │ +
ringcomm.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │ -
5
│ │ │ │ -
6#include <ostream>
│ │ │ │ -
7#include <string>
│ │ │ │ -
8
│ │ │ │ -
9namespace Dune {
│ │ │ │ -
10namespace GridGlue {
│ │ │ │ -
11
│ │ │ │ -
12template<int side, typename Glue>
│ │ │ │ -
13void write_glue_area_vtk(const Glue& glue, std::ostream& out);
│ │ │ │ -
14
│ │ │ │ -
15template<int side, typename Glue>
│ │ │ │ -
16void write_glue_area_vtk(const Glue& glue, const std::string& filename);
│ │ │ │ -
17
│ │ │ │ -
37template<typename Glue>
│ │ │ │ -
38void write_glue_areas_vtk(const Glue& glue, const std::string& base);
│ │ │ │ -
39
│ │ │ │ -
40} /* namespace GridGlue */
│ │ │ │ -
41} /* namespace Dune */
│ │ │ │ -
42
│ │ │ │ -
43#include "areawriter_impl.hh"
│ │ │ │ -
44
│ │ │ │ -
45#endif
│ │ │ │ - │ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ +
5/* IMPLEMENTATION OF CLASS G R I D G L U E */
│ │ │ │ +
6
│ │ │ │ +
8#define CheckMPIStatus(A,B) {}
│ │ │ │ +
9
│ │ │ │ +
10#include <mpi.h>
│ │ │ │ +
11#include <functional>
│ │ │ │ +
12#include <utility>
│ │ │ │ +
13
│ │ │ │ +
14#include <dune/common/fvector.hh>
│ │ │ │ +
15#include <dune/common/hybridutilities.hh>
│ │ │ │ +
16
│ │ │ │ +
17#include <dune/geometry/type.hh>
│ │ │ │ +
18
│ │ │ │ +
19namespace Dune {
│ │ │ │ +
20namespace Parallel {
│ │ │ │ +
21
│ │ │ │ +
22 namespace Impl {
│ │ │ │ +
23
│ │ │ │ +
25 template<typename T>
│ │ │ │ +
26 struct MPITypeInfo {};
│ │ │ │ +
27
│ │ │ │ +
28 template<>
│ │ │ │ +
29 struct MPITypeInfo< int >
│ │ │ │ +
30 {
│ │ │ │ +
31 static const unsigned int size = 1;
│ │ │ │ +
32 static inline MPI_Datatype getType()
│ │ │ │ +
33 {
│ │ │ │ +
34 return MPI_INT;
│ │ │ │ +
35 }
│ │ │ │ +
36 };
│ │ │ │ +
37
│ │ │ │ +
38 template<typename K, int N>
│ │ │ │ +
39 struct MPITypeInfo< Dune::FieldVector<K,N> >
│ │ │ │ +
40 {
│ │ │ │ +
41 static const unsigned int size = N;
│ │ │ │ +
42 static inline MPI_Datatype getType()
│ │ │ │ +
43 {
│ │ │ │ +
44 return Dune::MPITraits<K>::getType();
│ │ │ │ +
45 }
│ │ │ │ +
46 };
│ │ │ │ +
47
│ │ │ │ +
48 template<>
│ │ │ │ +
49 struct MPITypeInfo< unsigned int >
│ │ │ │ +
50 {
│ │ │ │ +
51 static const unsigned int size = 1;
│ │ │ │ +
52 static inline MPI_Datatype getType()
│ │ │ │ +
53 {
│ │ │ │ +
54 return MPI_UNSIGNED;
│ │ │ │ +
55 }
│ │ │ │ +
56 };
│ │ │ │ +
57
│ │ │ │ +
58 template<>
│ │ │ │ +
59 struct MPITypeInfo< Dune::GeometryType >
│ │ │ │ +
60 {
│ │ │ │ +
61 static const unsigned int size = 1;
│ │ │ │ +
62 static inline MPI_Datatype getType()
│ │ │ │ +
63 {
│ │ │ │ +
64 return Dune::MPITraits< Dune::GeometryType >::getType();
│ │ │ │ +
65 }
│ │ │ │ +
66 };
│ │ │ │ +
67
│ │ │ │ +
68 template<typename T>
│ │ │ │ +
69 void MPI_SetVectorSize(
│ │ │ │ +
70 std::vector<T> & data,
│ │ │ │ +
71 MPI_Status & status)
│ │ │ │ +
72 {
│ │ │ │ +
73 typedef MPITypeInfo<T> Info;
│ │ │ │ +
74 int sz;
│ │ │ │ +
75 MPI_Get_count(&status, Info::getType(), &sz);
│ │ │ │ +
76 assert(sz%Info::size == 0);
│ │ │ │ +
77 data.resize(sz/Info::size);
│ │ │ │ +
78 }
│ │ │ │ +
79
│ │ │ │ +
89 template<typename T>
│ │ │ │ +
90 void MPI_SendVectorInRing(
│ │ │ │ +
91 std::vector<T> & data,
│ │ │ │ +
92 std::vector<T> & next,
│ │ │ │ +
93 int tag,
│ │ │ │ +
94 int rightrank,
│ │ │ │ +
95 int leftrank,
│ │ │ │ +
96 MPI_Comm comm,
│ │ │ │ +
97 MPI_Request& r_send,
│ │ │ │ +
98 MPI_Request& r_recv
│ │ │ │ +
99 )
│ │ │ │ +
100 {
│ │ │ │ +
101 // mpi status stuff
│ │ │ │ +
102 [[maybe_unused]] int result = 0;
│ │ │ │ +
103 typedef MPITypeInfo<T> Info;
│ │ │ │ +
104 // resize next buffer to maximum size
│ │ │ │ +
105 next.resize(next.capacity());
│ │ │ │ +
106 // send data (explicitly send data.size elements)
│ │ │ │ +
107 result =
│ │ │ │ +
108 MPI_Isend(
│ │ │ │ +
109 &(data[0]), Info::size*data.size(), Info::getType(), rightrank, tag,
│ │ │ │ +
110 comm, &r_send);
│ │ │ │ +
111 // receive up to maximum size. The acutal size is stored in the status
│ │ │ │ +
112 result =
│ │ │ │ +
113 MPI_Irecv(
│ │ │ │ +
114 &(next[0]), Info::size*next.size(), Info::getType(), leftrank, tag,
│ │ │ │ +
115 comm, &r_recv);
│ │ │ │ +
116 // // check result
│ │ │ │ +
117 // MPI_Status status;
│ │ │ │ +
118 // CheckMPIStatus(result, status);
│ │ │ │ +
119 }
│ │ │ │ +
120
│ │ │ │ +
121 template<typename T>
│ │ │ │ +
122 using ptr_t = T*;
│ │ │ │ +
123
│ │ │ │ +
124 /* these helper structs are needed as long as we still support
│ │ │ │ +
125 C++11, as we can't use variadic lambdas */
│ │ │ │ +
126 template<typename... Args>
│ │ │ │ +
127 struct call_MPI_SendVectorInRing
│ │ │ │ +
128 {
│ │ │ │ +
129 std::tuple<Args...> & remotedata;
│ │ │ │ +
130 std::tuple<Args...> & nextdata;
│ │ │ │ +
131 int & tag;
│ │ │ │ +
132 int & rightrank;
│ │ │ │ +
133 int & leftrank;
│ │ │ │ +
134 MPI_Comm & mpicomm;
│ │ │ │ +
135 std::array<MPI_Request,sizeof...(Args)> & requests_send;
│ │ │ │ +
136 std::array<MPI_Request,sizeof...(Args)> & requests_recv;
│ │ │ │ +
137
│ │ │ │ +
138 template<typename I>
│ │ │ │ +
139 void operator()(I i)
│ │ │ │ +
140 {
│ │ │ │ +
141 MPI_SendVectorInRing(
│ │ │ │ +
142 std::get<i>(remotedata),
│ │ │ │ +
143 std::get<i>(nextdata),
│ │ │ │ +
144 tag+i,
│ │ │ │ +
145 rightrank, leftrank, mpicomm,
│ │ │ │ +
146 requests_send[i],
│ │ │ │ +
147 requests_recv[i]);
│ │ │ │ +
148 }
│ │ │ │ +
149 };
│ │ │ │ +
150 template<typename... Args>
│ │ │ │ +
151 struct call_MPI_SetVectorSize
│ │ │ │ +
152 {
│ │ │ │ +
153 std::tuple<Args...> & nextdata;
│ │ │ │ +
154 std::array<MPI_Status,sizeof...(Args)> & status_recv;
│ │ │ │ +
155
│ │ │ │ +
156 template<typename I>
│ │ │ │ +
157 void operator()(I i)
│ │ │ │ +
158 {
│ │ │ │ +
159 MPI_SetVectorSize(std::get<i>(nextdata),status_recv[i]);
│ │ │ │ +
160 }
│ │ │ │ +
161 };
│ │ │ │ +
162
│ │ │ │ +
163 template<typename OP, std::size_t... Indices, typename... Args>
│ │ │ │ +
164 void MPI_AllApply_impl(MPI_Comm mpicomm,
│ │ │ │ +
165 OP && op,
│ │ │ │ +
166 std::index_sequence<Indices...> indices,
│ │ │ │ +
167 const Args&... data)
│ │ │ │ +
168 {
│ │ │ │ +
169 constexpr std::size_t N = sizeof...(Args);
│ │ │ │ +
170 int myrank = 0;
│ │ │ │ +
171 int commsize = 0;
│ │ │ │ +
172#if HAVE_MPI
│ │ │ │ +
173 MPI_Comm_rank(mpicomm, &myrank);
│ │ │ │ +
174 MPI_Comm_size(mpicomm, &commsize);
│ │ │ │ +
175#endif // HAVE_MPI
│ │ │ │ +
176
│ │ │ │ +
177 if (commsize > 1)
│ │ │ │ +
178 {
│ │ │ │ +
179#ifdef DEBUG_GRIDGLUE_PARALLELMERGE
│ │ │ │ +
180 std::cout << myrank << " Start Communication, size " << commsize << std::endl;
│ │ │ │ +
181#endif
│ │ │ │ +
182
│ │ │ │ +
183 // get data sizes
│ │ │ │ +
184 std::array<unsigned int, N> size({ ((unsigned int)data.size())... });
│ │ │ │ +
185
│ │ │ │ +
186 // communicate max data size
│ │ │ │ +
187 std::array<unsigned int, N> maxSize;
│ │ │ │ +
188 MPI_Allreduce(&size, &maxSize,
│ │ │ │ +
189 size.size(), MPI_UNSIGNED, MPI_MAX, mpicomm);
│ │ │ │ +
190#ifdef DEBUG_GRIDGLUE_PARALLELMERGE
│ │ │ │ +
191 std::cout << myrank << " maxSize " << "done... " << std::endl;
│ │ │ │ +
192#endif
│ │ │ │ +
193
│ │ │ │ +
194 // allocate receiving buffers with maxsize to ensure sufficient buffer size for communication
│ │ │ │ +
195 std::tuple<Args...> remotedata { Args(maxSize[Indices])... };
│ │ │ │ +
196
│ │ │ │ +
197 // copy local data to receiving buffer
│ │ │ │ +
198 remotedata = std::tie(data...);
│ │ │ │ +
199
│ │ │ │ +
200 // allocate second set of receiving buffers necessary for async communication
│ │ │ │ +
201 std::tuple<Args...> nextdata { Args(maxSize[Indices])... };
│ │ │ │ +
202
│ │ │ │ +
203 // communicate data in the ring
│ │ │ │ +
204 int rightrank = (myrank + 1 + commsize) % commsize;
│ │ │ │ +
205 int leftrank = (myrank - 1 + commsize) % commsize;
│ │ │ │ +
206
│ │ │ │ +
207 std::cout << myrank << ": size = " << commsize << std::endl;
│ │ │ │ +
208 std::cout << myrank << ": left = " << leftrank
│ │ │ │ +
209 << " right = " << rightrank << std::endl;
│ │ │ │ +
210
│ │ │ │ +
211 // currently the remote data is our own data
│ │ │ │ +
212 int remoterank = myrank;
│ │ │ │ +
213
│ │ │ │ +
214 for (int i=1; i<commsize; i++)
│ │ │ │ +
215 {
│ │ │ │ +
216 // in this iteration we will receive data from nextrank
│ │ │ │ +
217 int nextrank = (myrank - i + commsize) % commsize;
│ │ │ │ +
218
│ │ │ │ +
219 std::cout << myrank << ": next = " << nextrank << std::endl;
│ │ │ │ +
220
│ │ │ │ +
221 // send remote data to right neighbor and receive from left neighbor
│ │ │ │ +
222 std::array<MPI_Request,N> requests_send;
│ │ │ │ +
223 std::array<MPI_Request,N> requests_recv;
│ │ │ │ +
224
│ │ │ │ +
225 int tag = 0;
│ │ │ │ +
226 Dune::Hybrid::forEach(indices,
│ │ │ │ +
227 // [&](auto i){
│ │ │ │ +
228 // MPI_SendVectorInRing(
│ │ │ │ +
229 // std::get<i>(remotedata),
│ │ │ │ +
230 // std::get<i>(nextdata),
│ │ │ │ +
231 // tag+i,
│ │ │ │ +
232 // rightrank, leftrank, mpicomm,
│ │ │ │ +
233 // requests_send[i],
│ │ │ │ +
234 // requests_recv[i]);
│ │ │ │ +
235 // });
│ │ │ │ +
236 call_MPI_SendVectorInRing<Args...>({
│ │ │ │ +
237 remotedata,
│ │ │ │ +
238 nextdata,
│ │ │ │ +
239 tag,
│ │ │ │ +
240 rightrank, leftrank, mpicomm,
│ │ │ │ +
241 requests_send,
│ │ │ │ +
242 requests_recv
│ │ │ │ +
243 }));
│ │ │ │ +
244
│ │ │ │ +
245 // apply operator
│ │ │ │ +
246 op(remoterank,std::get<Indices>(remotedata)...);
│ │ │ │ +
247
│ │ │ │ +
248 // wait for communication to finalize
│ │ │ │ +
249 std::array<MPI_Status,N> status_send;
│ │ │ │ +
250 std::array<MPI_Status,N> status_recv;
│ │ │ │ +
251 MPI_Waitall(N,&requests_recv[0],&status_recv[0]);
│ │ │ │ +
252
│ │ │ │ +
253 // we finished receiving from nextrank and thus remoterank = nextrank
│ │ │ │ +
254 remoterank = nextrank;
│ │ │ │ +
255
│ │ │ │ +
256 // get current data sizes
│ │ │ │ +
257 // and resize vectors
│ │ │ │ +
258 Dune::Hybrid::forEach(indices,
│ │ │ │ +
259 // [&](auto i){
│ │ │ │ +
260 // MPI_SetVectorSize(std::get<i>(nextdata),status_recv[i]);
│ │ │ │ +
261 // });
│ │ │ │ +
262 call_MPI_SetVectorSize<Args...>({
│ │ │ │ +
263 nextdata, status_recv
│ │ │ │ +
264 }));
│ │ │ │ +
265
│ │ │ │ +
266 MPI_Waitall(N,&requests_send[0],&status_send[0]);
│ │ │ │ +
267
│ │ │ │ +
268 // swap the communication buffers
│ │ │ │ +
269 std::swap(remotedata,nextdata);
│ │ │ │ +
270 }
│ │ │ │ +
271
│ │ │ │ +
272 // last apply (or the only one in the case of sequential application)
│ │ │ │ +
273 op(remoterank,std::get<Indices>(remotedata)...);
│ │ │ │ +
274 }
│ │ │ │ +
275 else // sequential
│ │ │ │ +
276 {
│ │ │ │ +
277 op(myrank,data...);
│ │ │ │ +
278 }
│ │ │ │ +
279 }
│ │ │ │ +
280
│ │ │ │ +
281 } // end namespace Impl
│ │ │ │ +
282
│ │ │ │ +
296template<typename OP, typename... Args>
│ │ │ │ +
297void MPI_AllApply(MPI_Comm mpicomm,
│ │ │ │ +
298 OP && op,
│ │ │ │ +
299 const Args& ... data)
│ │ │ │ +
300{
│ │ │ │ +
301 Impl::MPI_AllApply_impl(
│ │ │ │ +
302 mpicomm,
│ │ │ │ +
303 std::forward<OP>(op),
│ │ │ │ +
304 std::make_index_sequence<sizeof...(Args)>(),
│ │ │ │ +
305 data...
│ │ │ │ +
306 );
│ │ │ │ +
307}
│ │ │ │ +
308
│ │ │ │ +
309} // end namespace Parallel
│ │ │ │ +
310} // end namespace Dune
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
void write_glue_area_vtk(const Glue &glue, std::ostream &out)
Definition: areawriter_impl.hh:84
│ │ │ │ -
void write_glue_areas_vtk(const Glue &glue, const std::string &base)
Definition: areawriter_impl.hh:129
│ │ │ │ +
void MPI_AllApply(MPI_Comm mpicomm, OP &&op, const Args &... data)
apply an operator locally to a difstributed data set
Definition: ringcomm.hh:297
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,49 +5,309 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -areawriter.hh │ │ │ │ │ +ringcomm.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ + 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ + 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ + 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ - 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ + 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ - 4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8 │ │ │ │ │ - 9namespace Dune { │ │ │ │ │ - 10namespace GridGlue { │ │ │ │ │ - 11 │ │ │ │ │ - 12template │ │ │ │ │ - 13void write_glue_area_vtk(const Glue& glue, std::ostream& out); │ │ │ │ │ - 14 │ │ │ │ │ - 15template │ │ │ │ │ - 16void write_glue_area_vtk(const Glue& glue, const std::string& filename); │ │ │ │ │ - 17 │ │ │ │ │ - 37template │ │ │ │ │ - 38void write_glue_areas_vtk(const Glue& glue, const std::string& base); │ │ │ │ │ - 39 │ │ │ │ │ - 40} /* namespace GridGlue */ │ │ │ │ │ - 41} /* namespace Dune */ │ │ │ │ │ - 42 │ │ │ │ │ - 43#include "areawriter_impl.hh" │ │ │ │ │ - 44 │ │ │ │ │ - 45#endif │ │ │ │ │ -areawriter_impl.hh │ │ │ │ │ + 5/* IMPLEMENTATION OF CLASS G R I D G L U E */ │ │ │ │ │ + 6 │ │ │ │ │ +8#define CheckMPIStatus(A,B) {} │ │ │ │ │ + 9 │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12#include │ │ │ │ │ + 13 │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16 │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19namespace Dune { │ │ │ │ │ +20namespace Parallel { │ │ │ │ │ + 21 │ │ │ │ │ + 22 namespace Impl { │ │ │ │ │ + 23 │ │ │ │ │ + 25 template │ │ │ │ │ + 26 struct MPITypeInfo {}; │ │ │ │ │ + 27 │ │ │ │ │ + 28 template<> │ │ │ │ │ + 29 struct MPITypeInfo< int > │ │ │ │ │ + 30 { │ │ │ │ │ + 31 static const unsigned int size = 1; │ │ │ │ │ + 32 static inline MPI_Datatype getType() │ │ │ │ │ + 33 { │ │ │ │ │ + 34 return MPI_INT; │ │ │ │ │ + 35 } │ │ │ │ │ + 36 }; │ │ │ │ │ + 37 │ │ │ │ │ + 38 template │ │ │ │ │ + 39 struct MPITypeInfo< Dune::FieldVector > │ │ │ │ │ + 40 { │ │ │ │ │ + 41 static const unsigned int size = N; │ │ │ │ │ + 42 static inline MPI_Datatype getType() │ │ │ │ │ + 43 { │ │ │ │ │ + 44 return Dune::MPITraits::getType(); │ │ │ │ │ + 45 } │ │ │ │ │ + 46 }; │ │ │ │ │ + 47 │ │ │ │ │ + 48 template<> │ │ │ │ │ + 49 struct MPITypeInfo< unsigned int > │ │ │ │ │ + 50 { │ │ │ │ │ + 51 static const unsigned int size = 1; │ │ │ │ │ + 52 static inline MPI_Datatype getType() │ │ │ │ │ + 53 { │ │ │ │ │ + 54 return MPI_UNSIGNED; │ │ │ │ │ + 55 } │ │ │ │ │ + 56 }; │ │ │ │ │ + 57 │ │ │ │ │ + 58 template<> │ │ │ │ │ + 59 struct MPITypeInfo< Dune::GeometryType > │ │ │ │ │ + 60 { │ │ │ │ │ + 61 static const unsigned int size = 1; │ │ │ │ │ + 62 static inline MPI_Datatype getType() │ │ │ │ │ + 63 { │ │ │ │ │ + 64 return Dune::MPITraits< Dune::GeometryType >::getType(); │ │ │ │ │ + 65 } │ │ │ │ │ + 66 }; │ │ │ │ │ + 67 │ │ │ │ │ + 68 template │ │ │ │ │ + 69 void MPI_SetVectorSize( │ │ │ │ │ + 70 std::vector & data, │ │ │ │ │ + 71 MPI_Status & status) │ │ │ │ │ + 72 { │ │ │ │ │ + 73 typedef MPITypeInfo Info; │ │ │ │ │ + 74 int sz; │ │ │ │ │ + 75 MPI_Get_count(&status, Info::getType(), &sz); │ │ │ │ │ + 76 assert(sz%Info::size == 0); │ │ │ │ │ + 77 data.resize(sz/Info::size); │ │ │ │ │ + 78 } │ │ │ │ │ + 79 │ │ │ │ │ + 89 template │ │ │ │ │ + 90 void MPI_SendVectorInRing( │ │ │ │ │ + 91 std::vector & data, │ │ │ │ │ + 92 std::vector & next, │ │ │ │ │ + 93 int tag, │ │ │ │ │ + 94 int rightrank, │ │ │ │ │ + 95 int leftrank, │ │ │ │ │ + 96 MPI_Comm comm, │ │ │ │ │ + 97 MPI_Request& r_send, │ │ │ │ │ + 98 MPI_Request& r_recv │ │ │ │ │ + 99 ) │ │ │ │ │ + 100 { │ │ │ │ │ + 101 // mpi status stuff │ │ │ │ │ + 102 [[maybe_unused]] int result = 0; │ │ │ │ │ + 103 typedef MPITypeInfo Info; │ │ │ │ │ + 104 // resize next buffer to maximum size │ │ │ │ │ + 105 next.resize(next.capacity()); │ │ │ │ │ + 106 // send data (explicitly send data.size elements) │ │ │ │ │ + 107 result = │ │ │ │ │ + 108 MPI_Isend( │ │ │ │ │ + 109 &(data[0]), Info::size*data.size(), Info::getType(), rightrank, tag, │ │ │ │ │ + 110 comm, &r_send); │ │ │ │ │ + 111 // receive up to maximum size. The acutal size is stored in the status │ │ │ │ │ + 112 result = │ │ │ │ │ + 113 MPI_Irecv( │ │ │ │ │ + 114 &(next[0]), Info::size*next.size(), Info::getType(), leftrank, tag, │ │ │ │ │ + 115 comm, &r_recv); │ │ │ │ │ + 116 // // check result │ │ │ │ │ + 117 // MPI_Status status; │ │ │ │ │ + 118 // CheckMPIStatus(result, status); │ │ │ │ │ + 119 } │ │ │ │ │ + 120 │ │ │ │ │ + 121 template │ │ │ │ │ + 122 using ptr_t = T*; │ │ │ │ │ + 123 │ │ │ │ │ + 124 /* these helper structs are needed as long as we still support │ │ │ │ │ + 125 C++11, as we can't use variadic lambdas */ │ │ │ │ │ + 126 template │ │ │ │ │ + 127 struct call_MPI_SendVectorInRing │ │ │ │ │ + 128 { │ │ │ │ │ + 129 std::tuple & remotedata; │ │ │ │ │ + 130 std::tuple & nextdata; │ │ │ │ │ + 131 int & tag; │ │ │ │ │ + 132 int & rightrank; │ │ │ │ │ + 133 int & leftrank; │ │ │ │ │ + 134 MPI_Comm & mpicomm; │ │ │ │ │ + 135 std::array & requests_send; │ │ │ │ │ + 136 std::array & requests_recv; │ │ │ │ │ + 137 │ │ │ │ │ + 138 template │ │ │ │ │ + 139 void operator()(I i) │ │ │ │ │ + 140 { │ │ │ │ │ + 141 MPI_SendVectorInRing( │ │ │ │ │ + 142 std::get(remotedata), │ │ │ │ │ + 143 std::get(nextdata), │ │ │ │ │ + 144 tag+i, │ │ │ │ │ + 145 rightrank, leftrank, mpicomm, │ │ │ │ │ + 146 requests_send[i], │ │ │ │ │ + 147 requests_recv[i]); │ │ │ │ │ + 148 } │ │ │ │ │ + 149 }; │ │ │ │ │ + 150 template │ │ │ │ │ + 151 struct call_MPI_SetVectorSize │ │ │ │ │ + 152 { │ │ │ │ │ + 153 std::tuple & nextdata; │ │ │ │ │ + 154 std::array & status_recv; │ │ │ │ │ + 155 │ │ │ │ │ + 156 template │ │ │ │ │ + 157 void operator()(I i) │ │ │ │ │ + 158 { │ │ │ │ │ + 159 MPI_SetVectorSize(std::get(nextdata),status_recv[i]); │ │ │ │ │ + 160 } │ │ │ │ │ + 161 }; │ │ │ │ │ + 162 │ │ │ │ │ + 163 template │ │ │ │ │ + 164 void MPI_AllApply_impl(MPI_Comm mpicomm, │ │ │ │ │ + 165 OP && op, │ │ │ │ │ + 166 std::index_sequence indices, │ │ │ │ │ + 167 const Args&... data) │ │ │ │ │ + 168 { │ │ │ │ │ + 169 constexpr std::size_t N = sizeof...(Args); │ │ │ │ │ + 170 int myrank = 0; │ │ │ │ │ + 171 int commsize = 0; │ │ │ │ │ + 172#if HAVE_MPI │ │ │ │ │ + 173 MPI_Comm_rank(mpicomm, &myrank); │ │ │ │ │ + 174 MPI_Comm_size(mpicomm, &commsize); │ │ │ │ │ + 175#endif // HAVE_MPI │ │ │ │ │ + 176 │ │ │ │ │ + 177 if (commsize > 1) │ │ │ │ │ + 178 { │ │ │ │ │ + 179#ifdef DEBUG_GRIDGLUE_PARALLELMERGE │ │ │ │ │ + 180 std::cout << myrank << " Start Communication, size " << commsize << std:: │ │ │ │ │ +endl; │ │ │ │ │ + 181#endif │ │ │ │ │ + 182 │ │ │ │ │ + 183 // get data sizes │ │ │ │ │ + 184 std::array size({ ((unsigned int)data.size())... }); │ │ │ │ │ + 185 │ │ │ │ │ + 186 // communicate max data size │ │ │ │ │ + 187 std::array maxSize; │ │ │ │ │ + 188 MPI_Allreduce(&size, &maxSize, │ │ │ │ │ + 189 size.size(), MPI_UNSIGNED, MPI_MAX, mpicomm); │ │ │ │ │ + 190#ifdef DEBUG_GRIDGLUE_PARALLELMERGE │ │ │ │ │ + 191 std::cout << myrank << " maxSize " << "done... " << std::endl; │ │ │ │ │ + 192#endif │ │ │ │ │ + 193 │ │ │ │ │ + 194 // allocate receiving buffers with maxsize to ensure sufficient buffer │ │ │ │ │ +size for communication │ │ │ │ │ + 195 std::tuple remotedata { Args(maxSize[Indices])... }; │ │ │ │ │ + 196 │ │ │ │ │ + 197 // copy local data to receiving buffer │ │ │ │ │ + 198 remotedata = std::tie(data...); │ │ │ │ │ + 199 │ │ │ │ │ + 200 // allocate second set of receiving buffers necessary for async │ │ │ │ │ +communication │ │ │ │ │ + 201 std::tuple nextdata { Args(maxSize[Indices])... }; │ │ │ │ │ + 202 │ │ │ │ │ + 203 // communicate data in the ring │ │ │ │ │ + 204 int rightrank = (myrank + 1 + commsize) % commsize; │ │ │ │ │ + 205 int leftrank = (myrank - 1 + commsize) % commsize; │ │ │ │ │ + 206 │ │ │ │ │ + 207 std::cout << myrank << ": size = " << commsize << std::endl; │ │ │ │ │ + 208 std::cout << myrank << ": left = " << leftrank │ │ │ │ │ + 209 << " right = " << rightrank << std::endl; │ │ │ │ │ + 210 │ │ │ │ │ + 211 // currently the remote data is our own data │ │ │ │ │ + 212 int remoterank = myrank; │ │ │ │ │ + 213 │ │ │ │ │ + 214 for (int i=1; i │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter_impl.hh File Reference │ │ │ │ +dune-grid-glue: projection_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,56 +63,49 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
areawriter_impl.hh File Reference
│ │ │ │ +
projection_impl.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <fstream>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/geometry/type.hh>
│ │ │ │ -#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +
#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <cmath>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::GridGlue::AreaWriterImplementation::FacetLayout< dimgrid >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
namespace  Dune::GridGlue::AreaWriterImplementation
namespace  Dune::GridGlue::ProjectionImplementation
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename GridView >
void Dune::GridGlue::AreaWriterImplementation::write_facet_geometry (const GridView &gv, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string &filename)
 
template<typename Glue >
void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string &base)
 
template<typename Coordinate , typename Field >
Coordinate Dune::GridGlue::ProjectionImplementation::corner (unsigned c)
 
std::pair< unsigned, unsigned > Dune::GridGlue::ProjectionImplementation::edgeToCorners (unsigned edge)
 
template<typename Coordinate , typename Corners >
Corners::value_type Dune::GridGlue::ProjectionImplementation::interpolate (const Coordinate &x, const Corners &corners)
 
template<typename Coordinate , typename Normals >
Normals::value_type Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals (const Coordinate &x, const Normals &normals)
 
template<typename Coordinate , typename Field >
bool Dune::GridGlue::ProjectionImplementation::inside (const Coordinate &x, const Field &epsilon)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,44 +5,45 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -areawriter_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +projection_impl.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ -struct  Dune::GridGlue::AreaWriterImplementation::FacetLayout<_dimgrid_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -namespace  Dune::GridGlue::AreaWriterImplementation │ │ │ │ │ +namespace  Dune::GridGlue::ProjectionImplementation │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::AreaWriterImplementation::write_facet_geometry (const │ │ │ │ │ - GridView &gv, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string │ │ │ │ │ - &filename) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string │ │ │ │ │ - &base) │ │ │ │ │ +template │ │ │ │ │ + Coordinate Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + corner (unsigned c) │ │ │ │ │ +  │ │ │ │ │ +std::pair< unsigned, unsigned > Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + edgeToCorners (unsigned edge) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + Corners::value_type Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + interpolate (const Coordinate &x, const │ │ │ │ │ + Corners &corners) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + Normals::value_type Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + interpolate_unit_normals (const Coordinate &x, │ │ │ │ │ + const Normals &normals) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + inside (const Coordinate &x, const Field │ │ │ │ │ + &epsilon) │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter_impl.hh Source File │ │ │ │ +dune-grid-glue: projection_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,169 +62,449 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
areawriter_impl.hh
│ │ │ │ +
projection_impl.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#include <fstream>
│ │ │ │ -
4#include <vector>
│ │ │ │ -
5
│ │ │ │ -
6#include <dune/common/fvector.hh>
│ │ │ │ -
7#include <dune/geometry/type.hh>
│ │ │ │ -
8#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +
3#include <dune/common/fmatrix.hh>
│ │ │ │ +
4
│ │ │ │ +
5#include <cmath>
│ │ │ │ +
6
│ │ │ │ +
7namespace Dune {
│ │ │ │ +
8namespace GridGlue {
│ │ │ │
9
│ │ │ │ -
10namespace Dune {
│ │ │ │ -
11namespace GridGlue {
│ │ │ │ -
12
│ │ │ │ -
13namespace AreaWriterImplementation {
│ │ │ │ -
14
│ │ │ │ -
15template<int dimgrid>
│ │ │ │ - │ │ │ │ -
17{
│ │ │ │ -
18 bool contains(Dune::GeometryType gt) const
│ │ │ │ -
19 {
│ │ │ │ -
20 return gt.dim() == dimgrid - 1;
│ │ │ │ -
21 }
│ │ │ │ -
22};
│ │ │ │ -
23
│ │ │ │ -
24template<typename GridView>
│ │ │ │ -
25void write_facet_geometry(const GridView& gv, std::ostream& out)
│ │ │ │ -
26{
│ │ │ │ -
27 using Coordinate = Dune::FieldVector<double, 3>;
│ │ │ │ -
28
│ │ │ │ -
29 std::vector<Coordinate> corners;
│ │ │ │ -
30 for (const auto& facet : facets(gv)) {
│ │ │ │ -
31 const auto geometry = facet.geometry();
│ │ │ │ -
32 for (int i = 0; i < geometry.corners(); ++i) {
│ │ │ │ -
33 /* VTK always needs 3-dim coordinates... */
│ │ │ │ -
34 const auto c0 = geometry.corner(i);
│ │ │ │ -
35 Coordinate c1;
│ │ │ │ -
36 for (int d = 0; d < GridView::dimensionworld; ++d)
│ │ │ │ -
37 c1[d] = c0[d];
│ │ │ │ -
38 for (int d = GridView::dimensionworld; d < Coordinate::dimension; ++d)
│ │ │ │ -
39 c1[d] = double(0);
│ │ │ │ -
40 corners.push_back(c1);
│ │ │ │ -
41 }
│ │ │ │ -
42 }
│ │ │ │ -
43
│ │ │ │ -
44 {
│ │ │ │ -
45 out << "DATASET UNSTRUCTURED_GRID\n"
│ │ │ │ -
46 << "POINTS " << corners.size() << " double\n";
│ │ │ │ -
47 for (const auto& c : corners)
│ │ │ │ -
48 out << c << "\n";
│ │ │ │ +
10namespace ProjectionImplementation {
│ │ │ │ +
11
│ │ │ │ +
22template<typename Coordinate, typename Field>
│ │ │ │ +
23inline Coordinate
│ │ │ │ +
24corner(unsigned c)
│ │ │ │ +
25{
│ │ │ │ +
26 Coordinate x(Field(0));
│ │ │ │ +
27 if (c == 0)
│ │ │ │ +
28 return x;
│ │ │ │ +
29 x[c-1] = Field(1);
│ │ │ │ +
30 return x;
│ │ │ │ +
31}
│ │ │ │ +
32
│ │ │ │ +
42inline std::pair<unsigned, unsigned>
│ │ │ │ +
43edgeToCorners(unsigned edge)
│ │ │ │ +
44{
│ │ │ │ +
45 switch(edge) {
│ │ │ │ +
46 case 0: return {0, 1};
│ │ │ │ +
47 case 1: return {0, 2};
│ │ │ │ +
48 case 2: return {1, 2};
│ │ │ │
49 }
│ │ │ │ -
50 {
│ │ │ │ -
51 out << "CELLS " << gv.size(1) << " " << (gv.size(1) + corners.size()) << "\n";
│ │ │ │ -
52 std::size_t c = 0;
│ │ │ │ -
53 for (const auto& facet : facets(gv)) {
│ │ │ │ -
54 const auto geometry = facet.geometry();
│ │ │ │ -
55 out << geometry.corners();
│ │ │ │ -
56 for (int i = 0; i < geometry.corners(); ++i, ++c)
│ │ │ │ -
57 out << " " << c;
│ │ │ │ -
58 out << "\n";
│ │ │ │ -
59 }
│ │ │ │ -
60 }
│ │ │ │ -
61 {
│ │ │ │ -
62 out << "CELL_TYPES " << gv.size(1) << "\n";
│ │ │ │ -
63 for (const auto& facet : facets(gv)) {
│ │ │ │ -
64 const auto type = facet.type();
│ │ │ │ -
65 if (type.isVertex())
│ │ │ │ -
66 out << "1\n";
│ │ │ │ -
67 else if (type.isLine())
│ │ │ │ -
68 out << "2\n";
│ │ │ │ -
69 else if (type.isTriangle())
│ │ │ │ -
70 out << "5\n";
│ │ │ │ -
71 else if (type.isQuadrilateral())
│ │ │ │ -
72 out << "9\n";
│ │ │ │ -
73 else if (type.isTetrahedron())
│ │ │ │ -
74 out << "10\n";
│ │ │ │ -
75 else
│ │ │ │ -
76 DUNE_THROW(Dune::Exception, "Unhandled geometry type");
│ │ │ │ -
77 }
│ │ │ │ -
78 }
│ │ │ │ -
79}
│ │ │ │ -
80
│ │ │ │ -
81} /* namespace AreaWriterImplementation */
│ │ │ │ -
82
│ │ │ │ -
83template<int side, typename Glue>
│ │ │ │ -
84void write_glue_area_vtk(const Glue& glue, std::ostream& out)
│ │ │ │ -
85{
│ │ │ │ -
86 using GridView = typename std::decay< decltype(glue.template gridView<side>()) >::type;
│ │ │ │ -
87 using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, AreaWriterImplementation::FacetLayout>;
│ │ │ │ -
88 using ctype = typename GridView::ctype;
│ │ │ │ -
89
│ │ │ │ -
90 const GridView gv = glue.template gridView<side>();
│ │ │ │ -
91 Mapper mapper(gv);
│ │ │ │ -
92 std::vector<ctype> coveredArea(mapper.size(), ctype(0));
│ │ │ │ -
93 std::vector<ctype> totalArea(mapper.size(), ctype(1));
│ │ │ │ -
94
│ │ │ │ -
95 for (const auto& in : intersections(glue, Reverse<side == 1>())) {
│ │ │ │ -
96 const auto element = in.inside();
│ │ │ │ -
97 const auto index = mapper.subIndex(element, in.indexInInside(), 1);
│ │ │ │ -
98 coveredArea[index] += in.geometryInInside().volume();
│ │ │ │ -
99
│ │ │ │ -
100 const auto& refElement = Dune::ReferenceElements<ctype, GridView::dimension>::general(element.type());
│ │ │ │ -
101 const auto& subGeometry = refElement.template geometry<1>(in.indexInInside());
│ │ │ │ -
102 totalArea[index] = subGeometry.volume();
│ │ │ │ -
103 }
│ │ │ │ -
104
│ │ │ │ -
105 for (std::size_t i = 0; i < coveredArea.size(); ++i)
│ │ │ │ -
106 coveredArea[i] /= totalArea[i];
│ │ │ │ -
107
│ │ │ │ -
108 out << "# vtk DataFile Version 2.0\n"
│ │ │ │ -
109 << "Filename: Glue Area\n"
│ │ │ │ -
110 << "ASCII\n";
│ │ │ │ -
111
│ │ │ │ - │ │ │ │ -
113
│ │ │ │ -
114 out << "CELL_DATA " << coveredArea.size() << "\n"
│ │ │ │ -
115 << "SCALARS CoveredArea double 1\n"
│ │ │ │ -
116 << "LOOKUP_TABLE default\n";
│ │ │ │ -
117 for (const auto& value : coveredArea)
│ │ │ │ -
118 out << value << "\n";
│ │ │ │ -
119}
│ │ │ │ -
120
│ │ │ │ -
121template<int side, typename Glue>
│ │ │ │ -
122void write_glue_area_vtk(const Glue& glue, const std::string& filename)
│ │ │ │ -
123{
│ │ │ │ -
124 std::ofstream out(filename.c_str());
│ │ │ │ -
125 write_glue_area_vtk<side>(glue, out);
│ │ │ │ -
126}
│ │ │ │ +
50 DUNE_THROW(Dune::Exception, "Unexpected edge number.");
│ │ │ │ +
51}
│ │ │ │ +
52
│ │ │ │ +
68template<typename Coordinate, typename Corners>
│ │ │ │ +
69inline typename Corners::value_type
│ │ │ │ +
70interpolate(const Coordinate& x, const Corners& corners)
│ │ │ │ +
71{
│ │ │ │ +
72 auto y = corners[0];
│ │ │ │ +
73 for (unsigned i = 0; i < corners.size() - 1; ++i)
│ │ │ │ +
74 y.axpy(x[i], corners[i+1] - corners[0]);
│ │ │ │ +
75 return y;
│ │ │ │ +
76}
│ │ │ │ +
77
│ │ │ │ +
89template<typename Coordinate, typename Normals>
│ │ │ │ +
90inline typename Normals::value_type
│ │ │ │ +
91interpolate_unit_normals(const Coordinate& x, const Normals& normals)
│ │ │ │ +
92{
│ │ │ │ +
93 auto n = interpolate(x, normals);
│ │ │ │ +
94 n /= n.two_norm();
│ │ │ │ +
95 return n;
│ │ │ │ +
96}
│ │ │ │ +
97
│ │ │ │ +
109template<typename Coordinate, typename Field>
│ │ │ │ +
110inline bool
│ │ │ │ +
111inside(const Coordinate& x, const Field& epsilon)
│ │ │ │ +
112{
│ │ │ │ +
113 const unsigned dim = Coordinate::dimension;
│ │ │ │ +
114 Field sum(0);
│ │ │ │ +
115 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ +
116 if (x[i] < -epsilon)
│ │ │ │ +
117 return false;
│ │ │ │ +
118 sum += x[i];
│ │ │ │ +
119 }
│ │ │ │ +
120 /* If any xᵢ is NaN, sum will be NaN and this comparison false! */
│ │ │ │ +
121 if (sum <= Field(1) + epsilon)
│ │ │ │ +
122 return true;
│ │ │ │ +
123 return false;
│ │ │ │ +
124}
│ │ │ │ +
125
│ │ │ │ +
126} /* namespace ProjectionImplementation */
│ │ │ │
127
│ │ │ │ -
128template<typename Glue>
│ │ │ │ -
129void write_glue_areas_vtk(const Glue& glue, const std::string& base)
│ │ │ │ -
130{
│ │ │ │ -
131 {
│ │ │ │ -
132 std::string filename = base;
│ │ │ │ -
133 filename += "-inside.vtk";
│ │ │ │ -
134 write_glue_area_vtk<0>(glue, filename);
│ │ │ │ -
135 }
│ │ │ │ -
136 {
│ │ │ │ -
137 std::string filename = base;
│ │ │ │ -
138 filename += "-outside.vtk";
│ │ │ │ -
139 write_glue_area_vtk<1>(glue, filename);
│ │ │ │ -
140 }
│ │ │ │ -
141}
│ │ │ │ -
142
│ │ │ │ -
143} /* namespace GridGlue */
│ │ │ │ -
144} /* namespace Dune */
│ │ │ │ +
128template<typename Coordinate>
│ │ │ │ + │ │ │ │ +
130::Projection(const Field overlap, const Field max_normal_product)
│ │ │ │ +
131 : m_overlap(overlap)
│ │ │ │ +
132 , m_max_normal_product(max_normal_product)
│ │ │ │ +
133{
│ │ │ │ +
134 /* Nothing. */
│ │ │ │ +
135}
│ │ │ │ +
136
│ │ │ │ +
137template<typename Coordinate>
│ │ │ │ +
138void
│ │ │ │ + │ │ │ │ +
140::epsilon(const Field epsilon)
│ │ │ │ +
141{
│ │ │ │ +
142 m_epsilon = epsilon;
│ │ │ │ +
143}
│ │ │ │ +
144
│ │ │ │ +
145template<typename Coordinate>
│ │ │ │ +
146template<typename Corners, typename Normals>
│ │ │ │ +
147void
│ │ │ │ + │ │ │ │ +
149::doProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ +
150{
│ │ │ │ +
151 /* Try to obtain Φ(xᵢ) for each corner xᵢ of the preimage triangle.
│ │ │ │ +
152 * This means solving a linear system of equations
│ │ │ │ +
153 * Φ(xᵢ) = (1-α-β) y₀ + α y₁ + β y₂ = xᵢ + δ nᵢ
│ │ │ │ +
154 * or α (y₁ - y₀) + β (y₂ - y₀) - δ nᵢ = xᵢ - y₀
│ │ │ │ +
155 * to obtain the barycentric coordinates (α, β) of Φ(xᵢ) in the image
│ │ │ │ +
156 * triangle and the distance δ.
│ │ │ │ +
157 *
│ │ │ │ +
158 * In the matrix m corresponding to the system, only the third column and the
│ │ │ │ +
159 * right-hand side depend on i. The first two columns can be assembled before
│ │ │ │ +
160 * and reused.
│ │ │ │ +
161 */
│ │ │ │ +
162 using namespace ProjectionImplementation;
│ │ │ │ +
163 using std::get;
│ │ │ │ +
164 typedef Dune::FieldMatrix<Field, dim, dim> Matrix;
│ │ │ │ +
165 Matrix m;
│ │ │ │ +
166
│ │ │ │ +
167 const auto& origin = get<0>(corners);
│ │ │ │ +
168 const auto& origin_normals = get<0>(normals);
│ │ │ │ +
169 const auto& target = get<1>(corners);
│ │ │ │ +
170 const auto& target_normals = get<1>(normals);
│ │ │ │ +
171 auto& images = get<0>(m_images);
│ │ │ │ +
172 auto& success = get<0>(m_success);
│ │ │ │ +
173
│ │ │ │ +
174 /* directionsᵢ = (yᵢ - y₀) / ||yᵢ - y₀||
│ │ │ │ +
175 * These are the first to columns of the system matrix; the rescaling is done
│ │ │ │ +
176 * to ensure all columns have a comparable norm (the last has the normal with norm 1.
│ │ │ │ +
177 */
│ │ │ │ +
178 std::array<Coordinate, dim-1> directions;
│ │ │ │ +
179 std::array<Field, dim-1> scales;
│ │ │ │ +
180 /* estimator for the diameter of the target face */
│ │ │ │ +
181 Field scaleSum(0);
│ │ │ │ +
182 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ +
183 directions[i] = target[i+1] - target[0];
│ │ │ │ +
184 scales[i] = directions[i].infinity_norm();
│ │ │ │ +
185 directions[i] /= scales[i];
│ │ │ │ +
186 scaleSum += scales[i];
│ │ │ │ +
187 }
│ │ │ │ +
188
│ │ │ │ +
189 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ +
190 for (unsigned j = 0; j < dim; ++j) {
│ │ │ │ +
191 m[j][i] = directions[i][j];
│ │ │ │ +
192 }
│ │ │ │ +
193 }
│ │ │ │ +
194
│ │ │ │ +
195 m_projection_valid = true;
│ │ │ │ +
196 success.reset();
│ │ │ │ +
197
│ │ │ │ +
198 /* Now project xᵢ for each i */
│ │ │ │ +
199 for (unsigned i = 0; i < origin.size(); ++i) {
│ │ │ │ +
200 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ +
201 m[j][dim-1] = origin_normals[i][j];
│ │ │ │ +
202
│ │ │ │ +
203 const Coordinate rhs = origin[i] - target[0];
│ │ │ │ +
204
│ │ │ │ +
205 try {
│ │ │ │ +
206 /* y = (α, β, δ) */
│ │ │ │ +
207 auto& y = images[i];
│ │ │ │ +
208 m.solve(y, rhs);
│ │ │ │ +
209 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ +
210 y[j] /= scales[j];
│ │ │ │ +
211 /* Solving gave us -δ as the term is "-δ nᵢ". */
│ │ │ │ +
212 y[dim-1] *= Field(-1);
│ │ │ │ +
213
│ │ │ │ +
214 /* If the forward projection is too far in the wrong direction
│ │ │ │ +
215 * then this might result in artificial inverse projections or
│ │ │ │ +
216 * edge intersections. To prevent these wrong cases but not
│ │ │ │ +
217 * dismiss feasible intersections, the projection is dismissed
│ │ │ │ +
218 * if the forward projection is further than two times the
│ │ │ │ +
219 * approximate diameter of the image triangle.
│ │ │ │ +
220 */
│ │ │ │ +
221 if(y[dim-1] < -2*scaleSum) {
│ │ │ │ +
222 success.set(i,false);
│ │ │ │ +
223 m_projection_valid = false;
│ │ │ │ +
224 return;
│ │ │ │ +
225 }
│ │ │ │ +
226
│ │ │ │ +
227 const bool feasible = projectionFeasible(origin[i], origin_normals[i], y, target, target_normals);
│ │ │ │ +
228 success.set(i, feasible);
│ │ │ │ +
229 }
│ │ │ │ +
230 catch (const Dune::FMatrixError&) {
│ │ │ │ +
231 success.set(i, false);
│ │ │ │ +
232 m_projection_valid = false;
│ │ │ │ +
233 }
│ │ │ │ +
234 }
│ │ │ │ +
235}
│ │ │ │ +
236
│ │ │ │ +
237template<typename Coordinate>
│ │ │ │ +
238template<typename Corners, typename Normals>
│ │ │ │ +
239void
│ │ │ │ +
240Projection<Coordinate>
│ │ │ │ +
241::doInverseProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ +
242{
│ │ │ │ +
243 /* Try to obtain Φ⁻¹(yᵢ) for each corner yᵢ of the image triangle.
│ │ │ │ +
244 * Instead of solving the problem directly (which would lead to
│ │ │ │ +
245 * non-linear equations), we make use of the forward projection Φ
│ │ │ │ +
246 * which projects the preimage triangle on the plane spanned by the
│ │ │ │ +
247 * image triangle. The inverse projection is then given by finding
│ │ │ │ +
248 * the barycentric coordinates of yᵢ with respect to the triangle
│ │ │ │ +
249 * with the corners Φ(xᵢ). This way we only have to solve linear
│ │ │ │ +
250 * equations.
│ │ │ │ +
251 */
│ │ │ │ +
252
│ │ │ │ +
253 using namespace ProjectionImplementation;
│ │ │ │ +
254 using std::get;
│ │ │ │ +
255 typedef Dune::FieldMatrix<Field, dim-1, dim-1> Matrix;
│ │ │ │ +
256 typedef Dune::FieldVector<Field, dim-1> Vector;
│ │ │ │ +
257
│ │ │ │ +
258 /* The inverse projection can only be computed if the forward projection
│ │ │ │ +
259 * managed to project all xᵢ on the plane spanned by the yᵢ
│ │ │ │ +
260 */
│ │ │ │ +
261 if (!m_projection_valid) {
│ │ │ │ +
262 get<1>(m_success).reset();
│ │ │ │ +
263 return;
│ │ │ │ +
264 }
│ │ │ │ +
265
│ │ │ │ +
266 const auto& images = get<0>(m_images);
│ │ │ │ +
267 const auto& target_corners = get<1>(corners);
│ │ │ │ +
268 auto& preimages = get<1>(m_images);
│ │ │ │ +
269 auto& success = get<1>(m_success);
│ │ │ │ +
270
│ │ │ │ +
271 std::array<Coordinate, dim> v;
│ │ │ │ +
272 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ +
273 v[i] = interpolate(images[i+1], target_corners);
│ │ │ │ +
274 v[i] -= interpolate(images[0], target_corners);
│ │ │ │ +
275 }
│ │ │ │ +
276
│ │ │ │ +
277 Matrix m;
│ │ │ │ +
278 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ +
279 for (unsigned j = 0; j < dim-1; ++j) {
│ │ │ │ +
280 m[i][j] = v[i]*v[j];
│ │ │ │ +
281 }
│ │ │ │ +
282 }
│ │ │ │ +
283
│ │ │ │ +
284 for (unsigned i = 0; i < dim; ++i) {
│ │ │ │ +
285 /* Convert yᵢ to barycentric coordinates with respect to Φ(xⱼ) */
│ │ │ │ +
286 v[dim-1] = target_corners[i];
│ │ │ │ +
287 v[dim-1] -= interpolate(images[0], target_corners);
│ │ │ │ +
288
│ │ │ │ +
289 Vector rhs, z;
│ │ │ │ +
290 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ +
291 rhs[j] = v[dim-1]*v[j];
│ │ │ │ +
292 m.solve(z, rhs);
│ │ │ │ +
293
│ │ │ │ +
294 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ +
295 preimages[i][j] = z[j];
│ │ │ │ +
296
│ │ │ │ +
297 /* Calculate distance along normal direction */
│ │ │ │ +
298 const auto x = interpolate(z, get<0>(corners));
│ │ │ │ +
299 preimages[i][dim-1] = (x - target_corners[i]) * get<1>(normals)[i];
│ │ │ │ +
300
│ │ │ │ +
301 /* Check y_i lies inside the Φ(xⱼ) */
│ │ │ │ +
302 const bool feasible = projectionFeasible(target_corners[i], get<1>(normals)[i], preimages[i], get<0>(corners), get<0>(normals));
│ │ │ │ +
303 success.set(i, feasible);
│ │ │ │ +
304 }
│ │ │ │ +
305}
│ │ │ │ +
306
│ │ │ │ +
307template<typename Coordinate>
│ │ │ │ +
308template<typename Corners, typename Normals>
│ │ │ │ +
309void
│ │ │ │ +
310Projection<Coordinate>
│ │ │ │ +
311::doEdgeIntersection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ +
312{
│ │ │ │ +
313 using namespace ProjectionImplementation;
│ │ │ │ +
314 using std::get;
│ │ │ │ +
315
│ │ │ │ +
316 m_number_of_edge_intersections = 0;
│ │ │ │ +
317
│ │ │ │ +
318 /* There are no edge intersections for 2d, only for 3d */
│ │ │ │ +
319 if (dim != 3)
│ │ │ │ +
320 return;
│ │ │ │ +
321
│ │ │ │ +
322 /* There are no edge intersections
│ │ │ │ +
323 * - when the projection is invalid,
│ │ │ │ +
324 * - when the projected triangle lies fully in the target triangle,
│ │ │ │ +
325 * - or when the target triangle lies fully in the projected triangle.
│ │ │ │ +
326 */
│ │ │ │ +
327 if (!m_projection_valid || get<0>(m_success).all() || get<1>(m_success).all()) {
│ │ │ │ +
328 return;
│ │ │ │ +
329 }
│ │ │ │ +
330
│ │ │ │ +
331 const auto& images = get<0>(m_images);
│ │ │ │ +
332 const auto& ys = get<1>(corners);
│ │ │ │ +
333
│ │ │ │ +
334 /* Intersect line through Φ(xᵢ), Φ(xⱼ) with line through yₖ, yₗ:
│ │ │ │ +
335 We want α, β ∈ ℝ such that
│ │ │ │ +
336 Φ(xᵢ) + α (Φ(xⱼ) - Φ(xᵢ)) = yₖ + β (yₗ - yₖ)
│ │ │ │ +
337 or
│ │ │ │ +
338 α (Φ(xⱼ)-Φ(xᵢ)) + β (yₗ-yₖ) = yₖ-Φ(xᵢ)
│ │ │ │ +
339 To get a 2×2 system of equations, multiply with yₘ-y₀ for
│ │ │ │ +
340 m ∈ {1,̣̣2} which are linear indep. (and so the system is
│ │ │ │ +
341 equivalent to the original 3×2 system)
│ │ │ │ +
342 */
│ │ │ │ +
343 for (unsigned edgex = 0; edgex < dim; ++edgex) {
│ │ │ │ +
344 unsigned i, j;
│ │ │ │ +
345 std::tie(i, j) = edgeToCorners(edgex);
│ │ │ │ +
346
│ │ │ │ +
347 /* Both sides of edgex lie in the target triangle means no edge intersection */
│ │ │ │ +
348 if (get<0>(m_success)[i] && get<0>(m_success)[j])
│ │ │ │ +
349 continue;
│ │ │ │ +
350
│ │ │ │ +
351 const auto pxi = interpolate(images[i], ys);
│ │ │ │ +
352 const auto pxj = interpolate(images[j], ys);
│ │ │ │ +
353 const auto pxjpxi = pxj - pxi;
│ │ │ │ +
354
│ │ │ │ +
355 typedef Dune::FieldMatrix<Field, dim-1, dim-1> Matrix;
│ │ │ │ +
356 typedef Dune::FieldVector<Field, dim-1> Vector;
│ │ │ │ +
357
│ │ │ │ +
358 for (unsigned edgey = 0; edgey < dim; ++edgey) {
│ │ │ │ +
359 unsigned k, l;
│ │ │ │ +
360 std::tie(k, l) = edgeToCorners(edgey);
│ │ │ │ +
361
│ │ │ │ +
362 /* Both sides of edgey lie in the projected triangle means no edge intersection */
│ │ │ │ +
363 if (get<1>(m_success)[k] && get<1>(m_success)[l])
│ │ │ │ +
364 continue;
│ │ │ │ +
365
│ │ │ │ +
366 const auto ykyl = ys[k] - ys[l];
│ │ │ │ +
367 const auto ykpxi = ys[k] - pxi;
│ │ │ │ +
368
│ │ │ │ +
369 /* If edges are parallel then the intersection is already computed by vertex projections. */
│ │ │ │ +
370 bool parallel = true;
│ │ │ │ +
371 for (unsigned h=0; h<3; h++)
│ │ │ │ +
372 parallel &= std::abs(ykyl[(h+1)%3]*pxjpxi[(h+2)%3] - ykyl[(h+2)%3]*pxjpxi[(h+1)%3])<1e-14;
│ │ │ │ +
373 if (parallel)
│ │ │ │ +
374 continue;
│ │ │ │ +
375
│ │ │ │ +
376 Matrix mat;
│ │ │ │ +
377 Vector rhs, z;
│ │ │ │ +
378
│ │ │ │ +
379 for (unsigned m = 0; m < dim-1; ++m) {
│ │ │ │ +
380 const auto ym1y0 = ys[m+1] - ys[0];
│ │ │ │ +
381 mat[m][0] = pxjpxi * ym1y0;
│ │ │ │ +
382 mat[m][1] = ykyl * ym1y0;
│ │ │ │ +
383 rhs[m] = ykpxi * ym1y0;
│ │ │ │ +
384 }
│ │ │ │ +
385
│ │ │ │ +
386 try {
│ │ │ │ +
387 using std::isfinite;
│ │ │ │ +
388
│ │ │ │ +
389 mat.solve(z, rhs);
│ │ │ │ +
390
│ │ │ │ +
391 /* If solving the system gives a NaN, the edges are probably parallel. */
│ │ │ │ +
392 if (!isfinite(z[0]) || !isfinite(z[1]))
│ │ │ │ +
393 continue;
│ │ │ │ +
394
│ │ │ │ +
395 /* Filter out corner (pre)images. We only want "real" edge-edge intersections here. */
│ │ │ │ +
396 if (z[0] < m_epsilon || z[0] > Field(1) - m_epsilon
│ │ │ │ +
397 || z[1] < m_epsilon || z[1] > Field(1) - m_epsilon)
│ │ │ │ +
398 continue;
│ │ │ │ +
399
│ │ │ │ +
400 Coordinate local_x = corner<Coordinate, Field>(i);
│ │ │ │ +
401 local_x.axpy(z[0], corner<Coordinate, Field>(j) - corner<Coordinate, Field>(i));
│ │ │ │ +
402 Coordinate local_y = corner<Coordinate, Field>(k);
│ │ │ │ +
403 local_y.axpy(z[1], corner<Coordinate, Field>(l) - corner<Coordinate, Field>(k));
│ │ │ │ +
404
│ │ │ │ +
405 /* Make sure the intersection is in the triangle. */
│ │ │ │ +
406 if (!inside(local_x, m_epsilon) || !inside(local_y, m_epsilon))
│ │ │ │ +
407 continue;
│ │ │ │ +
408
│ │ │ │ +
409 /* Make sure the intersection respects overlap. */
│ │ │ │ +
410 auto xy = interpolate(local_x, get<0>(corners));
│ │ │ │ +
411 xy -= interpolate(local_y, get<1>(corners));
│ │ │ │ +
412 const auto nx = interpolate_unit_normals(local_x, get<0>(normals));
│ │ │ │ +
413 const auto ny = interpolate_unit_normals(local_y, get<1>(normals));
│ │ │ │ +
414 local_x[dim-1] = -(xy*nx);
│ │ │ │ +
415 local_y[dim-1] = xy*ny;
│ │ │ │ +
416
│ │ │ │ +
417 if (local_x[dim-1] < -m_overlap-m_epsilon || local_y[dim-1] < -m_overlap-m_epsilon)
│ │ │ │ +
418 continue;
│ │ │ │ +
419
│ │ │ │ +
420 /* Normals should be opposing. */
│ │ │ │ +
421 if (nx*ny > m_max_normal_product + m_epsilon)
│ │ │ │ +
422 continue;
│ │ │ │ +
423
│ │ │ │ +
424 /* Intersection is feasible. Store it. */
│ │ │ │ +
425 auto& intersection = m_edge_intersections[m_number_of_edge_intersections++];
│ │ │ │ +
426 intersection = { {{edgex, edgey}}, {{local_x, local_y}} };
│ │ │ │ +
427 }
│ │ │ │ +
428 catch(const Dune::FMatrixError&) {
│ │ │ │ +
429 /* Edges might be parallel, ignore and continue with next edge */
│ │ │ │ +
430 }
│ │ │ │ +
431 }
│ │ │ │ +
432 }
│ │ │ │ +
433}
│ │ │ │ +
434
│ │ │ │ +
435template<typename Coordinate>
│ │ │ │ +
436template<typename Corners, typename Normals>
│ │ │ │ +
437bool Projection<Coordinate>
│ │ │ │ +
438::projectionFeasible(const Coordinate& x, const Coordinate& nx, const Coordinate& px, const Corners& corners, const Normals& normals) const
│ │ │ │ +
439{
│ │ │ │ +
440 using namespace ProjectionImplementation;
│ │ │ │ +
441
│ │ │ │ +
442 /* Image must be within simplex. */
│ │ │ │ +
443 if (!inside(px, m_epsilon))
│ │ │ │ +
444 return false;
│ │ │ │ +
445
│ │ │ │ +
446 /* Distance along normal must not be smaller than -overlap. */
│ │ │ │ +
447 if (px[dim-1] < -m_overlap-m_epsilon)
│ │ │ │ +
448 return false;
│ │ │ │ +
449
│ │ │ │ +
450 /* Distance along normal at image must not be smaller than -overlap. */
│ │ │ │ +
451 auto xmy = x;
│ │ │ │ +
452 xmy -= interpolate(px, corners);
│ │ │ │ +
453 const auto n = interpolate_unit_normals(px, normals);
│ │ │ │ +
454 const auto d = xmy * n;
│ │ │ │ +
455 if (d < -m_overlap-m_epsilon)
│ │ │ │ +
456 return false;
│ │ │ │ +
457
│ │ │ │ +
458 /* Normals at x and Φ(x) are opposing. */
│ │ │ │ +
459 if (nx * n > m_max_normal_product + m_epsilon)
│ │ │ │ +
460 return false;
│ │ │ │ +
461
│ │ │ │ +
462 /* Okay, projection is feasible. */
│ │ │ │ +
463 return true;
│ │ │ │ +
464}
│ │ │ │ +
465
│ │ │ │ +
466template<typename Coordinate>
│ │ │ │ +
467template<typename Corners, typename Normals>
│ │ │ │ + │ │ │ │ +
469::project(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ +
470{
│ │ │ │ +
471 doProjection(corners, normals);
│ │ │ │ +
472 doInverseProjection(corners, normals);
│ │ │ │ +
473 doEdgeIntersection(corners, normals);
│ │ │ │ +
474}
│ │ │ │ +
475
│ │ │ │ +
476} /* namespace GridGlue */
│ │ │ │ +
477} /* namespace Dune */
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
void write_glue_area_vtk(const Glue &glue, std::ostream &out)
Definition: areawriter_impl.hh:84
│ │ │ │ -
void write_glue_areas_vtk(const Glue &glue, const std::string &base)
Definition: areawriter_impl.hh:129
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
void write_facet_geometry(const GridView &gv, std::ostream &out)
Definition: areawriter_impl.hh:25
│ │ │ │ -
Definition: rangegenerators.hh:17
│ │ │ │ - │ │ │ │ -
bool contains(Dune::GeometryType gt) const
Definition: areawriter_impl.hh:18
│ │ │ │ +
Corners::value_type interpolate(const Coordinate &x, const Corners &corners)
Definition: projection_impl.hh:70
│ │ │ │ +
bool inside(const Coordinate &x, const Field &epsilon)
Definition: projection_impl.hh:111
│ │ │ │ +
std::pair< unsigned, unsigned > edgeToCorners(unsigned edge)
Definition: projection_impl.hh:43
│ │ │ │ +
Coordinate corner(unsigned c)
Definition: projection_impl.hh:24
│ │ │ │ +
Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals &normals)
Definition: projection_impl.hh:91
│ │ │ │ +
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:21
│ │ │ │ +
Coordinate::field_type Field
Scalar type.
Definition: projection.hh:61
│ │ │ │ +
Projection(const Field overlap=Field(0), const Field max_normal_product=Field(-0.1))
Definition: projection_impl.hh:130
│ │ │ │ +
void epsilon(const Field epsilon)
Set epsilon used for floating-point comparisons.
Definition: projection_impl.hh:140
│ │ │ │ +
void project(const std::tuple< Corners &, Corners & > &corners, const std::tuple< Normals &, Normals & > &normals)
Do the actual projection.
Definition: projection_impl.hh:469
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,185 +5,494 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -areawriter_impl.hh │ │ │ │ │ +projection_impl.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#include │ │ │ │ │ - 4#include │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8#include │ │ │ │ │ + 3#include │ │ │ │ │ + 4 │ │ │ │ │ + 5#include │ │ │ │ │ + 6 │ │ │ │ │ + 7namespace Dune { │ │ │ │ │ + 8namespace GridGlue { │ │ │ │ │ 9 │ │ │ │ │ - 10namespace Dune { │ │ │ │ │ - 11namespace GridGlue { │ │ │ │ │ - 12 │ │ │ │ │ -13namespace AreaWriterImplementation { │ │ │ │ │ - 14 │ │ │ │ │ - 15template │ │ │ │ │ -16struct FacetLayout │ │ │ │ │ - 17{ │ │ │ │ │ -18 bool contains(Dune::GeometryType gt) const │ │ │ │ │ - 19 { │ │ │ │ │ - 20 return gt.dim() == dimgrid - 1; │ │ │ │ │ - 21 } │ │ │ │ │ - 22}; │ │ │ │ │ - 23 │ │ │ │ │ - 24template │ │ │ │ │ -25void write_facet_geometry(const GridView& gv, std::ostream& out) │ │ │ │ │ - 26{ │ │ │ │ │ - 27 using Coordinate = Dune::FieldVector; │ │ │ │ │ - 28 │ │ │ │ │ - 29 std::vector corners; │ │ │ │ │ - 30 for (const auto& facet : facets(gv)) { │ │ │ │ │ - 31 const auto geometry = facet.geometry(); │ │ │ │ │ - 32 for (int i = 0; i < geometry.corners(); ++i) { │ │ │ │ │ - 33 /* VTK always needs 3-dim coordinates... */ │ │ │ │ │ - 34 const auto c0 = geometry.corner(i); │ │ │ │ │ - 35 Coordinate c1; │ │ │ │ │ - 36 for (int d = 0; d < GridView::dimensionworld; ++d) │ │ │ │ │ - 37 c1[d] = c0[d]; │ │ │ │ │ - 38 for (int d = GridView::dimensionworld; d < Coordinate::dimension; ++d) │ │ │ │ │ - 39 c1[d] = double(0); │ │ │ │ │ - 40 corners.push_back(c1); │ │ │ │ │ - 41 } │ │ │ │ │ - 42 } │ │ │ │ │ - 43 │ │ │ │ │ - 44 { │ │ │ │ │ - 45 out << "DATASET UNSTRUCTURED_GRID\n" │ │ │ │ │ - 46 << "POINTS " << corners.size() << " double\n"; │ │ │ │ │ - 47 for (const auto& c : corners) │ │ │ │ │ - 48 out << c << "\n"; │ │ │ │ │ +10namespace ProjectionImplementation { │ │ │ │ │ + 11 │ │ │ │ │ + 22template │ │ │ │ │ + 23inline Coordinate │ │ │ │ │ +24corner(unsigned c) │ │ │ │ │ + 25{ │ │ │ │ │ + 26 Coordinate x(Field(0)); │ │ │ │ │ + 27 if (c == 0) │ │ │ │ │ + 28 return x; │ │ │ │ │ + 29 x[c-1] = Field(1); │ │ │ │ │ + 30 return x; │ │ │ │ │ + 31} │ │ │ │ │ + 32 │ │ │ │ │ + 42inline std::pair │ │ │ │ │ +43edgeToCorners(unsigned edge) │ │ │ │ │ + 44{ │ │ │ │ │ + 45 switch(edge) { │ │ │ │ │ + 46 case 0: return {0, 1}; │ │ │ │ │ + 47 case 1: return {0, 2}; │ │ │ │ │ + 48 case 2: return {1, 2}; │ │ │ │ │ 49 } │ │ │ │ │ - 50 { │ │ │ │ │ - 51 out << "CELLS " << gv.size(1) << " " << (gv.size(1) + corners.size()) << │ │ │ │ │ -"\n"; │ │ │ │ │ - 52 std::size_t c = 0; │ │ │ │ │ - 53 for (const auto& facet : facets(gv)) { │ │ │ │ │ - 54 const auto geometry = facet.geometry(); │ │ │ │ │ - 55 out << geometry.corners(); │ │ │ │ │ - 56 for (int i = 0; i < geometry.corners(); ++i, ++c) │ │ │ │ │ - 57 out << " " << c; │ │ │ │ │ - 58 out << "\n"; │ │ │ │ │ - 59 } │ │ │ │ │ - 60 } │ │ │ │ │ - 61 { │ │ │ │ │ - 62 out << "CELL_TYPES " << gv.size(1) << "\n"; │ │ │ │ │ - 63 for (const auto& facet : facets(gv)) { │ │ │ │ │ - 64 const auto type = facet.type(); │ │ │ │ │ - 65 if (type.isVertex()) │ │ │ │ │ - 66 out << "1\n"; │ │ │ │ │ - 67 else if (type.isLine()) │ │ │ │ │ - 68 out << "2\n"; │ │ │ │ │ - 69 else if (type.isTriangle()) │ │ │ │ │ - 70 out << "5\n"; │ │ │ │ │ - 71 else if (type.isQuadrilateral()) │ │ │ │ │ - 72 out << "9\n"; │ │ │ │ │ - 73 else if (type.isTetrahedron()) │ │ │ │ │ - 74 out << "10\n"; │ │ │ │ │ - 75 else │ │ │ │ │ - 76 DUNE_THROW(Dune::Exception, "Unhandled geometry type"); │ │ │ │ │ - 77 } │ │ │ │ │ - 78 } │ │ │ │ │ - 79} │ │ │ │ │ - 80 │ │ │ │ │ - 81} /* namespace AreaWriterImplementation */ │ │ │ │ │ - 82 │ │ │ │ │ - 83template │ │ │ │ │ -84void write_glue_area_vtk(const Glue& glue, std::ostream& out) │ │ │ │ │ - 85{ │ │ │ │ │ - 86 using GridView = typename std::decay< decltype(glue.template gridView │ │ │ │ │ -()) >::type; │ │ │ │ │ - 87 using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper; │ │ │ │ │ - 88 using ctype = typename GridView::ctype; │ │ │ │ │ - 89 │ │ │ │ │ - 90 const GridView gv = glue.template gridView(); │ │ │ │ │ - 91 Mapper mapper(gv); │ │ │ │ │ - 92 std::vector coveredArea(mapper.size(), ctype(0)); │ │ │ │ │ - 93 std::vector totalArea(mapper.size(), ctype(1)); │ │ │ │ │ - 94 │ │ │ │ │ - 95 for (const auto& in : intersections(glue, Reverse())) { │ │ │ │ │ - 96 const auto element = in.inside(); │ │ │ │ │ - 97 const auto index = mapper.subIndex(element, in.indexInInside(), 1); │ │ │ │ │ - 98 coveredArea[index] += in.geometryInInside().volume(); │ │ │ │ │ - 99 │ │ │ │ │ - 100 const auto& refElement = Dune::ReferenceElements::general(element.type()); │ │ │ │ │ - 101 const auto& subGeometry = refElement.template geometry<1>(in.indexInInside │ │ │ │ │ -()); │ │ │ │ │ - 102 totalArea[index] = subGeometry.volume(); │ │ │ │ │ - 103 } │ │ │ │ │ - 104 │ │ │ │ │ - 105 for (std::size_t i = 0; i < coveredArea.size(); ++i) │ │ │ │ │ - 106 coveredArea[i] /= totalArea[i]; │ │ │ │ │ - 107 │ │ │ │ │ - 108 out << "# vtk DataFile Version 2.0\n" │ │ │ │ │ - 109 << "Filename: Glue Area\n" │ │ │ │ │ - 110 << "ASCII\n"; │ │ │ │ │ - 111 │ │ │ │ │ - 112 AreaWriterImplementation::write_facet_geometry(gv, out); │ │ │ │ │ - 113 │ │ │ │ │ - 114 out << "CELL_DATA " << coveredArea.size() << "\n" │ │ │ │ │ - 115 << "SCALARS CoveredArea double 1\n" │ │ │ │ │ - 116 << "LOOKUP_TABLE default\n"; │ │ │ │ │ - 117 for (const auto& value : coveredArea) │ │ │ │ │ - 118 out << value << "\n"; │ │ │ │ │ - 119} │ │ │ │ │ - 120 │ │ │ │ │ - 121template │ │ │ │ │ -122void write_glue_area_vtk(const Glue& glue, const std::string& filename) │ │ │ │ │ - 123{ │ │ │ │ │ - 124 std::ofstream out(filename.c_str()); │ │ │ │ │ - 125 write_glue_area_vtk(glue, out); │ │ │ │ │ - 126} │ │ │ │ │ + 50 DUNE_THROW(Dune::Exception, "Unexpected edge number."); │ │ │ │ │ + 51} │ │ │ │ │ + 52 │ │ │ │ │ + 68template │ │ │ │ │ + 69inline typename Corners::value_type │ │ │ │ │ +70interpolate(const Coordinate& x, const Corners& corners) │ │ │ │ │ + 71{ │ │ │ │ │ + 72 auto y = corners[0]; │ │ │ │ │ + 73 for (unsigned i = 0; i < corners.size() - 1; ++i) │ │ │ │ │ + 74 y.axpy(x[i], corners[i+1] - corners[0]); │ │ │ │ │ + 75 return y; │ │ │ │ │ + 76} │ │ │ │ │ + 77 │ │ │ │ │ + 89template │ │ │ │ │ + 90inline typename Normals::value_type │ │ │ │ │ +91interpolate_unit_normals(const Coordinate& x, const Normals& normals) │ │ │ │ │ + 92{ │ │ │ │ │ + 93 auto n = interpolate(x, normals); │ │ │ │ │ + 94 n /= n.two_norm(); │ │ │ │ │ + 95 return n; │ │ │ │ │ + 96} │ │ │ │ │ + 97 │ │ │ │ │ + 109template │ │ │ │ │ + 110inline bool │ │ │ │ │ +111inside(const Coordinate& x, const Field& epsilon) │ │ │ │ │ + 112{ │ │ │ │ │ + 113 const unsigned dim = Coordinate::dimension; │ │ │ │ │ + 114 Field sum(0); │ │ │ │ │ + 115 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ + 116 if (x[i] < -epsilon) │ │ │ │ │ + 117 return false; │ │ │ │ │ + 118 sum += x[i]; │ │ │ │ │ + 119 } │ │ │ │ │ + 120 /* If any xᵢ is NaN, sum will be NaN and this comparison false! */ │ │ │ │ │ + 121 if (sum <= Field(1) + epsilon) │ │ │ │ │ + 122 return true; │ │ │ │ │ + 123 return false; │ │ │ │ │ + 124} │ │ │ │ │ + 125 │ │ │ │ │ + 126} /* namespace ProjectionImplementation */ │ │ │ │ │ 127 │ │ │ │ │ - 128template │ │ │ │ │ -129void write_glue_areas_vtk(const Glue& glue, const std::string& base) │ │ │ │ │ - 130{ │ │ │ │ │ - 131 { │ │ │ │ │ - 132 std::string filename = base; │ │ │ │ │ - 133 filename += "-inside.vtk"; │ │ │ │ │ - 134 write_glue_area_vtk<0>(glue, filename); │ │ │ │ │ - 135 } │ │ │ │ │ - 136 { │ │ │ │ │ - 137 std::string filename = base; │ │ │ │ │ - 138 filename += "-outside.vtk"; │ │ │ │ │ - 139 write_glue_area_vtk<1>(glue, filename); │ │ │ │ │ - 140 } │ │ │ │ │ - 141} │ │ │ │ │ - 142 │ │ │ │ │ - 143} /* namespace GridGlue */ │ │ │ │ │ - 144} /* namespace Dune */ │ │ │ │ │ + 128template │ │ │ │ │ + 129Projection │ │ │ │ │ +130::Projection(const Field overlap, const Field max_normal_product) │ │ │ │ │ + 131 : m_overlap(overlap) │ │ │ │ │ + 132 , m_max_normal_product(max_normal_product) │ │ │ │ │ + 133{ │ │ │ │ │ + 134 /* Nothing. */ │ │ │ │ │ + 135} │ │ │ │ │ + 136 │ │ │ │ │ + 137template │ │ │ │ │ + 138void │ │ │ │ │ + 139Projection │ │ │ │ │ +140::epsilon(const Field epsilon) │ │ │ │ │ + 141{ │ │ │ │ │ + 142 m_epsilon = epsilon; │ │ │ │ │ + 143} │ │ │ │ │ + 144 │ │ │ │ │ + 145template │ │ │ │ │ + 146template │ │ │ │ │ + 147void │ │ │ │ │ + 148Projection │ │ │ │ │ + 149::doProjection(const std::tuple& corners, const std:: │ │ │ │ │ +tuple& normals) │ │ │ │ │ + 150{ │ │ │ │ │ + 151 /* Try to obtain Φ(xᵢ) for each corner xᵢ of the preimage triangle. │ │ │ │ │ + 152 * This means solving a linear system of equations │ │ │ │ │ + 153 * Φ(xᵢ) = (1-α-β) y₀ + α y₁ + β y₂ = xᵢ + δ nᵢ │ │ │ │ │ + 154 * or α (y₁ - y₀) + β (y₂ - y₀) - δ nᵢ = xᵢ - y₀ │ │ │ │ │ + 155 * to obtain the barycentric coordinates (α, β) of Φ(xᵢ) in the image │ │ │ │ │ + 156 * triangle and the distance δ. │ │ │ │ │ + 157 * │ │ │ │ │ + 158 * In the matrix m corresponding to the system, only the third column and │ │ │ │ │ +the │ │ │ │ │ + 159 * right-hand side depend on i. The first two columns can be assembled │ │ │ │ │ +before │ │ │ │ │ + 160 * and reused. │ │ │ │ │ + 161 */ │ │ │ │ │ + 162 using namespace ProjectionImplementation; │ │ │ │ │ + 163 using std::get; │ │ │ │ │ + 164 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ + 165 Matrix m; │ │ │ │ │ + 166 │ │ │ │ │ + 167 const auto& origin = get<0>(corners); │ │ │ │ │ + 168 const auto& origin_normals = get<0>(normals); │ │ │ │ │ + 169 const auto& target = get<1>(corners); │ │ │ │ │ + 170 const auto& target_normals = get<1>(normals); │ │ │ │ │ + 171 auto& images = get<0>(m_images); │ │ │ │ │ + 172 auto& success = get<0>(m_success); │ │ │ │ │ + 173 │ │ │ │ │ + 174 /* directionsᵢ = (yᵢ - y₀) / ||yᵢ - y₀|| │ │ │ │ │ + 175 * These are the first to columns of the system matrix; the rescaling is │ │ │ │ │ +done │ │ │ │ │ + 176 * to ensure all columns have a comparable norm (the last has the normal │ │ │ │ │ +with norm 1. │ │ │ │ │ + 177 */ │ │ │ │ │ + 178 std::array directions; │ │ │ │ │ + 179 std::array scales; │ │ │ │ │ + 180 /* estimator for the diameter of the target face */ │ │ │ │ │ + 181 Field scaleSum(0); │ │ │ │ │ + 182 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ + 183 directions[i] = target[i+1] - target[0]; │ │ │ │ │ + 184 scales[i] = directions[i].infinity_norm(); │ │ │ │ │ + 185 directions[i] /= scales[i]; │ │ │ │ │ + 186 scaleSum += scales[i]; │ │ │ │ │ + 187 } │ │ │ │ │ + 188 │ │ │ │ │ + 189 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ + 190 for (unsigned j = 0; j < dim; ++j) { │ │ │ │ │ + 191 m[j][i] = directions[i][j]; │ │ │ │ │ + 192 } │ │ │ │ │ + 193 } │ │ │ │ │ + 194 │ │ │ │ │ + 195 m_projection_valid = true; │ │ │ │ │ + 196 success.reset(); │ │ │ │ │ + 197 │ │ │ │ │ + 198 /* Now project xᵢ for each i */ │ │ │ │ │ + 199 for (unsigned i = 0; i < origin.size(); ++i) { │ │ │ │ │ + 200 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ + 201 m[j][dim-1] = origin_normals[i][j]; │ │ │ │ │ + 202 │ │ │ │ │ + 203 const Coordinate rhs = origin[i] - target[0]; │ │ │ │ │ + 204 │ │ │ │ │ + 205 try { │ │ │ │ │ + 206 /* y = (α, β, δ) */ │ │ │ │ │ + 207 auto& y = images[i]; │ │ │ │ │ + 208 m.solve(y, rhs); │ │ │ │ │ + 209 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ + 210 y[j] /= scales[j]; │ │ │ │ │ + 211 /* Solving gave us -δ as the term is "-δ nᵢ". */ │ │ │ │ │ + 212 y[dim-1] *= Field(-1); │ │ │ │ │ + 213 │ │ │ │ │ + 214 /* If the forward projection is too far in the wrong direction │ │ │ │ │ + 215 * then this might result in artificial inverse projections or │ │ │ │ │ + 216 * edge intersections. To prevent these wrong cases but not │ │ │ │ │ + 217 * dismiss feasible intersections, the projection is dismissed │ │ │ │ │ + 218 * if the forward projection is further than two times the │ │ │ │ │ + 219 * approximate diameter of the image triangle. │ │ │ │ │ + 220 */ │ │ │ │ │ + 221 if(y[dim-1] < -2*scaleSum) { │ │ │ │ │ + 222 success.set(i,false); │ │ │ │ │ + 223 m_projection_valid = false; │ │ │ │ │ + 224 return; │ │ │ │ │ + 225 } │ │ │ │ │ + 226 │ │ │ │ │ + 227 const bool feasible = projectionFeasible(origin[i], origin_normals[i], y, │ │ │ │ │ +target, target_normals); │ │ │ │ │ + 228 success.set(i, feasible); │ │ │ │ │ + 229 } │ │ │ │ │ + 230 catch (const Dune::FMatrixError&) { │ │ │ │ │ + 231 success.set(i, false); │ │ │ │ │ + 232 m_projection_valid = false; │ │ │ │ │ + 233 } │ │ │ │ │ + 234 } │ │ │ │ │ + 235} │ │ │ │ │ + 236 │ │ │ │ │ + 237template │ │ │ │ │ + 238template │ │ │ │ │ + 239void │ │ │ │ │ + 240Projection │ │ │ │ │ + 241::doInverseProjection(const std::tuple& corners, const │ │ │ │ │ +std::tuple& normals) │ │ │ │ │ + 242{ │ │ │ │ │ + 243 /* Try to obtain Φ⁻¹(yᵢ) for each corner yᵢ of the image triangle. │ │ │ │ │ + 244 * Instead of solving the problem directly (which would lead to │ │ │ │ │ + 245 * non-linear equations), we make use of the forward projection Φ │ │ │ │ │ + 246 * which projects the preimage triangle on the plane spanned by the │ │ │ │ │ + 247 * image triangle. The inverse projection is then given by finding │ │ │ │ │ + 248 * the barycentric coordinates of yᵢ with respect to the triangle │ │ │ │ │ + 249 * with the corners Φ(xᵢ). This way we only have to solve linear │ │ │ │ │ + 250 * equations. │ │ │ │ │ + 251 */ │ │ │ │ │ + 252 │ │ │ │ │ + 253 using namespace ProjectionImplementation; │ │ │ │ │ + 254 using std::get; │ │ │ │ │ + 255 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ + 256 typedef Dune::FieldVector Vector; │ │ │ │ │ + 257 │ │ │ │ │ + 258 /* The inverse projection can only be computed if the forward projection │ │ │ │ │ + 259 * managed to project all xᵢ on the plane spanned by the yᵢ │ │ │ │ │ + 260 */ │ │ │ │ │ + 261 if (!m_projection_valid) { │ │ │ │ │ + 262 get<1>(m_success).reset(); │ │ │ │ │ + 263 return; │ │ │ │ │ + 264 } │ │ │ │ │ + 265 │ │ │ │ │ + 266 const auto& images = get<0>(m_images); │ │ │ │ │ + 267 const auto& target_corners = get<1>(corners); │ │ │ │ │ + 268 auto& preimages = get<1>(m_images); │ │ │ │ │ + 269 auto& success = get<1>(m_success); │ │ │ │ │ + 270 │ │ │ │ │ + 271 std::array v; │ │ │ │ │ + 272 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ + 273 v[i] = interpolate(images[i+1], target_corners); │ │ │ │ │ + 274 v[i] -= interpolate(images[0], target_corners); │ │ │ │ │ + 275 } │ │ │ │ │ + 276 │ │ │ │ │ + 277 Matrix m; │ │ │ │ │ + 278 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ + 279 for (unsigned j = 0; j < dim-1; ++j) { │ │ │ │ │ + 280 m[i][j] = v[i]*v[j]; │ │ │ │ │ + 281 } │ │ │ │ │ + 282 } │ │ │ │ │ + 283 │ │ │ │ │ + 284 for (unsigned i = 0; i < dim; ++i) { │ │ │ │ │ + 285 /* Convert yᵢ to barycentric coordinates with respect to Φ(xⱼ) */ │ │ │ │ │ + 286 v[dim-1] = target_corners[i]; │ │ │ │ │ + 287 v[dim-1] -= interpolate(images[0], target_corners); │ │ │ │ │ + 288 │ │ │ │ │ + 289 Vector rhs, z; │ │ │ │ │ + 290 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ + 291 rhs[j] = v[dim-1]*v[j]; │ │ │ │ │ + 292 m.solve(z, rhs); │ │ │ │ │ + 293 │ │ │ │ │ + 294 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ + 295 preimages[i][j] = z[j]; │ │ │ │ │ + 296 │ │ │ │ │ + 297 /* Calculate distance along normal direction */ │ │ │ │ │ + 298 const auto x = interpolate(z, get<0>(corners)); │ │ │ │ │ + 299 preimages[i][dim-1] = (x - target_corners[i]) * get<1>(normals)[i]; │ │ │ │ │ + 300 │ │ │ │ │ + 301 /* Check y_i lies inside the Φ(xⱼ) */ │ │ │ │ │ + 302 const bool feasible = projectionFeasible(target_corners[i], get<1> │ │ │ │ │ +(normals)[i], preimages[i], get<0>(corners), get<0>(normals)); │ │ │ │ │ + 303 success.set(i, feasible); │ │ │ │ │ + 304 } │ │ │ │ │ + 305} │ │ │ │ │ + 306 │ │ │ │ │ + 307template │ │ │ │ │ + 308template │ │ │ │ │ + 309void │ │ │ │ │ + 310Projection │ │ │ │ │ + 311::doEdgeIntersection(const std::tuple& corners, const │ │ │ │ │ +std::tuple& normals) │ │ │ │ │ + 312{ │ │ │ │ │ + 313 using namespace ProjectionImplementation; │ │ │ │ │ + 314 using std::get; │ │ │ │ │ + 315 │ │ │ │ │ + 316 m_number_of_edge_intersections = 0; │ │ │ │ │ + 317 │ │ │ │ │ + 318 /* There are no edge intersections for 2d, only for 3d */ │ │ │ │ │ + 319 if (dim != 3) │ │ │ │ │ + 320 return; │ │ │ │ │ + 321 │ │ │ │ │ + 322 /* There are no edge intersections │ │ │ │ │ + 323 * - when the projection is invalid, │ │ │ │ │ + 324 * - when the projected triangle lies fully in the target triangle, │ │ │ │ │ + 325 * - or when the target triangle lies fully in the projected triangle. │ │ │ │ │ + 326 */ │ │ │ │ │ + 327 if (!m_projection_valid || get<0>(m_success).all() || get<1> │ │ │ │ │ +(m_success).all()) { │ │ │ │ │ + 328 return; │ │ │ │ │ + 329 } │ │ │ │ │ + 330 │ │ │ │ │ + 331 const auto& images = get<0>(m_images); │ │ │ │ │ + 332 const auto& ys = get<1>(corners); │ │ │ │ │ + 333 │ │ │ │ │ + 334 /* Intersect line through Φ(xᵢ), Φ(xⱼ) with line through yₖ, yₗ: │ │ │ │ │ + 335 We want α, β ∈ ℝ such that │ │ │ │ │ + 336 Φ(xᵢ) + α (Φ(xⱼ) - Φ(xᵢ)) = yₖ + β (yₗ - yₖ) │ │ │ │ │ + 337 or │ │ │ │ │ + 338 α (Φ(xⱼ)-Φ(xᵢ)) + β (yₗ-yₖ) = yₖ-Φ(xᵢ) │ │ │ │ │ + 339 To get a 2×2 system of equations, multiply with yₘ-y₀ for │ │ │ │ │ + 340 m ∈ {1,̣̣2} which are linear indep. (and so the system is │ │ │ │ │ + 341 equivalent to the original 3×2 system) │ │ │ │ │ + 342 */ │ │ │ │ │ + 343 for (unsigned edgex = 0; edgex < dim; ++edgex) { │ │ │ │ │ + 344 unsigned i, j; │ │ │ │ │ + 345 std::tie(i, j) = edgeToCorners(edgex); │ │ │ │ │ + 346 │ │ │ │ │ + 347 /* Both sides of edgex lie in the target triangle means no edge │ │ │ │ │ +intersection */ │ │ │ │ │ + 348 if (get<0>(m_success)[i] && get<0>(m_success)[j]) │ │ │ │ │ + 349 continue; │ │ │ │ │ + 350 │ │ │ │ │ + 351 const auto pxi = interpolate(images[i], ys); │ │ │ │ │ + 352 const auto pxj = interpolate(images[j], ys); │ │ │ │ │ + 353 const auto pxjpxi = pxj - pxi; │ │ │ │ │ + 354 │ │ │ │ │ + 355 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ + 356 typedef Dune::FieldVector Vector; │ │ │ │ │ + 357 │ │ │ │ │ + 358 for (unsigned edgey = 0; edgey < dim; ++edgey) { │ │ │ │ │ + 359 unsigned k, l; │ │ │ │ │ + 360 std::tie(k, l) = edgeToCorners(edgey); │ │ │ │ │ + 361 │ │ │ │ │ + 362 /* Both sides of edgey lie in the projected triangle means no edge │ │ │ │ │ +intersection */ │ │ │ │ │ + 363 if (get<1>(m_success)[k] && get<1>(m_success)[l]) │ │ │ │ │ + 364 continue; │ │ │ │ │ + 365 │ │ │ │ │ + 366 const auto ykyl = ys[k] - ys[l]; │ │ │ │ │ + 367 const auto ykpxi = ys[k] - pxi; │ │ │ │ │ + 368 │ │ │ │ │ + 369 /* If edges are parallel then the intersection is already computed by │ │ │ │ │ +vertex projections. */ │ │ │ │ │ + 370 bool parallel = true; │ │ │ │ │ + 371 for (unsigned h=0; h<3; h++) │ │ │ │ │ + 372 parallel &= std::abs(ykyl[(h+1)%3]*pxjpxi[(h+2)%3] - ykyl[(h+2)%3]*pxjpxi[ │ │ │ │ │ +(h+1)%3])<1e-14; │ │ │ │ │ + 373 if (parallel) │ │ │ │ │ + 374 continue; │ │ │ │ │ + 375 │ │ │ │ │ + 376 Matrix mat; │ │ │ │ │ + 377 Vector rhs, z; │ │ │ │ │ + 378 │ │ │ │ │ + 379 for (unsigned m = 0; m < dim-1; ++m) { │ │ │ │ │ + 380 const auto ym1y0 = ys[m+1] - ys[0]; │ │ │ │ │ + 381 mat[m][0] = pxjpxi * ym1y0; │ │ │ │ │ + 382 mat[m][1] = ykyl * ym1y0; │ │ │ │ │ + 383 rhs[m] = ykpxi * ym1y0; │ │ │ │ │ + 384 } │ │ │ │ │ + 385 │ │ │ │ │ + 386 try { │ │ │ │ │ + 387 using std::isfinite; │ │ │ │ │ + 388 │ │ │ │ │ + 389 mat.solve(z, rhs); │ │ │ │ │ + 390 │ │ │ │ │ + 391 /* If solving the system gives a NaN, the edges are probably parallel. */ │ │ │ │ │ + 392 if (!isfinite(z[0]) || !isfinite(z[1])) │ │ │ │ │ + 393 continue; │ │ │ │ │ + 394 │ │ │ │ │ + 395 /* Filter out corner (pre)images. We only want "real" edge-edge │ │ │ │ │ +intersections here. */ │ │ │ │ │ + 396 if (z[0] < m_epsilon || z[0] > Field(1) - m_epsilon │ │ │ │ │ + 397 || z[1] < m_epsilon || z[1] > Field(1) - m_epsilon) │ │ │ │ │ + 398 continue; │ │ │ │ │ + 399 │ │ │ │ │ + 400 Coordinate local_x = corner(i); │ │ │ │ │ + 401 local_x.axpy(z[0], corner(j) - corner(i)); │ │ │ │ │ + 402 Coordinate local_y = corner(k); │ │ │ │ │ + 403 local_y.axpy(z[1], corner(l) - corner(k)); │ │ │ │ │ + 404 │ │ │ │ │ + 405 /* Make sure the intersection is in the triangle. */ │ │ │ │ │ + 406 if (!inside(local_x, m_epsilon) || !inside(local_y, m_epsilon)) │ │ │ │ │ + 407 continue; │ │ │ │ │ + 408 │ │ │ │ │ + 409 /* Make sure the intersection respects overlap. */ │ │ │ │ │ + 410 auto xy = interpolate(local_x, get<0>(corners)); │ │ │ │ │ + 411 xy -= interpolate(local_y, get<1>(corners)); │ │ │ │ │ + 412 const auto nx = interpolate_unit_normals(local_x, get<0>(normals)); │ │ │ │ │ + 413 const auto ny = interpolate_unit_normals(local_y, get<1>(normals)); │ │ │ │ │ + 414 local_x[dim-1] = -(xy*nx); │ │ │ │ │ + 415 local_y[dim-1] = xy*ny; │ │ │ │ │ + 416 │ │ │ │ │ + 417 if (local_x[dim-1] < -m_overlap-m_epsilon || local_y[dim-1] < -m_overlap- │ │ │ │ │ +m_epsilon) │ │ │ │ │ + 418 continue; │ │ │ │ │ + 419 │ │ │ │ │ + 420 /* Normals should be opposing. */ │ │ │ │ │ + 421 if (nx*ny > m_max_normal_product + m_epsilon) │ │ │ │ │ + 422 continue; │ │ │ │ │ + 423 │ │ │ │ │ + 424 /* Intersection is feasible. Store it. */ │ │ │ │ │ + 425 auto& intersection = m_edge_intersections │ │ │ │ │ +[m_number_of_edge_intersections++]; │ │ │ │ │ + 426 intersection = { {{edgex, edgey}}, {{local_x, local_y}} }; │ │ │ │ │ + 427 } │ │ │ │ │ + 428 catch(const Dune::FMatrixError&) { │ │ │ │ │ + 429 /* Edges might be parallel, ignore and continue with next edge */ │ │ │ │ │ + 430 } │ │ │ │ │ + 431 } │ │ │ │ │ + 432 } │ │ │ │ │ + 433} │ │ │ │ │ + 434 │ │ │ │ │ + 435template │ │ │ │ │ + 436template │ │ │ │ │ + 437bool Projection │ │ │ │ │ + 438::projectionFeasible(const Coordinate& x, const Coordinate& nx, const │ │ │ │ │ +Coordinate& px, const Corners& corners, const Normals& normals) const │ │ │ │ │ + 439{ │ │ │ │ │ + 440 using namespace ProjectionImplementation; │ │ │ │ │ + 441 │ │ │ │ │ + 442 /* Image must be within simplex. */ │ │ │ │ │ + 443 if (!inside(px, m_epsilon)) │ │ │ │ │ + 444 return false; │ │ │ │ │ + 445 │ │ │ │ │ + 446 /* Distance along normal must not be smaller than -overlap. */ │ │ │ │ │ + 447 if (px[dim-1] < -m_overlap-m_epsilon) │ │ │ │ │ + 448 return false; │ │ │ │ │ + 449 │ │ │ │ │ + 450 /* Distance along normal at image must not be smaller than -overlap. */ │ │ │ │ │ + 451 auto xmy = x; │ │ │ │ │ + 452 xmy -= interpolate(px, corners); │ │ │ │ │ + 453 const auto n = interpolate_unit_normals(px, normals); │ │ │ │ │ + 454 const auto d = xmy * n; │ │ │ │ │ + 455 if (d < -m_overlap-m_epsilon) │ │ │ │ │ + 456 return false; │ │ │ │ │ + 457 │ │ │ │ │ + 458 /* Normals at x and Φ(x) are opposing. */ │ │ │ │ │ + 459 if (nx * n > m_max_normal_product + m_epsilon) │ │ │ │ │ + 460 return false; │ │ │ │ │ + 461 │ │ │ │ │ + 462 /* Okay, projection is feasible. */ │ │ │ │ │ + 463 return true; │ │ │ │ │ + 464} │ │ │ │ │ + 465 │ │ │ │ │ + 466template │ │ │ │ │ + 467template │ │ │ │ │ + 468void Projection │ │ │ │ │ +469::project(const std::tuple& corners, const std:: │ │ │ │ │ +tuple& normals) │ │ │ │ │ + 470{ │ │ │ │ │ + 471 doProjection(corners, normals); │ │ │ │ │ + 472 doInverseProjection(corners, normals); │ │ │ │ │ + 473 doEdgeIntersection(corners, normals); │ │ │ │ │ + 474} │ │ │ │ │ + 475 │ │ │ │ │ + 476} /* namespace GridGlue */ │ │ │ │ │ + 477} /* namespace Dune */ │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::write_glue_area_vtk │ │ │ │ │ -void write_glue_area_vtk(const Glue &glue, std::ostream &out) │ │ │ │ │ -Definition: areawriter_impl.hh:84 │ │ │ │ │ -Dune::GridGlue::write_glue_areas_vtk │ │ │ │ │ -void write_glue_areas_vtk(const Glue &glue, const std::string &base) │ │ │ │ │ -Definition: areawriter_impl.hh:129 │ │ │ │ │ -Dune::GridGlue::intersections │ │ │ │ │ -IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ -> &reverse=!reversed) │ │ │ │ │ -Iterate over all intersections of a GridGlue. │ │ │ │ │ -Dune::GridGlue::AreaWriterImplementation::write_facet_geometry │ │ │ │ │ -void write_facet_geometry(const GridView &gv, std::ostream &out) │ │ │ │ │ -Definition: areawriter_impl.hh:25 │ │ │ │ │ -Dune::GridGlue::Reverse │ │ │ │ │ -Definition: rangegenerators.hh:17 │ │ │ │ │ -Dune::GridGlue::AreaWriterImplementation::FacetLayout │ │ │ │ │ -Definition: areawriter_impl.hh:17 │ │ │ │ │ -Dune::GridGlue::AreaWriterImplementation::FacetLayout::contains │ │ │ │ │ -bool contains(Dune::GeometryType gt) const │ │ │ │ │ -Definition: areawriter_impl.hh:18 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::interpolate │ │ │ │ │ +Corners::value_type interpolate(const Coordinate &x, const Corners &corners) │ │ │ │ │ +Definition: projection_impl.hh:70 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::inside │ │ │ │ │ +bool inside(const Coordinate &x, const Field &epsilon) │ │ │ │ │ +Definition: projection_impl.hh:111 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::edgeToCorners │ │ │ │ │ +std::pair< unsigned, unsigned > edgeToCorners(unsigned edge) │ │ │ │ │ +Definition: projection_impl.hh:43 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::corner │ │ │ │ │ +Coordinate corner(unsigned c) │ │ │ │ │ +Definition: projection_impl.hh:24 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals │ │ │ │ │ +Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals │ │ │ │ │ +&normals) │ │ │ │ │ +Definition: projection_impl.hh:91 │ │ │ │ │ +Dune::GridGlue::Projection │ │ │ │ │ +Projection of a line (triangle) on another line (triangle). │ │ │ │ │ +Definition: projection.hh:21 │ │ │ │ │ +Dune::GridGlue::Projection::Field │ │ │ │ │ +Coordinate::field_type Field │ │ │ │ │ +Scalar type. │ │ │ │ │ +Definition: projection.hh:61 │ │ │ │ │ +Dune::GridGlue::Projection::Projection │ │ │ │ │ +Projection(const Field overlap=Field(0), const Field max_normal_product=Field(- │ │ │ │ │ +0.1)) │ │ │ │ │ +Definition: projection_impl.hh:130 │ │ │ │ │ +Dune::GridGlue::Projection::epsilon │ │ │ │ │ +void epsilon(const Field epsilon) │ │ │ │ │ +Set epsilon used for floating-point comparisons. │ │ │ │ │ +Definition: projection_impl.hh:140 │ │ │ │ │ +Dune::GridGlue::Projection::project │ │ │ │ │ +void project(const std::tuple< Corners &, Corners & > &corners, const std:: │ │ │ │ │ +tuple< Normals &, Normals & > &normals) │ │ │ │ │ +Do the actual projection. │ │ │ │ │ +Definition: projection_impl.hh:469 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041.html │ │ │ │ @@ -71,15 +71,15 @@ │ │ │ │ Namespaces │ │ │ │
projection.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │
#include <array>
│ │ │ │ #include <bitset>
│ │ │ │ #include <tuple>
│ │ │ │ -#include "projection_impl.hh"
│ │ │ │ +#include "projection_impl.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041_source.html │ │ │ │ @@ -153,18 +153,18 @@ │ │ │ │
273 const std::array<EdgeIntersection, maxEdgeIntersections>& edgeIntersections() const
│ │ │ │
274 { return m_edge_intersections; }
│ │ │ │
275};
│ │ │ │
276
│ │ │ │
277} /* namespace GridGlue */
│ │ │ │
278} /* namespace Dune */
│ │ │ │
279
│ │ │ │ -
280#include "projection_impl.hh"
│ │ │ │ +
280#include "projection_impl.hh"
│ │ │ │
281
│ │ │ │
282#endif
│ │ │ │ - │ │ │ │ + │ │ │ │
Definition: gridglue.hh:37
│ │ │ │
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:21
│ │ │ │
Coordinate::field_type Field
Scalar type.
Definition: projection.hh:61
│ │ │ │
Projection(const Field overlap=Field(0), const Field max_normal_product=Field(-0.1))
Definition: projection_impl.hh:130
│ │ │ │
const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const
Indicate whether projection (inverse projection) is valid for each corner or not.
Definition: projection.hh:252
│ │ │ │
static constexpr unsigned maxEdgeIntersections
maximum number of edge-edge intersections
Definition: projection.hh:54
│ │ │ │
Images Preimages
Definition: projection.hh:78
│ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: ringcomm.hh File Reference │ │ │ │ +dune-grid-glue: projectionwriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,77 +64,47 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
│ │ │ │ -
ringcomm.hh File Reference
│ │ │ │ +
projectionwriter.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <mpi.h>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/hybridutilities.hh>
│ │ │ │ -#include <dune/geometry/type.hh>
│ │ │ │ +
#include <iostream>
│ │ │ │ +#include <string>
│ │ │ │ +#include <dune/grid-glue/common/projection.hh>
│ │ │ │ +#include "projectionwriter_impl.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::Projection< Coordinate >
 Projection of a line (triangle) on another line (triangle). More...
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::Parallel
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define CheckMPIStatus(A, B)   {}
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename OP , typename... Args>
void Dune::Parallel::MPI_AllApply (MPI_Comm mpicomm, OP &&op, const Args &... data)
 apply an operator locally to a difstributed data set More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
 write projection in VTK format More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, const std::string &filename)
 write projection in VTK format More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::print (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
 Print information about the projection to std::cout stream. More...
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ CheckMPIStatus

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define CheckMPIStatus( A,
 
)   {}
│ │ │ │ -
│ │ │ │ -
Todo:
Implement MPI Status check with exception handling
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,40 +5,38 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -ringcomm.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +projectionwriter.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "projectionwriter_impl.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ -namespace  Dune::Parallel │ │ │ │ │ -  │ │ │ │ │ - Macros │ │ │ │ │ -#define CheckMPIStatus(A, B)   {} │ │ │ │ │ +namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::Parallel::MPI_AllApply (MPI_Comm mpicomm, OP &&op, const Args &... │ │ │ │ │ - data) │ │ │ │ │ -  apply an operator locally to a difstributed data set More... │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals, std::ostream &out) │ │ │ │ │ +  write projection in VTK format More... │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ +  write projection in VTK format More... │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals) │ │ │ │ │ +  Print information about the projection to std::cout stream. More... │ │ │ │ │   │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ CheckMPIStatus ***** │ │ │ │ │ -#define CheckMPIStatus (  A, │ │ │ │ │ -  B  │ │ │ │ │ - )    {} │ │ │ │ │ - Todo: │ │ │ │ │ - Implement MPI Status check with exception handling │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: ringcomm.hh Source File │ │ │ │ +dune-grid-glue: projectionwriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,305 +62,57 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
ringcomm.hh
│ │ │ │ +
projectionwriter.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
5/* IMPLEMENTATION OF CLASS G R I D G L U E */
│ │ │ │ -
6
│ │ │ │ -
8#define CheckMPIStatus(A,B) {}
│ │ │ │ -
9
│ │ │ │ -
10#include <mpi.h>
│ │ │ │ -
11#include <functional>
│ │ │ │ -
12#include <utility>
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ +
5
│ │ │ │ +
6#include <iostream>
│ │ │ │ +
7#include <string>
│ │ │ │ +
8
│ │ │ │ + │ │ │ │ +
10
│ │ │ │ +
11namespace Dune {
│ │ │ │ +
12namespace GridGlue {
│ │ │ │
13
│ │ │ │ -
14#include <dune/common/fvector.hh>
│ │ │ │ -
15#include <dune/common/hybridutilities.hh>
│ │ │ │ -
16
│ │ │ │ -
17#include <dune/geometry/type.hh>
│ │ │ │ -
18
│ │ │ │ -
19namespace Dune {
│ │ │ │ -
20namespace Parallel {
│ │ │ │ -
21
│ │ │ │ -
22 namespace Impl {
│ │ │ │ -
23
│ │ │ │ -
25 template<typename T>
│ │ │ │ -
26 struct MPITypeInfo {};
│ │ │ │ -
27
│ │ │ │ -
28 template<>
│ │ │ │ -
29 struct MPITypeInfo< int >
│ │ │ │ -
30 {
│ │ │ │ -
31 static const unsigned int size = 1;
│ │ │ │ -
32 static inline MPI_Datatype getType()
│ │ │ │ -
33 {
│ │ │ │ -
34 return MPI_INT;
│ │ │ │ -
35 }
│ │ │ │ -
36 };
│ │ │ │ -
37
│ │ │ │ -
38 template<typename K, int N>
│ │ │ │ -
39 struct MPITypeInfo< Dune::FieldVector<K,N> >
│ │ │ │ -
40 {
│ │ │ │ -
41 static const unsigned int size = N;
│ │ │ │ -
42 static inline MPI_Datatype getType()
│ │ │ │ -
43 {
│ │ │ │ -
44 return Dune::MPITraits<K>::getType();
│ │ │ │ -
45 }
│ │ │ │ -
46 };
│ │ │ │ -
47
│ │ │ │ -
48 template<>
│ │ │ │ -
49 struct MPITypeInfo< unsigned int >
│ │ │ │ -
50 {
│ │ │ │ -
51 static const unsigned int size = 1;
│ │ │ │ -
52 static inline MPI_Datatype getType()
│ │ │ │ -
53 {
│ │ │ │ -
54 return MPI_UNSIGNED;
│ │ │ │ -
55 }
│ │ │ │ -
56 };
│ │ │ │ -
57
│ │ │ │ -
58 template<>
│ │ │ │ -
59 struct MPITypeInfo< Dune::GeometryType >
│ │ │ │ -
60 {
│ │ │ │ -
61 static const unsigned int size = 1;
│ │ │ │ -
62 static inline MPI_Datatype getType()
│ │ │ │ -
63 {
│ │ │ │ -
64 return Dune::MPITraits< Dune::GeometryType >::getType();
│ │ │ │ -
65 }
│ │ │ │ -
66 };
│ │ │ │ -
67
│ │ │ │ -
68 template<typename T>
│ │ │ │ -
69 void MPI_SetVectorSize(
│ │ │ │ -
70 std::vector<T> & data,
│ │ │ │ -
71 MPI_Status & status)
│ │ │ │ -
72 {
│ │ │ │ -
73 typedef MPITypeInfo<T> Info;
│ │ │ │ -
74 int sz;
│ │ │ │ -
75 MPI_Get_count(&status, Info::getType(), &sz);
│ │ │ │ -
76 assert(sz%Info::size == 0);
│ │ │ │ -
77 data.resize(sz/Info::size);
│ │ │ │ -
78 }
│ │ │ │ -
79
│ │ │ │ -
89 template<typename T>
│ │ │ │ -
90 void MPI_SendVectorInRing(
│ │ │ │ -
91 std::vector<T> & data,
│ │ │ │ -
92 std::vector<T> & next,
│ │ │ │ -
93 int tag,
│ │ │ │ -
94 int rightrank,
│ │ │ │ -
95 int leftrank,
│ │ │ │ -
96 MPI_Comm comm,
│ │ │ │ -
97 MPI_Request& r_send,
│ │ │ │ -
98 MPI_Request& r_recv
│ │ │ │ -
99 )
│ │ │ │ -
100 {
│ │ │ │ -
101 // mpi status stuff
│ │ │ │ -
102 [[maybe_unused]] int result = 0;
│ │ │ │ -
103 typedef MPITypeInfo<T> Info;
│ │ │ │ -
104 // resize next buffer to maximum size
│ │ │ │ -
105 next.resize(next.capacity());
│ │ │ │ -
106 // send data (explicitly send data.size elements)
│ │ │ │ -
107 result =
│ │ │ │ -
108 MPI_Isend(
│ │ │ │ -
109 &(data[0]), Info::size*data.size(), Info::getType(), rightrank, tag,
│ │ │ │ -
110 comm, &r_send);
│ │ │ │ -
111 // receive up to maximum size. The acutal size is stored in the status
│ │ │ │ -
112 result =
│ │ │ │ -
113 MPI_Irecv(
│ │ │ │ -
114 &(next[0]), Info::size*next.size(), Info::getType(), leftrank, tag,
│ │ │ │ -
115 comm, &r_recv);
│ │ │ │ -
116 // // check result
│ │ │ │ -
117 // MPI_Status status;
│ │ │ │ -
118 // CheckMPIStatus(result, status);
│ │ │ │ -
119 }
│ │ │ │ -
120
│ │ │ │ -
121 template<typename T>
│ │ │ │ -
122 using ptr_t = T*;
│ │ │ │ -
123
│ │ │ │ -
124 /* these helper structs are needed as long as we still support
│ │ │ │ -
125 C++11, as we can't use variadic lambdas */
│ │ │ │ -
126 template<typename... Args>
│ │ │ │ -
127 struct call_MPI_SendVectorInRing
│ │ │ │ -
128 {
│ │ │ │ -
129 std::tuple<Args...> & remotedata;
│ │ │ │ -
130 std::tuple<Args...> & nextdata;
│ │ │ │ -
131 int & tag;
│ │ │ │ -
132 int & rightrank;
│ │ │ │ -
133 int & leftrank;
│ │ │ │ -
134 MPI_Comm & mpicomm;
│ │ │ │ -
135 std::array<MPI_Request,sizeof...(Args)> & requests_send;
│ │ │ │ -
136 std::array<MPI_Request,sizeof...(Args)> & requests_recv;
│ │ │ │ -
137
│ │ │ │ -
138 template<typename I>
│ │ │ │ -
139 void operator()(I i)
│ │ │ │ -
140 {
│ │ │ │ -
141 MPI_SendVectorInRing(
│ │ │ │ -
142 std::get<i>(remotedata),
│ │ │ │ -
143 std::get<i>(nextdata),
│ │ │ │ -
144 tag+i,
│ │ │ │ -
145 rightrank, leftrank, mpicomm,
│ │ │ │ -
146 requests_send[i],
│ │ │ │ -
147 requests_recv[i]);
│ │ │ │ -
148 }
│ │ │ │ -
149 };
│ │ │ │ -
150 template<typename... Args>
│ │ │ │ -
151 struct call_MPI_SetVectorSize
│ │ │ │ -
152 {
│ │ │ │ -
153 std::tuple<Args...> & nextdata;
│ │ │ │ -
154 std::array<MPI_Status,sizeof...(Args)> & status_recv;
│ │ │ │ -
155
│ │ │ │ -
156 template<typename I>
│ │ │ │ -
157 void operator()(I i)
│ │ │ │ -
158 {
│ │ │ │ -
159 MPI_SetVectorSize(std::get<i>(nextdata),status_recv[i]);
│ │ │ │ -
160 }
│ │ │ │ -
161 };
│ │ │ │ -
162
│ │ │ │ -
163 template<typename OP, std::size_t... Indices, typename... Args>
│ │ │ │ -
164 void MPI_AllApply_impl(MPI_Comm mpicomm,
│ │ │ │ -
165 OP && op,
│ │ │ │ -
166 std::index_sequence<Indices...> indices,
│ │ │ │ -
167 const Args&... data)
│ │ │ │ -
168 {
│ │ │ │ -
169 constexpr std::size_t N = sizeof...(Args);
│ │ │ │ -
170 int myrank = 0;
│ │ │ │ -
171 int commsize = 0;
│ │ │ │ -
172#if HAVE_MPI
│ │ │ │ -
173 MPI_Comm_rank(mpicomm, &myrank);
│ │ │ │ -
174 MPI_Comm_size(mpicomm, &commsize);
│ │ │ │ -
175#endif // HAVE_MPI
│ │ │ │ -
176
│ │ │ │ -
177 if (commsize > 1)
│ │ │ │ -
178 {
│ │ │ │ -
179#ifdef DEBUG_GRIDGLUE_PARALLELMERGE
│ │ │ │ -
180 std::cout << myrank << " Start Communication, size " << commsize << std::endl;
│ │ │ │ -
181#endif
│ │ │ │ -
182
│ │ │ │ -
183 // get data sizes
│ │ │ │ -
184 std::array<unsigned int, N> size({ ((unsigned int)data.size())... });
│ │ │ │ -
185
│ │ │ │ -
186 // communicate max data size
│ │ │ │ -
187 std::array<unsigned int, N> maxSize;
│ │ │ │ -
188 MPI_Allreduce(&size, &maxSize,
│ │ │ │ -
189 size.size(), MPI_UNSIGNED, MPI_MAX, mpicomm);
│ │ │ │ -
190#ifdef DEBUG_GRIDGLUE_PARALLELMERGE
│ │ │ │ -
191 std::cout << myrank << " maxSize " << "done... " << std::endl;
│ │ │ │ -
192#endif
│ │ │ │ -
193
│ │ │ │ -
194 // allocate receiving buffers with maxsize to ensure sufficient buffer size for communication
│ │ │ │ -
195 std::tuple<Args...> remotedata { Args(maxSize[Indices])... };
│ │ │ │ -
196
│ │ │ │ -
197 // copy local data to receiving buffer
│ │ │ │ -
198 remotedata = std::tie(data...);
│ │ │ │ -
199
│ │ │ │ -
200 // allocate second set of receiving buffers necessary for async communication
│ │ │ │ -
201 std::tuple<Args...> nextdata { Args(maxSize[Indices])... };
│ │ │ │ -
202
│ │ │ │ -
203 // communicate data in the ring
│ │ │ │ -
204 int rightrank = (myrank + 1 + commsize) % commsize;
│ │ │ │ -
205 int leftrank = (myrank - 1 + commsize) % commsize;
│ │ │ │ -
206
│ │ │ │ -
207 std::cout << myrank << ": size = " << commsize << std::endl;
│ │ │ │ -
208 std::cout << myrank << ": left = " << leftrank
│ │ │ │ -
209 << " right = " << rightrank << std::endl;
│ │ │ │ -
210
│ │ │ │ -
211 // currently the remote data is our own data
│ │ │ │ -
212 int remoterank = myrank;
│ │ │ │ -
213
│ │ │ │ -
214 for (int i=1; i<commsize; i++)
│ │ │ │ -
215 {
│ │ │ │ -
216 // in this iteration we will receive data from nextrank
│ │ │ │ -
217 int nextrank = (myrank - i + commsize) % commsize;
│ │ │ │ -
218
│ │ │ │ -
219 std::cout << myrank << ": next = " << nextrank << std::endl;
│ │ │ │ -
220
│ │ │ │ -
221 // send remote data to right neighbor and receive from left neighbor
│ │ │ │ -
222 std::array<MPI_Request,N> requests_send;
│ │ │ │ -
223 std::array<MPI_Request,N> requests_recv;
│ │ │ │ -
224
│ │ │ │ -
225 int tag = 0;
│ │ │ │ -
226 Dune::Hybrid::forEach(indices,
│ │ │ │ -
227 // [&](auto i){
│ │ │ │ -
228 // MPI_SendVectorInRing(
│ │ │ │ -
229 // std::get<i>(remotedata),
│ │ │ │ -
230 // std::get<i>(nextdata),
│ │ │ │ -
231 // tag+i,
│ │ │ │ -
232 // rightrank, leftrank, mpicomm,
│ │ │ │ -
233 // requests_send[i],
│ │ │ │ -
234 // requests_recv[i]);
│ │ │ │ -
235 // });
│ │ │ │ -
236 call_MPI_SendVectorInRing<Args...>({
│ │ │ │ -
237 remotedata,
│ │ │ │ -
238 nextdata,
│ │ │ │ -
239 tag,
│ │ │ │ -
240 rightrank, leftrank, mpicomm,
│ │ │ │ -
241 requests_send,
│ │ │ │ -
242 requests_recv
│ │ │ │ -
243 }));
│ │ │ │ -
244
│ │ │ │ -
245 // apply operator
│ │ │ │ -
246 op(remoterank,std::get<Indices>(remotedata)...);
│ │ │ │ -
247
│ │ │ │ -
248 // wait for communication to finalize
│ │ │ │ -
249 std::array<MPI_Status,N> status_send;
│ │ │ │ -
250 std::array<MPI_Status,N> status_recv;
│ │ │ │ -
251 MPI_Waitall(N,&requests_recv[0],&status_recv[0]);
│ │ │ │ -
252
│ │ │ │ -
253 // we finished receiving from nextrank and thus remoterank = nextrank
│ │ │ │ -
254 remoterank = nextrank;
│ │ │ │ -
255
│ │ │ │ -
256 // get current data sizes
│ │ │ │ -
257 // and resize vectors
│ │ │ │ -
258 Dune::Hybrid::forEach(indices,
│ │ │ │ -
259 // [&](auto i){
│ │ │ │ -
260 // MPI_SetVectorSize(std::get<i>(nextdata),status_recv[i]);
│ │ │ │ -
261 // });
│ │ │ │ -
262 call_MPI_SetVectorSize<Args...>({
│ │ │ │ -
263 nextdata, status_recv
│ │ │ │ -
264 }));
│ │ │ │ -
265
│ │ │ │ -
266 MPI_Waitall(N,&requests_send[0],&status_send[0]);
│ │ │ │ -
267
│ │ │ │ -
268 // swap the communication buffers
│ │ │ │ -
269 std::swap(remotedata,nextdata);
│ │ │ │ -
270 }
│ │ │ │ -
271
│ │ │ │ -
272 // last apply (or the only one in the case of sequential application)
│ │ │ │ -
273 op(remoterank,std::get<Indices>(remotedata)...);
│ │ │ │ -
274 }
│ │ │ │ -
275 else // sequential
│ │ │ │ -
276 {
│ │ │ │ -
277 op(myrank,data...);
│ │ │ │ -
278 }
│ │ │ │ -
279 }
│ │ │ │ -
280
│ │ │ │ -
281 } // end namespace Impl
│ │ │ │ -
282
│ │ │ │ -
296template<typename OP, typename... Args>
│ │ │ │ -
297void MPI_AllApply(MPI_Comm mpicomm,
│ │ │ │ -
298 OP && op,
│ │ │ │ -
299 const Args& ... data)
│ │ │ │ -
300{
│ │ │ │ -
301 Impl::MPI_AllApply_impl(
│ │ │ │ -
302 mpicomm,
│ │ │ │ -
303 std::forward<OP>(op),
│ │ │ │ -
304 std::make_index_sequence<sizeof...(Args)>(),
│ │ │ │ -
305 data...
│ │ │ │ -
306 );
│ │ │ │ -
307}
│ │ │ │ -
308
│ │ │ │ -
309} // end namespace Parallel
│ │ │ │ -
310} // end namespace Dune
│ │ │ │ +
28template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
29void write(const Projection<Coordinate>& projection,
│ │ │ │ +
30 const Corners& corners,
│ │ │ │ +
31 const Normals& normals,
│ │ │ │ +
32 std::ostream& out);
│ │ │ │ +
33
│ │ │ │ +
40template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
41void write(const Projection<Coordinate>& projection,
│ │ │ │ +
42 const Corners& corners,
│ │ │ │ +
43 const Normals& normals,
│ │ │ │ +
44 const std::string& filename);
│ │ │ │ +
54template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
55void print(const Projection<Coordinate>& projection,
│ │ │ │ +
56 const Corners& corners,
│ │ │ │ +
57 const Normals& normals);
│ │ │ │ +
58
│ │ │ │ +
59} /* namespace GridGlue */
│ │ │ │ +
60} /* namespace Dune */
│ │ │ │ +
61
│ │ │ │ + │ │ │ │ +
63
│ │ │ │ +
64#endif
│ │ │ │ + │ │ │ │ + │ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
void MPI_AllApply(MPI_Comm mpicomm, OP &&op, const Args &... data)
apply an operator locally to a difstributed data set
Definition: ringcomm.hh:297
│ │ │ │ +
void write(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
write projection in VTK format
Definition: projectionwriter_impl.hh:86
│ │ │ │ +
void print(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
Print information about the projection to std::cout stream.
Definition: projectionwriter_impl.hh:140
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,309 +5,63 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -ringcomm.hh │ │ │ │ │ +projectionwriter.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ - 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ - 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ - 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ + 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 5/* IMPLEMENTATION OF CLASS G R I D G L U E */ │ │ │ │ │ - 6 │ │ │ │ │ -8#define CheckMPIStatus(A,B) {} │ │ │ │ │ - 9 │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12#include │ │ │ │ │ + 3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ + 4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ + 5 │ │ │ │ │ + 6#include │ │ │ │ │ + 7#include │ │ │ │ │ + 8 │ │ │ │ │ + 9#include │ │ │ │ │ + 10 │ │ │ │ │ + 11namespace Dune { │ │ │ │ │ + 12namespace GridGlue { │ │ │ │ │ 13 │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16 │ │ │ │ │ - 17#include │ │ │ │ │ - 18 │ │ │ │ │ - 19namespace Dune { │ │ │ │ │ -20namespace Parallel { │ │ │ │ │ - 21 │ │ │ │ │ - 22 namespace Impl { │ │ │ │ │ - 23 │ │ │ │ │ - 25 template │ │ │ │ │ - 26 struct MPITypeInfo {}; │ │ │ │ │ - 27 │ │ │ │ │ - 28 template<> │ │ │ │ │ - 29 struct MPITypeInfo< int > │ │ │ │ │ - 30 { │ │ │ │ │ - 31 static const unsigned int size = 1; │ │ │ │ │ - 32 static inline MPI_Datatype getType() │ │ │ │ │ - 33 { │ │ │ │ │ - 34 return MPI_INT; │ │ │ │ │ - 35 } │ │ │ │ │ - 36 }; │ │ │ │ │ - 37 │ │ │ │ │ - 38 template │ │ │ │ │ - 39 struct MPITypeInfo< Dune::FieldVector > │ │ │ │ │ - 40 { │ │ │ │ │ - 41 static const unsigned int size = N; │ │ │ │ │ - 42 static inline MPI_Datatype getType() │ │ │ │ │ - 43 { │ │ │ │ │ - 44 return Dune::MPITraits::getType(); │ │ │ │ │ - 45 } │ │ │ │ │ - 46 }; │ │ │ │ │ - 47 │ │ │ │ │ - 48 template<> │ │ │ │ │ - 49 struct MPITypeInfo< unsigned int > │ │ │ │ │ - 50 { │ │ │ │ │ - 51 static const unsigned int size = 1; │ │ │ │ │ - 52 static inline MPI_Datatype getType() │ │ │ │ │ - 53 { │ │ │ │ │ - 54 return MPI_UNSIGNED; │ │ │ │ │ - 55 } │ │ │ │ │ - 56 }; │ │ │ │ │ - 57 │ │ │ │ │ - 58 template<> │ │ │ │ │ - 59 struct MPITypeInfo< Dune::GeometryType > │ │ │ │ │ - 60 { │ │ │ │ │ - 61 static const unsigned int size = 1; │ │ │ │ │ - 62 static inline MPI_Datatype getType() │ │ │ │ │ - 63 { │ │ │ │ │ - 64 return Dune::MPITraits< Dune::GeometryType >::getType(); │ │ │ │ │ - 65 } │ │ │ │ │ - 66 }; │ │ │ │ │ - 67 │ │ │ │ │ - 68 template │ │ │ │ │ - 69 void MPI_SetVectorSize( │ │ │ │ │ - 70 std::vector & data, │ │ │ │ │ - 71 MPI_Status & status) │ │ │ │ │ - 72 { │ │ │ │ │ - 73 typedef MPITypeInfo Info; │ │ │ │ │ - 74 int sz; │ │ │ │ │ - 75 MPI_Get_count(&status, Info::getType(), &sz); │ │ │ │ │ - 76 assert(sz%Info::size == 0); │ │ │ │ │ - 77 data.resize(sz/Info::size); │ │ │ │ │ - 78 } │ │ │ │ │ - 79 │ │ │ │ │ - 89 template │ │ │ │ │ - 90 void MPI_SendVectorInRing( │ │ │ │ │ - 91 std::vector & data, │ │ │ │ │ - 92 std::vector & next, │ │ │ │ │ - 93 int tag, │ │ │ │ │ - 94 int rightrank, │ │ │ │ │ - 95 int leftrank, │ │ │ │ │ - 96 MPI_Comm comm, │ │ │ │ │ - 97 MPI_Request& r_send, │ │ │ │ │ - 98 MPI_Request& r_recv │ │ │ │ │ - 99 ) │ │ │ │ │ - 100 { │ │ │ │ │ - 101 // mpi status stuff │ │ │ │ │ - 102 [[maybe_unused]] int result = 0; │ │ │ │ │ - 103 typedef MPITypeInfo Info; │ │ │ │ │ - 104 // resize next buffer to maximum size │ │ │ │ │ - 105 next.resize(next.capacity()); │ │ │ │ │ - 106 // send data (explicitly send data.size elements) │ │ │ │ │ - 107 result = │ │ │ │ │ - 108 MPI_Isend( │ │ │ │ │ - 109 &(data[0]), Info::size*data.size(), Info::getType(), rightrank, tag, │ │ │ │ │ - 110 comm, &r_send); │ │ │ │ │ - 111 // receive up to maximum size. The acutal size is stored in the status │ │ │ │ │ - 112 result = │ │ │ │ │ - 113 MPI_Irecv( │ │ │ │ │ - 114 &(next[0]), Info::size*next.size(), Info::getType(), leftrank, tag, │ │ │ │ │ - 115 comm, &r_recv); │ │ │ │ │ - 116 // // check result │ │ │ │ │ - 117 // MPI_Status status; │ │ │ │ │ - 118 // CheckMPIStatus(result, status); │ │ │ │ │ - 119 } │ │ │ │ │ - 120 │ │ │ │ │ - 121 template │ │ │ │ │ - 122 using ptr_t = T*; │ │ │ │ │ - 123 │ │ │ │ │ - 124 /* these helper structs are needed as long as we still support │ │ │ │ │ - 125 C++11, as we can't use variadic lambdas */ │ │ │ │ │ - 126 template │ │ │ │ │ - 127 struct call_MPI_SendVectorInRing │ │ │ │ │ - 128 { │ │ │ │ │ - 129 std::tuple & remotedata; │ │ │ │ │ - 130 std::tuple & nextdata; │ │ │ │ │ - 131 int & tag; │ │ │ │ │ - 132 int & rightrank; │ │ │ │ │ - 133 int & leftrank; │ │ │ │ │ - 134 MPI_Comm & mpicomm; │ │ │ │ │ - 135 std::array & requests_send; │ │ │ │ │ - 136 std::array & requests_recv; │ │ │ │ │ - 137 │ │ │ │ │ - 138 template │ │ │ │ │ - 139 void operator()(I i) │ │ │ │ │ - 140 { │ │ │ │ │ - 141 MPI_SendVectorInRing( │ │ │ │ │ - 142 std::get(remotedata), │ │ │ │ │ - 143 std::get(nextdata), │ │ │ │ │ - 144 tag+i, │ │ │ │ │ - 145 rightrank, leftrank, mpicomm, │ │ │ │ │ - 146 requests_send[i], │ │ │ │ │ - 147 requests_recv[i]); │ │ │ │ │ - 148 } │ │ │ │ │ - 149 }; │ │ │ │ │ - 150 template │ │ │ │ │ - 151 struct call_MPI_SetVectorSize │ │ │ │ │ - 152 { │ │ │ │ │ - 153 std::tuple & nextdata; │ │ │ │ │ - 154 std::array & status_recv; │ │ │ │ │ - 155 │ │ │ │ │ - 156 template │ │ │ │ │ - 157 void operator()(I i) │ │ │ │ │ - 158 { │ │ │ │ │ - 159 MPI_SetVectorSize(std::get(nextdata),status_recv[i]); │ │ │ │ │ - 160 } │ │ │ │ │ - 161 }; │ │ │ │ │ - 162 │ │ │ │ │ - 163 template │ │ │ │ │ - 164 void MPI_AllApply_impl(MPI_Comm mpicomm, │ │ │ │ │ - 165 OP && op, │ │ │ │ │ - 166 std::index_sequence indices, │ │ │ │ │ - 167 const Args&... data) │ │ │ │ │ - 168 { │ │ │ │ │ - 169 constexpr std::size_t N = sizeof...(Args); │ │ │ │ │ - 170 int myrank = 0; │ │ │ │ │ - 171 int commsize = 0; │ │ │ │ │ - 172#if HAVE_MPI │ │ │ │ │ - 173 MPI_Comm_rank(mpicomm, &myrank); │ │ │ │ │ - 174 MPI_Comm_size(mpicomm, &commsize); │ │ │ │ │ - 175#endif // HAVE_MPI │ │ │ │ │ - 176 │ │ │ │ │ - 177 if (commsize > 1) │ │ │ │ │ - 178 { │ │ │ │ │ - 179#ifdef DEBUG_GRIDGLUE_PARALLELMERGE │ │ │ │ │ - 180 std::cout << myrank << " Start Communication, size " << commsize << std:: │ │ │ │ │ -endl; │ │ │ │ │ - 181#endif │ │ │ │ │ - 182 │ │ │ │ │ - 183 // get data sizes │ │ │ │ │ - 184 std::array size({ ((unsigned int)data.size())... }); │ │ │ │ │ - 185 │ │ │ │ │ - 186 // communicate max data size │ │ │ │ │ - 187 std::array maxSize; │ │ │ │ │ - 188 MPI_Allreduce(&size, &maxSize, │ │ │ │ │ - 189 size.size(), MPI_UNSIGNED, MPI_MAX, mpicomm); │ │ │ │ │ - 190#ifdef DEBUG_GRIDGLUE_PARALLELMERGE │ │ │ │ │ - 191 std::cout << myrank << " maxSize " << "done... " << std::endl; │ │ │ │ │ - 192#endif │ │ │ │ │ - 193 │ │ │ │ │ - 194 // allocate receiving buffers with maxsize to ensure sufficient buffer │ │ │ │ │ -size for communication │ │ │ │ │ - 195 std::tuple remotedata { Args(maxSize[Indices])... }; │ │ │ │ │ - 196 │ │ │ │ │ - 197 // copy local data to receiving buffer │ │ │ │ │ - 198 remotedata = std::tie(data...); │ │ │ │ │ - 199 │ │ │ │ │ - 200 // allocate second set of receiving buffers necessary for async │ │ │ │ │ -communication │ │ │ │ │ - 201 std::tuple nextdata { Args(maxSize[Indices])... }; │ │ │ │ │ - 202 │ │ │ │ │ - 203 // communicate data in the ring │ │ │ │ │ - 204 int rightrank = (myrank + 1 + commsize) % commsize; │ │ │ │ │ - 205 int leftrank = (myrank - 1 + commsize) % commsize; │ │ │ │ │ - 206 │ │ │ │ │ - 207 std::cout << myrank << ": size = " << commsize << std::endl; │ │ │ │ │ - 208 std::cout << myrank << ": left = " << leftrank │ │ │ │ │ - 209 << " right = " << rightrank << std::endl; │ │ │ │ │ - 210 │ │ │ │ │ - 211 // currently the remote data is our own data │ │ │ │ │ - 212 int remoterank = myrank; │ │ │ │ │ - 213 │ │ │ │ │ - 214 for (int i=1; i &projection, const Corners &corners, │ │ │ │ │ +const Normals &normals, std::ostream &out) │ │ │ │ │ +write projection in VTK format │ │ │ │ │ +Definition: projectionwriter_impl.hh:86 │ │ │ │ │ +Dune::GridGlue::print │ │ │ │ │ +void print(const Projection< Coordinate > &projection, const Corners &corners, │ │ │ │ │ +const Normals &normals) │ │ │ │ │ +Print information about the projection to std::cout stream. │ │ │ │ │ +Definition: projectionwriter_impl.hh:140 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projection_impl.hh File Reference │ │ │ │ +dune-grid-glue: areawriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,47 +65,41 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
projection_impl.hh File Reference
│ │ │ │ +
areawriter.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <cmath>
│ │ │ │ +
#include <ostream>
│ │ │ │ +#include <string>
│ │ │ │ +#include "areawriter_impl.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
namespace  Dune::GridGlue::ProjectionImplementation
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<typename Coordinate , typename Field >
Coordinate Dune::GridGlue::ProjectionImplementation::corner (unsigned c)
 
std::pair< unsigned, unsigned > Dune::GridGlue::ProjectionImplementation::edgeToCorners (unsigned edge)
 
template<typename Coordinate , typename Corners >
Corners::value_type Dune::GridGlue::ProjectionImplementation::interpolate (const Coordinate &x, const Corners &corners)
 
template<typename Coordinate , typename Normals >
Normals::value_type Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals (const Coordinate &x, const Normals &normals)
 
template<typename Coordinate , typename Field >
bool Dune::GridGlue::ProjectionImplementation::inside (const Coordinate &x, const Field &epsilon)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out)
 
template<int side, typename Glue >
void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string &filename)
 
template<typename Glue >
void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string &base)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,44 +6,32 @@ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -projection_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +areawriter.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "areawriter_impl.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -namespace  Dune::GridGlue::ProjectionImplementation │ │ │ │ │ -  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ - Coordinate Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - corner (unsigned c) │ │ │ │ │ -  │ │ │ │ │ -std::pair< unsigned, unsigned > Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - edgeToCorners (unsigned edge) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - Corners::value_type Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - interpolate (const Coordinate &x, const │ │ │ │ │ - Corners &corners) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - Normals::value_type Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - interpolate_unit_normals (const Coordinate &x, │ │ │ │ │ - const Normals &normals) │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, std::ostream &out) │ │ │ │ │   │ │ │ │ │ -template │ │ │ │ │ - bool Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - inside (const Coordinate &x, const Field │ │ │ │ │ - &epsilon) │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_area_vtk (const Glue &glue, const std::string │ │ │ │ │ + &filename) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string │ │ │ │ │ + &base) │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projection_impl.hh Source File │ │ │ │ +dune-grid-glue: areawriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,449 +62,47 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
projection_impl.hh
│ │ │ │ +
areawriter.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#include <dune/common/fmatrix.hh>
│ │ │ │ -
4
│ │ │ │ -
5#include <cmath>
│ │ │ │ -
6
│ │ │ │ -
7namespace Dune {
│ │ │ │ -
8namespace GridGlue {
│ │ │ │ -
9
│ │ │ │ -
10namespace ProjectionImplementation {
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │ +
5
│ │ │ │ +
6#include <ostream>
│ │ │ │ +
7#include <string>
│ │ │ │ +
8
│ │ │ │ +
9namespace Dune {
│ │ │ │ +
10namespace GridGlue {
│ │ │ │
11
│ │ │ │ -
22template<typename Coordinate, typename Field>
│ │ │ │ -
23inline Coordinate
│ │ │ │ -
24corner(unsigned c)
│ │ │ │ -
25{
│ │ │ │ -
26 Coordinate x(Field(0));
│ │ │ │ -
27 if (c == 0)
│ │ │ │ -
28 return x;
│ │ │ │ -
29 x[c-1] = Field(1);
│ │ │ │ -
30 return x;
│ │ │ │ -
31}
│ │ │ │ -
32
│ │ │ │ -
42inline std::pair<unsigned, unsigned>
│ │ │ │ -
43edgeToCorners(unsigned edge)
│ │ │ │ -
44{
│ │ │ │ -
45 switch(edge) {
│ │ │ │ -
46 case 0: return {0, 1};
│ │ │ │ -
47 case 1: return {0, 2};
│ │ │ │ -
48 case 2: return {1, 2};
│ │ │ │ -
49 }
│ │ │ │ -
50 DUNE_THROW(Dune::Exception, "Unexpected edge number.");
│ │ │ │ -
51}
│ │ │ │ -
52
│ │ │ │ -
68template<typename Coordinate, typename Corners>
│ │ │ │ -
69inline typename Corners::value_type
│ │ │ │ -
70interpolate(const Coordinate& x, const Corners& corners)
│ │ │ │ -
71{
│ │ │ │ -
72 auto y = corners[0];
│ │ │ │ -
73 for (unsigned i = 0; i < corners.size() - 1; ++i)
│ │ │ │ -
74 y.axpy(x[i], corners[i+1] - corners[0]);
│ │ │ │ -
75 return y;
│ │ │ │ -
76}
│ │ │ │ -
77
│ │ │ │ -
89template<typename Coordinate, typename Normals>
│ │ │ │ -
90inline typename Normals::value_type
│ │ │ │ -
91interpolate_unit_normals(const Coordinate& x, const Normals& normals)
│ │ │ │ -
92{
│ │ │ │ -
93 auto n = interpolate(x, normals);
│ │ │ │ -
94 n /= n.two_norm();
│ │ │ │ -
95 return n;
│ │ │ │ -
96}
│ │ │ │ -
97
│ │ │ │ -
109template<typename Coordinate, typename Field>
│ │ │ │ -
110inline bool
│ │ │ │ -
111inside(const Coordinate& x, const Field& epsilon)
│ │ │ │ -
112{
│ │ │ │ -
113 const unsigned dim = Coordinate::dimension;
│ │ │ │ -
114 Field sum(0);
│ │ │ │ -
115 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ -
116 if (x[i] < -epsilon)
│ │ │ │ -
117 return false;
│ │ │ │ -
118 sum += x[i];
│ │ │ │ -
119 }
│ │ │ │ -
120 /* If any xᵢ is NaN, sum will be NaN and this comparison false! */
│ │ │ │ -
121 if (sum <= Field(1) + epsilon)
│ │ │ │ -
122 return true;
│ │ │ │ -
123 return false;
│ │ │ │ -
124}
│ │ │ │ -
125
│ │ │ │ -
126} /* namespace ProjectionImplementation */
│ │ │ │ -
127
│ │ │ │ -
128template<typename Coordinate>
│ │ │ │ - │ │ │ │ -
130::Projection(const Field overlap, const Field max_normal_product)
│ │ │ │ -
131 : m_overlap(overlap)
│ │ │ │ -
132 , m_max_normal_product(max_normal_product)
│ │ │ │ -
133{
│ │ │ │ -
134 /* Nothing. */
│ │ │ │ -
135}
│ │ │ │ -
136
│ │ │ │ -
137template<typename Coordinate>
│ │ │ │ -
138void
│ │ │ │ - │ │ │ │ -
140::epsilon(const Field epsilon)
│ │ │ │ -
141{
│ │ │ │ -
142 m_epsilon = epsilon;
│ │ │ │ -
143}
│ │ │ │ -
144
│ │ │ │ -
145template<typename Coordinate>
│ │ │ │ -
146template<typename Corners, typename Normals>
│ │ │ │ -
147void
│ │ │ │ - │ │ │ │ -
149::doProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ -
150{
│ │ │ │ -
151 /* Try to obtain Φ(xᵢ) for each corner xᵢ of the preimage triangle.
│ │ │ │ -
152 * This means solving a linear system of equations
│ │ │ │ -
153 * Φ(xᵢ) = (1-α-β) y₀ + α y₁ + β y₂ = xᵢ + δ nᵢ
│ │ │ │ -
154 * or α (y₁ - y₀) + β (y₂ - y₀) - δ nᵢ = xᵢ - y₀
│ │ │ │ -
155 * to obtain the barycentric coordinates (α, β) of Φ(xᵢ) in the image
│ │ │ │ -
156 * triangle and the distance δ.
│ │ │ │ -
157 *
│ │ │ │ -
158 * In the matrix m corresponding to the system, only the third column and the
│ │ │ │ -
159 * right-hand side depend on i. The first two columns can be assembled before
│ │ │ │ -
160 * and reused.
│ │ │ │ -
161 */
│ │ │ │ -
162 using namespace ProjectionImplementation;
│ │ │ │ -
163 using std::get;
│ │ │ │ -
164 typedef Dune::FieldMatrix<Field, dim, dim> Matrix;
│ │ │ │ -
165 Matrix m;
│ │ │ │ -
166
│ │ │ │ -
167 const auto& origin = get<0>(corners);
│ │ │ │ -
168 const auto& origin_normals = get<0>(normals);
│ │ │ │ -
169 const auto& target = get<1>(corners);
│ │ │ │ -
170 const auto& target_normals = get<1>(normals);
│ │ │ │ -
171 auto& images = get<0>(m_images);
│ │ │ │ -
172 auto& success = get<0>(m_success);
│ │ │ │ -
173
│ │ │ │ -
174 /* directionsᵢ = (yᵢ - y₀) / ||yᵢ - y₀||
│ │ │ │ -
175 * These are the first to columns of the system matrix; the rescaling is done
│ │ │ │ -
176 * to ensure all columns have a comparable norm (the last has the normal with norm 1.
│ │ │ │ -
177 */
│ │ │ │ -
178 std::array<Coordinate, dim-1> directions;
│ │ │ │ -
179 std::array<Field, dim-1> scales;
│ │ │ │ -
180 /* estimator for the diameter of the target face */
│ │ │ │ -
181 Field scaleSum(0);
│ │ │ │ -
182 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ -
183 directions[i] = target[i+1] - target[0];
│ │ │ │ -
184 scales[i] = directions[i].infinity_norm();
│ │ │ │ -
185 directions[i] /= scales[i];
│ │ │ │ -
186 scaleSum += scales[i];
│ │ │ │ -
187 }
│ │ │ │ -
188
│ │ │ │ -
189 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ -
190 for (unsigned j = 0; j < dim; ++j) {
│ │ │ │ -
191 m[j][i] = directions[i][j];
│ │ │ │ -
192 }
│ │ │ │ -
193 }
│ │ │ │ -
194
│ │ │ │ -
195 m_projection_valid = true;
│ │ │ │ -
196 success.reset();
│ │ │ │ -
197
│ │ │ │ -
198 /* Now project xᵢ for each i */
│ │ │ │ -
199 for (unsigned i = 0; i < origin.size(); ++i) {
│ │ │ │ -
200 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ -
201 m[j][dim-1] = origin_normals[i][j];
│ │ │ │ -
202
│ │ │ │ -
203 const Coordinate rhs = origin[i] - target[0];
│ │ │ │ -
204
│ │ │ │ -
205 try {
│ │ │ │ -
206 /* y = (α, β, δ) */
│ │ │ │ -
207 auto& y = images[i];
│ │ │ │ -
208 m.solve(y, rhs);
│ │ │ │ -
209 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ -
210 y[j] /= scales[j];
│ │ │ │ -
211 /* Solving gave us -δ as the term is "-δ nᵢ". */
│ │ │ │ -
212 y[dim-1] *= Field(-1);
│ │ │ │ -
213
│ │ │ │ -
214 /* If the forward projection is too far in the wrong direction
│ │ │ │ -
215 * then this might result in artificial inverse projections or
│ │ │ │ -
216 * edge intersections. To prevent these wrong cases but not
│ │ │ │ -
217 * dismiss feasible intersections, the projection is dismissed
│ │ │ │ -
218 * if the forward projection is further than two times the
│ │ │ │ -
219 * approximate diameter of the image triangle.
│ │ │ │ -
220 */
│ │ │ │ -
221 if(y[dim-1] < -2*scaleSum) {
│ │ │ │ -
222 success.set(i,false);
│ │ │ │ -
223 m_projection_valid = false;
│ │ │ │ -
224 return;
│ │ │ │ -
225 }
│ │ │ │ -
226
│ │ │ │ -
227 const bool feasible = projectionFeasible(origin[i], origin_normals[i], y, target, target_normals);
│ │ │ │ -
228 success.set(i, feasible);
│ │ │ │ -
229 }
│ │ │ │ -
230 catch (const Dune::FMatrixError&) {
│ │ │ │ -
231 success.set(i, false);
│ │ │ │ -
232 m_projection_valid = false;
│ │ │ │ -
233 }
│ │ │ │ -
234 }
│ │ │ │ -
235}
│ │ │ │ -
236
│ │ │ │ -
237template<typename Coordinate>
│ │ │ │ -
238template<typename Corners, typename Normals>
│ │ │ │ -
239void
│ │ │ │ -
240Projection<Coordinate>
│ │ │ │ -
241::doInverseProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ -
242{
│ │ │ │ -
243 /* Try to obtain Φ⁻¹(yᵢ) for each corner yᵢ of the image triangle.
│ │ │ │ -
244 * Instead of solving the problem directly (which would lead to
│ │ │ │ -
245 * non-linear equations), we make use of the forward projection Φ
│ │ │ │ -
246 * which projects the preimage triangle on the plane spanned by the
│ │ │ │ -
247 * image triangle. The inverse projection is then given by finding
│ │ │ │ -
248 * the barycentric coordinates of yᵢ with respect to the triangle
│ │ │ │ -
249 * with the corners Φ(xᵢ). This way we only have to solve linear
│ │ │ │ -
250 * equations.
│ │ │ │ -
251 */
│ │ │ │ -
252
│ │ │ │ -
253 using namespace ProjectionImplementation;
│ │ │ │ -
254 using std::get;
│ │ │ │ -
255 typedef Dune::FieldMatrix<Field, dim-1, dim-1> Matrix;
│ │ │ │ -
256 typedef Dune::FieldVector<Field, dim-1> Vector;
│ │ │ │ -
257
│ │ │ │ -
258 /* The inverse projection can only be computed if the forward projection
│ │ │ │ -
259 * managed to project all xᵢ on the plane spanned by the yᵢ
│ │ │ │ -
260 */
│ │ │ │ -
261 if (!m_projection_valid) {
│ │ │ │ -
262 get<1>(m_success).reset();
│ │ │ │ -
263 return;
│ │ │ │ -
264 }
│ │ │ │ -
265
│ │ │ │ -
266 const auto& images = get<0>(m_images);
│ │ │ │ -
267 const auto& target_corners = get<1>(corners);
│ │ │ │ -
268 auto& preimages = get<1>(m_images);
│ │ │ │ -
269 auto& success = get<1>(m_success);
│ │ │ │ -
270
│ │ │ │ -
271 std::array<Coordinate, dim> v;
│ │ │ │ -
272 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ -
273 v[i] = interpolate(images[i+1], target_corners);
│ │ │ │ -
274 v[i] -= interpolate(images[0], target_corners);
│ │ │ │ -
275 }
│ │ │ │ -
276
│ │ │ │ -
277 Matrix m;
│ │ │ │ -
278 for (unsigned i = 0; i < dim-1; ++i) {
│ │ │ │ -
279 for (unsigned j = 0; j < dim-1; ++j) {
│ │ │ │ -
280 m[i][j] = v[i]*v[j];
│ │ │ │ -
281 }
│ │ │ │ -
282 }
│ │ │ │ -
283
│ │ │ │ -
284 for (unsigned i = 0; i < dim; ++i) {
│ │ │ │ -
285 /* Convert yᵢ to barycentric coordinates with respect to Φ(xⱼ) */
│ │ │ │ -
286 v[dim-1] = target_corners[i];
│ │ │ │ -
287 v[dim-1] -= interpolate(images[0], target_corners);
│ │ │ │ -
288
│ │ │ │ -
289 Vector rhs, z;
│ │ │ │ -
290 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ -
291 rhs[j] = v[dim-1]*v[j];
│ │ │ │ -
292 m.solve(z, rhs);
│ │ │ │ -
293
│ │ │ │ -
294 for (unsigned j = 0; j < dim-1; ++j)
│ │ │ │ -
295 preimages[i][j] = z[j];
│ │ │ │ -
296
│ │ │ │ -
297 /* Calculate distance along normal direction */
│ │ │ │ -
298 const auto x = interpolate(z, get<0>(corners));
│ │ │ │ -
299 preimages[i][dim-1] = (x - target_corners[i]) * get<1>(normals)[i];
│ │ │ │ -
300
│ │ │ │ -
301 /* Check y_i lies inside the Φ(xⱼ) */
│ │ │ │ -
302 const bool feasible = projectionFeasible(target_corners[i], get<1>(normals)[i], preimages[i], get<0>(corners), get<0>(normals));
│ │ │ │ -
303 success.set(i, feasible);
│ │ │ │ -
304 }
│ │ │ │ -
305}
│ │ │ │ -
306
│ │ │ │ -
307template<typename Coordinate>
│ │ │ │ -
308template<typename Corners, typename Normals>
│ │ │ │ -
309void
│ │ │ │ -
310Projection<Coordinate>
│ │ │ │ -
311::doEdgeIntersection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ -
312{
│ │ │ │ -
313 using namespace ProjectionImplementation;
│ │ │ │ -
314 using std::get;
│ │ │ │ -
315
│ │ │ │ -
316 m_number_of_edge_intersections = 0;
│ │ │ │ -
317
│ │ │ │ -
318 /* There are no edge intersections for 2d, only for 3d */
│ │ │ │ -
319 if (dim != 3)
│ │ │ │ -
320 return;
│ │ │ │ -
321
│ │ │ │ -
322 /* There are no edge intersections
│ │ │ │ -
323 * - when the projection is invalid,
│ │ │ │ -
324 * - when the projected triangle lies fully in the target triangle,
│ │ │ │ -
325 * - or when the target triangle lies fully in the projected triangle.
│ │ │ │ -
326 */
│ │ │ │ -
327 if (!m_projection_valid || get<0>(m_success).all() || get<1>(m_success).all()) {
│ │ │ │ -
328 return;
│ │ │ │ -
329 }
│ │ │ │ -
330
│ │ │ │ -
331 const auto& images = get<0>(m_images);
│ │ │ │ -
332 const auto& ys = get<1>(corners);
│ │ │ │ -
333
│ │ │ │ -
334 /* Intersect line through Φ(xᵢ), Φ(xⱼ) with line through yₖ, yₗ:
│ │ │ │ -
335 We want α, β ∈ ℝ such that
│ │ │ │ -
336 Φ(xᵢ) + α (Φ(xⱼ) - Φ(xᵢ)) = yₖ + β (yₗ - yₖ)
│ │ │ │ -
337 or
│ │ │ │ -
338 α (Φ(xⱼ)-Φ(xᵢ)) + β (yₗ-yₖ) = yₖ-Φ(xᵢ)
│ │ │ │ -
339 To get a 2×2 system of equations, multiply with yₘ-y₀ for
│ │ │ │ -
340 m ∈ {1,̣̣2} which are linear indep. (and so the system is
│ │ │ │ -
341 equivalent to the original 3×2 system)
│ │ │ │ -
342 */
│ │ │ │ -
343 for (unsigned edgex = 0; edgex < dim; ++edgex) {
│ │ │ │ -
344 unsigned i, j;
│ │ │ │ -
345 std::tie(i, j) = edgeToCorners(edgex);
│ │ │ │ -
346
│ │ │ │ -
347 /* Both sides of edgex lie in the target triangle means no edge intersection */
│ │ │ │ -
348 if (get<0>(m_success)[i] && get<0>(m_success)[j])
│ │ │ │ -
349 continue;
│ │ │ │ -
350
│ │ │ │ -
351 const auto pxi = interpolate(images[i], ys);
│ │ │ │ -
352 const auto pxj = interpolate(images[j], ys);
│ │ │ │ -
353 const auto pxjpxi = pxj - pxi;
│ │ │ │ -
354
│ │ │ │ -
355 typedef Dune::FieldMatrix<Field, dim-1, dim-1> Matrix;
│ │ │ │ -
356 typedef Dune::FieldVector<Field, dim-1> Vector;
│ │ │ │ -
357
│ │ │ │ -
358 for (unsigned edgey = 0; edgey < dim; ++edgey) {
│ │ │ │ -
359 unsigned k, l;
│ │ │ │ -
360 std::tie(k, l) = edgeToCorners(edgey);
│ │ │ │ -
361
│ │ │ │ -
362 /* Both sides of edgey lie in the projected triangle means no edge intersection */
│ │ │ │ -
363 if (get<1>(m_success)[k] && get<1>(m_success)[l])
│ │ │ │ -
364 continue;
│ │ │ │ -
365
│ │ │ │ -
366 const auto ykyl = ys[k] - ys[l];
│ │ │ │ -
367 const auto ykpxi = ys[k] - pxi;
│ │ │ │ -
368
│ │ │ │ -
369 /* If edges are parallel then the intersection is already computed by vertex projections. */
│ │ │ │ -
370 bool parallel = true;
│ │ │ │ -
371 for (unsigned h=0; h<3; h++)
│ │ │ │ -
372 parallel &= std::abs(ykyl[(h+1)%3]*pxjpxi[(h+2)%3] - ykyl[(h+2)%3]*pxjpxi[(h+1)%3])<1e-14;
│ │ │ │ -
373 if (parallel)
│ │ │ │ -
374 continue;
│ │ │ │ -
375
│ │ │ │ -
376 Matrix mat;
│ │ │ │ -
377 Vector rhs, z;
│ │ │ │ -
378
│ │ │ │ -
379 for (unsigned m = 0; m < dim-1; ++m) {
│ │ │ │ -
380 const auto ym1y0 = ys[m+1] - ys[0];
│ │ │ │ -
381 mat[m][0] = pxjpxi * ym1y0;
│ │ │ │ -
382 mat[m][1] = ykyl * ym1y0;
│ │ │ │ -
383 rhs[m] = ykpxi * ym1y0;
│ │ │ │ -
384 }
│ │ │ │ -
385
│ │ │ │ -
386 try {
│ │ │ │ -
387 using std::isfinite;
│ │ │ │ -
388
│ │ │ │ -
389 mat.solve(z, rhs);
│ │ │ │ -
390
│ │ │ │ -
391 /* If solving the system gives a NaN, the edges are probably parallel. */
│ │ │ │ -
392 if (!isfinite(z[0]) || !isfinite(z[1]))
│ │ │ │ -
393 continue;
│ │ │ │ -
394
│ │ │ │ -
395 /* Filter out corner (pre)images. We only want "real" edge-edge intersections here. */
│ │ │ │ -
396 if (z[0] < m_epsilon || z[0] > Field(1) - m_epsilon
│ │ │ │ -
397 || z[1] < m_epsilon || z[1] > Field(1) - m_epsilon)
│ │ │ │ -
398 continue;
│ │ │ │ -
399
│ │ │ │ -
400 Coordinate local_x = corner<Coordinate, Field>(i);
│ │ │ │ -
401 local_x.axpy(z[0], corner<Coordinate, Field>(j) - corner<Coordinate, Field>(i));
│ │ │ │ -
402 Coordinate local_y = corner<Coordinate, Field>(k);
│ │ │ │ -
403 local_y.axpy(z[1], corner<Coordinate, Field>(l) - corner<Coordinate, Field>(k));
│ │ │ │ -
404
│ │ │ │ -
405 /* Make sure the intersection is in the triangle. */
│ │ │ │ -
406 if (!inside(local_x, m_epsilon) || !inside(local_y, m_epsilon))
│ │ │ │ -
407 continue;
│ │ │ │ -
408
│ │ │ │ -
409 /* Make sure the intersection respects overlap. */
│ │ │ │ -
410 auto xy = interpolate(local_x, get<0>(corners));
│ │ │ │ -
411 xy -= interpolate(local_y, get<1>(corners));
│ │ │ │ -
412 const auto nx = interpolate_unit_normals(local_x, get<0>(normals));
│ │ │ │ -
413 const auto ny = interpolate_unit_normals(local_y, get<1>(normals));
│ │ │ │ -
414 local_x[dim-1] = -(xy*nx);
│ │ │ │ -
415 local_y[dim-1] = xy*ny;
│ │ │ │ -
416
│ │ │ │ -
417 if (local_x[dim-1] < -m_overlap-m_epsilon || local_y[dim-1] < -m_overlap-m_epsilon)
│ │ │ │ -
418 continue;
│ │ │ │ -
419
│ │ │ │ -
420 /* Normals should be opposing. */
│ │ │ │ -
421 if (nx*ny > m_max_normal_product + m_epsilon)
│ │ │ │ -
422 continue;
│ │ │ │ -
423
│ │ │ │ -
424 /* Intersection is feasible. Store it. */
│ │ │ │ -
425 auto& intersection = m_edge_intersections[m_number_of_edge_intersections++];
│ │ │ │ -
426 intersection = { {{edgex, edgey}}, {{local_x, local_y}} };
│ │ │ │ -
427 }
│ │ │ │ -
428 catch(const Dune::FMatrixError&) {
│ │ │ │ -
429 /* Edges might be parallel, ignore and continue with next edge */
│ │ │ │ -
430 }
│ │ │ │ -
431 }
│ │ │ │ -
432 }
│ │ │ │ -
433}
│ │ │ │ -
434
│ │ │ │ -
435template<typename Coordinate>
│ │ │ │ -
436template<typename Corners, typename Normals>
│ │ │ │ -
437bool Projection<Coordinate>
│ │ │ │ -
438::projectionFeasible(const Coordinate& x, const Coordinate& nx, const Coordinate& px, const Corners& corners, const Normals& normals) const
│ │ │ │ -
439{
│ │ │ │ -
440 using namespace ProjectionImplementation;
│ │ │ │ -
441
│ │ │ │ -
442 /* Image must be within simplex. */
│ │ │ │ -
443 if (!inside(px, m_epsilon))
│ │ │ │ -
444 return false;
│ │ │ │ -
445
│ │ │ │ -
446 /* Distance along normal must not be smaller than -overlap. */
│ │ │ │ -
447 if (px[dim-1] < -m_overlap-m_epsilon)
│ │ │ │ -
448 return false;
│ │ │ │ -
449
│ │ │ │ -
450 /* Distance along normal at image must not be smaller than -overlap. */
│ │ │ │ -
451 auto xmy = x;
│ │ │ │ -
452 xmy -= interpolate(px, corners);
│ │ │ │ -
453 const auto n = interpolate_unit_normals(px, normals);
│ │ │ │ -
454 const auto d = xmy * n;
│ │ │ │ -
455 if (d < -m_overlap-m_epsilon)
│ │ │ │ -
456 return false;
│ │ │ │ -
457
│ │ │ │ -
458 /* Normals at x and Φ(x) are opposing. */
│ │ │ │ -
459 if (nx * n > m_max_normal_product + m_epsilon)
│ │ │ │ -
460 return false;
│ │ │ │ -
461
│ │ │ │ -
462 /* Okay, projection is feasible. */
│ │ │ │ -
463 return true;
│ │ │ │ -
464}
│ │ │ │ -
465
│ │ │ │ -
466template<typename Coordinate>
│ │ │ │ -
467template<typename Corners, typename Normals>
│ │ │ │ - │ │ │ │ -
469::project(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals)
│ │ │ │ -
470{
│ │ │ │ -
471 doProjection(corners, normals);
│ │ │ │ -
472 doInverseProjection(corners, normals);
│ │ │ │ -
473 doEdgeIntersection(corners, normals);
│ │ │ │ -
474}
│ │ │ │ -
475
│ │ │ │ -
476} /* namespace GridGlue */
│ │ │ │ -
477} /* namespace Dune */
│ │ │ │ +
12template<int side, typename Glue>
│ │ │ │ +
13void write_glue_area_vtk(const Glue& glue, std::ostream& out);
│ │ │ │ +
14
│ │ │ │ +
15template<int side, typename Glue>
│ │ │ │ +
16void write_glue_area_vtk(const Glue& glue, const std::string& filename);
│ │ │ │ +
17
│ │ │ │ +
37template<typename Glue>
│ │ │ │ +
38void write_glue_areas_vtk(const Glue& glue, const std::string& base);
│ │ │ │ +
39
│ │ │ │ +
40} /* namespace GridGlue */
│ │ │ │ +
41} /* namespace Dune */
│ │ │ │ +
42
│ │ │ │ +
43#include "areawriter_impl.hh"
│ │ │ │ +
44
│ │ │ │ +
45#endif
│ │ │ │ + │ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
Corners::value_type interpolate(const Coordinate &x, const Corners &corners)
Definition: projection_impl.hh:70
│ │ │ │ -
bool inside(const Coordinate &x, const Field &epsilon)
Definition: projection_impl.hh:111
│ │ │ │ -
std::pair< unsigned, unsigned > edgeToCorners(unsigned edge)
Definition: projection_impl.hh:43
│ │ │ │ -
Coordinate corner(unsigned c)
Definition: projection_impl.hh:24
│ │ │ │ -
Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals &normals)
Definition: projection_impl.hh:91
│ │ │ │ -
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:21
│ │ │ │ -
Coordinate::field_type Field
Scalar type.
Definition: projection.hh:61
│ │ │ │ -
Projection(const Field overlap=Field(0), const Field max_normal_product=Field(-0.1))
Definition: projection_impl.hh:130
│ │ │ │ -
void epsilon(const Field epsilon)
Set epsilon used for floating-point comparisons.
Definition: projection_impl.hh:140
│ │ │ │ -
void project(const std::tuple< Corners &, Corners & > &corners, const std::tuple< Normals &, Normals & > &normals)
Do the actual projection.
Definition: projection_impl.hh:469
│ │ │ │ +
void write_glue_area_vtk(const Glue &glue, std::ostream &out)
Definition: areawriter_impl.hh:84
│ │ │ │ +
void write_glue_areas_vtk(const Glue &glue, const std::string &base)
Definition: areawriter_impl.hh:129
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,494 +5,49 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projection_impl.hh │ │ │ │ │ +areawriter.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#include │ │ │ │ │ - 4 │ │ │ │ │ - 5#include │ │ │ │ │ - 6 │ │ │ │ │ - 7namespace Dune { │ │ │ │ │ - 8namespace GridGlue { │ │ │ │ │ - 9 │ │ │ │ │ -10namespace ProjectionImplementation { │ │ │ │ │ + 3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ + 4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ + 5 │ │ │ │ │ + 6#include │ │ │ │ │ + 7#include │ │ │ │ │ + 8 │ │ │ │ │ + 9namespace Dune { │ │ │ │ │ + 10namespace GridGlue { │ │ │ │ │ 11 │ │ │ │ │ - 22template │ │ │ │ │ - 23inline Coordinate │ │ │ │ │ -24corner(unsigned c) │ │ │ │ │ - 25{ │ │ │ │ │ - 26 Coordinate x(Field(0)); │ │ │ │ │ - 27 if (c == 0) │ │ │ │ │ - 28 return x; │ │ │ │ │ - 29 x[c-1] = Field(1); │ │ │ │ │ - 30 return x; │ │ │ │ │ - 31} │ │ │ │ │ - 32 │ │ │ │ │ - 42inline std::pair │ │ │ │ │ -43edgeToCorners(unsigned edge) │ │ │ │ │ - 44{ │ │ │ │ │ - 45 switch(edge) { │ │ │ │ │ - 46 case 0: return {0, 1}; │ │ │ │ │ - 47 case 1: return {0, 2}; │ │ │ │ │ - 48 case 2: return {1, 2}; │ │ │ │ │ - 49 } │ │ │ │ │ - 50 DUNE_THROW(Dune::Exception, "Unexpected edge number."); │ │ │ │ │ - 51} │ │ │ │ │ - 52 │ │ │ │ │ - 68template │ │ │ │ │ - 69inline typename Corners::value_type │ │ │ │ │ -70interpolate(const Coordinate& x, const Corners& corners) │ │ │ │ │ - 71{ │ │ │ │ │ - 72 auto y = corners[0]; │ │ │ │ │ - 73 for (unsigned i = 0; i < corners.size() - 1; ++i) │ │ │ │ │ - 74 y.axpy(x[i], corners[i+1] - corners[0]); │ │ │ │ │ - 75 return y; │ │ │ │ │ - 76} │ │ │ │ │ - 77 │ │ │ │ │ - 89template │ │ │ │ │ - 90inline typename Normals::value_type │ │ │ │ │ -91interpolate_unit_normals(const Coordinate& x, const Normals& normals) │ │ │ │ │ - 92{ │ │ │ │ │ - 93 auto n = interpolate(x, normals); │ │ │ │ │ - 94 n /= n.two_norm(); │ │ │ │ │ - 95 return n; │ │ │ │ │ - 96} │ │ │ │ │ - 97 │ │ │ │ │ - 109template │ │ │ │ │ - 110inline bool │ │ │ │ │ -111inside(const Coordinate& x, const Field& epsilon) │ │ │ │ │ - 112{ │ │ │ │ │ - 113 const unsigned dim = Coordinate::dimension; │ │ │ │ │ - 114 Field sum(0); │ │ │ │ │ - 115 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ - 116 if (x[i] < -epsilon) │ │ │ │ │ - 117 return false; │ │ │ │ │ - 118 sum += x[i]; │ │ │ │ │ - 119 } │ │ │ │ │ - 120 /* If any xᵢ is NaN, sum will be NaN and this comparison false! */ │ │ │ │ │ - 121 if (sum <= Field(1) + epsilon) │ │ │ │ │ - 122 return true; │ │ │ │ │ - 123 return false; │ │ │ │ │ - 124} │ │ │ │ │ - 125 │ │ │ │ │ - 126} /* namespace ProjectionImplementation */ │ │ │ │ │ - 127 │ │ │ │ │ - 128template │ │ │ │ │ - 129Projection │ │ │ │ │ -130::Projection(const Field overlap, const Field max_normal_product) │ │ │ │ │ - 131 : m_overlap(overlap) │ │ │ │ │ - 132 , m_max_normal_product(max_normal_product) │ │ │ │ │ - 133{ │ │ │ │ │ - 134 /* Nothing. */ │ │ │ │ │ - 135} │ │ │ │ │ - 136 │ │ │ │ │ - 137template │ │ │ │ │ - 138void │ │ │ │ │ - 139Projection │ │ │ │ │ -140::epsilon(const Field epsilon) │ │ │ │ │ - 141{ │ │ │ │ │ - 142 m_epsilon = epsilon; │ │ │ │ │ - 143} │ │ │ │ │ - 144 │ │ │ │ │ - 145template │ │ │ │ │ - 146template │ │ │ │ │ - 147void │ │ │ │ │ - 148Projection │ │ │ │ │ - 149::doProjection(const std::tuple& corners, const std:: │ │ │ │ │ -tuple& normals) │ │ │ │ │ - 150{ │ │ │ │ │ - 151 /* Try to obtain Φ(xᵢ) for each corner xᵢ of the preimage triangle. │ │ │ │ │ - 152 * This means solving a linear system of equations │ │ │ │ │ - 153 * Φ(xᵢ) = (1-α-β) y₀ + α y₁ + β y₂ = xᵢ + δ nᵢ │ │ │ │ │ - 154 * or α (y₁ - y₀) + β (y₂ - y₀) - δ nᵢ = xᵢ - y₀ │ │ │ │ │ - 155 * to obtain the barycentric coordinates (α, β) of Φ(xᵢ) in the image │ │ │ │ │ - 156 * triangle and the distance δ. │ │ │ │ │ - 157 * │ │ │ │ │ - 158 * In the matrix m corresponding to the system, only the third column and │ │ │ │ │ -the │ │ │ │ │ - 159 * right-hand side depend on i. The first two columns can be assembled │ │ │ │ │ -before │ │ │ │ │ - 160 * and reused. │ │ │ │ │ - 161 */ │ │ │ │ │ - 162 using namespace ProjectionImplementation; │ │ │ │ │ - 163 using std::get; │ │ │ │ │ - 164 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ - 165 Matrix m; │ │ │ │ │ - 166 │ │ │ │ │ - 167 const auto& origin = get<0>(corners); │ │ │ │ │ - 168 const auto& origin_normals = get<0>(normals); │ │ │ │ │ - 169 const auto& target = get<1>(corners); │ │ │ │ │ - 170 const auto& target_normals = get<1>(normals); │ │ │ │ │ - 171 auto& images = get<0>(m_images); │ │ │ │ │ - 172 auto& success = get<0>(m_success); │ │ │ │ │ - 173 │ │ │ │ │ - 174 /* directionsᵢ = (yᵢ - y₀) / ||yᵢ - y₀|| │ │ │ │ │ - 175 * These are the first to columns of the system matrix; the rescaling is │ │ │ │ │ -done │ │ │ │ │ - 176 * to ensure all columns have a comparable norm (the last has the normal │ │ │ │ │ -with norm 1. │ │ │ │ │ - 177 */ │ │ │ │ │ - 178 std::array directions; │ │ │ │ │ - 179 std::array scales; │ │ │ │ │ - 180 /* estimator for the diameter of the target face */ │ │ │ │ │ - 181 Field scaleSum(0); │ │ │ │ │ - 182 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ - 183 directions[i] = target[i+1] - target[0]; │ │ │ │ │ - 184 scales[i] = directions[i].infinity_norm(); │ │ │ │ │ - 185 directions[i] /= scales[i]; │ │ │ │ │ - 186 scaleSum += scales[i]; │ │ │ │ │ - 187 } │ │ │ │ │ - 188 │ │ │ │ │ - 189 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ - 190 for (unsigned j = 0; j < dim; ++j) { │ │ │ │ │ - 191 m[j][i] = directions[i][j]; │ │ │ │ │ - 192 } │ │ │ │ │ - 193 } │ │ │ │ │ - 194 │ │ │ │ │ - 195 m_projection_valid = true; │ │ │ │ │ - 196 success.reset(); │ │ │ │ │ - 197 │ │ │ │ │ - 198 /* Now project xᵢ for each i */ │ │ │ │ │ - 199 for (unsigned i = 0; i < origin.size(); ++i) { │ │ │ │ │ - 200 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ - 201 m[j][dim-1] = origin_normals[i][j]; │ │ │ │ │ - 202 │ │ │ │ │ - 203 const Coordinate rhs = origin[i] - target[0]; │ │ │ │ │ - 204 │ │ │ │ │ - 205 try { │ │ │ │ │ - 206 /* y = (α, β, δ) */ │ │ │ │ │ - 207 auto& y = images[i]; │ │ │ │ │ - 208 m.solve(y, rhs); │ │ │ │ │ - 209 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ - 210 y[j] /= scales[j]; │ │ │ │ │ - 211 /* Solving gave us -δ as the term is "-δ nᵢ". */ │ │ │ │ │ - 212 y[dim-1] *= Field(-1); │ │ │ │ │ - 213 │ │ │ │ │ - 214 /* If the forward projection is too far in the wrong direction │ │ │ │ │ - 215 * then this might result in artificial inverse projections or │ │ │ │ │ - 216 * edge intersections. To prevent these wrong cases but not │ │ │ │ │ - 217 * dismiss feasible intersections, the projection is dismissed │ │ │ │ │ - 218 * if the forward projection is further than two times the │ │ │ │ │ - 219 * approximate diameter of the image triangle. │ │ │ │ │ - 220 */ │ │ │ │ │ - 221 if(y[dim-1] < -2*scaleSum) { │ │ │ │ │ - 222 success.set(i,false); │ │ │ │ │ - 223 m_projection_valid = false; │ │ │ │ │ - 224 return; │ │ │ │ │ - 225 } │ │ │ │ │ - 226 │ │ │ │ │ - 227 const bool feasible = projectionFeasible(origin[i], origin_normals[i], y, │ │ │ │ │ -target, target_normals); │ │ │ │ │ - 228 success.set(i, feasible); │ │ │ │ │ - 229 } │ │ │ │ │ - 230 catch (const Dune::FMatrixError&) { │ │ │ │ │ - 231 success.set(i, false); │ │ │ │ │ - 232 m_projection_valid = false; │ │ │ │ │ - 233 } │ │ │ │ │ - 234 } │ │ │ │ │ - 235} │ │ │ │ │ - 236 │ │ │ │ │ - 237template │ │ │ │ │ - 238template │ │ │ │ │ - 239void │ │ │ │ │ - 240Projection │ │ │ │ │ - 241::doInverseProjection(const std::tuple& corners, const │ │ │ │ │ -std::tuple& normals) │ │ │ │ │ - 242{ │ │ │ │ │ - 243 /* Try to obtain Φ⁻¹(yᵢ) for each corner yᵢ of the image triangle. │ │ │ │ │ - 244 * Instead of solving the problem directly (which would lead to │ │ │ │ │ - 245 * non-linear equations), we make use of the forward projection Φ │ │ │ │ │ - 246 * which projects the preimage triangle on the plane spanned by the │ │ │ │ │ - 247 * image triangle. The inverse projection is then given by finding │ │ │ │ │ - 248 * the barycentric coordinates of yᵢ with respect to the triangle │ │ │ │ │ - 249 * with the corners Φ(xᵢ). This way we only have to solve linear │ │ │ │ │ - 250 * equations. │ │ │ │ │ - 251 */ │ │ │ │ │ - 252 │ │ │ │ │ - 253 using namespace ProjectionImplementation; │ │ │ │ │ - 254 using std::get; │ │ │ │ │ - 255 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ - 256 typedef Dune::FieldVector Vector; │ │ │ │ │ - 257 │ │ │ │ │ - 258 /* The inverse projection can only be computed if the forward projection │ │ │ │ │ - 259 * managed to project all xᵢ on the plane spanned by the yᵢ │ │ │ │ │ - 260 */ │ │ │ │ │ - 261 if (!m_projection_valid) { │ │ │ │ │ - 262 get<1>(m_success).reset(); │ │ │ │ │ - 263 return; │ │ │ │ │ - 264 } │ │ │ │ │ - 265 │ │ │ │ │ - 266 const auto& images = get<0>(m_images); │ │ │ │ │ - 267 const auto& target_corners = get<1>(corners); │ │ │ │ │ - 268 auto& preimages = get<1>(m_images); │ │ │ │ │ - 269 auto& success = get<1>(m_success); │ │ │ │ │ - 270 │ │ │ │ │ - 271 std::array v; │ │ │ │ │ - 272 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ - 273 v[i] = interpolate(images[i+1], target_corners); │ │ │ │ │ - 274 v[i] -= interpolate(images[0], target_corners); │ │ │ │ │ - 275 } │ │ │ │ │ - 276 │ │ │ │ │ - 277 Matrix m; │ │ │ │ │ - 278 for (unsigned i = 0; i < dim-1; ++i) { │ │ │ │ │ - 279 for (unsigned j = 0; j < dim-1; ++j) { │ │ │ │ │ - 280 m[i][j] = v[i]*v[j]; │ │ │ │ │ - 281 } │ │ │ │ │ - 282 } │ │ │ │ │ - 283 │ │ │ │ │ - 284 for (unsigned i = 0; i < dim; ++i) { │ │ │ │ │ - 285 /* Convert yᵢ to barycentric coordinates with respect to Φ(xⱼ) */ │ │ │ │ │ - 286 v[dim-1] = target_corners[i]; │ │ │ │ │ - 287 v[dim-1] -= interpolate(images[0], target_corners); │ │ │ │ │ - 288 │ │ │ │ │ - 289 Vector rhs, z; │ │ │ │ │ - 290 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ - 291 rhs[j] = v[dim-1]*v[j]; │ │ │ │ │ - 292 m.solve(z, rhs); │ │ │ │ │ - 293 │ │ │ │ │ - 294 for (unsigned j = 0; j < dim-1; ++j) │ │ │ │ │ - 295 preimages[i][j] = z[j]; │ │ │ │ │ - 296 │ │ │ │ │ - 297 /* Calculate distance along normal direction */ │ │ │ │ │ - 298 const auto x = interpolate(z, get<0>(corners)); │ │ │ │ │ - 299 preimages[i][dim-1] = (x - target_corners[i]) * get<1>(normals)[i]; │ │ │ │ │ - 300 │ │ │ │ │ - 301 /* Check y_i lies inside the Φ(xⱼ) */ │ │ │ │ │ - 302 const bool feasible = projectionFeasible(target_corners[i], get<1> │ │ │ │ │ -(normals)[i], preimages[i], get<0>(corners), get<0>(normals)); │ │ │ │ │ - 303 success.set(i, feasible); │ │ │ │ │ - 304 } │ │ │ │ │ - 305} │ │ │ │ │ - 306 │ │ │ │ │ - 307template │ │ │ │ │ - 308template │ │ │ │ │ - 309void │ │ │ │ │ - 310Projection │ │ │ │ │ - 311::doEdgeIntersection(const std::tuple& corners, const │ │ │ │ │ -std::tuple& normals) │ │ │ │ │ - 312{ │ │ │ │ │ - 313 using namespace ProjectionImplementation; │ │ │ │ │ - 314 using std::get; │ │ │ │ │ - 315 │ │ │ │ │ - 316 m_number_of_edge_intersections = 0; │ │ │ │ │ - 317 │ │ │ │ │ - 318 /* There are no edge intersections for 2d, only for 3d */ │ │ │ │ │ - 319 if (dim != 3) │ │ │ │ │ - 320 return; │ │ │ │ │ - 321 │ │ │ │ │ - 322 /* There are no edge intersections │ │ │ │ │ - 323 * - when the projection is invalid, │ │ │ │ │ - 324 * - when the projected triangle lies fully in the target triangle, │ │ │ │ │ - 325 * - or when the target triangle lies fully in the projected triangle. │ │ │ │ │ - 326 */ │ │ │ │ │ - 327 if (!m_projection_valid || get<0>(m_success).all() || get<1> │ │ │ │ │ -(m_success).all()) { │ │ │ │ │ - 328 return; │ │ │ │ │ - 329 } │ │ │ │ │ - 330 │ │ │ │ │ - 331 const auto& images = get<0>(m_images); │ │ │ │ │ - 332 const auto& ys = get<1>(corners); │ │ │ │ │ - 333 │ │ │ │ │ - 334 /* Intersect line through Φ(xᵢ), Φ(xⱼ) with line through yₖ, yₗ: │ │ │ │ │ - 335 We want α, β ∈ ℝ such that │ │ │ │ │ - 336 Φ(xᵢ) + α (Φ(xⱼ) - Φ(xᵢ)) = yₖ + β (yₗ - yₖ) │ │ │ │ │ - 337 or │ │ │ │ │ - 338 α (Φ(xⱼ)-Φ(xᵢ)) + β (yₗ-yₖ) = yₖ-Φ(xᵢ) │ │ │ │ │ - 339 To get a 2×2 system of equations, multiply with yₘ-y₀ for │ │ │ │ │ - 340 m ∈ {1,̣̣2} which are linear indep. (and so the system is │ │ │ │ │ - 341 equivalent to the original 3×2 system) │ │ │ │ │ - 342 */ │ │ │ │ │ - 343 for (unsigned edgex = 0; edgex < dim; ++edgex) { │ │ │ │ │ - 344 unsigned i, j; │ │ │ │ │ - 345 std::tie(i, j) = edgeToCorners(edgex); │ │ │ │ │ - 346 │ │ │ │ │ - 347 /* Both sides of edgex lie in the target triangle means no edge │ │ │ │ │ -intersection */ │ │ │ │ │ - 348 if (get<0>(m_success)[i] && get<0>(m_success)[j]) │ │ │ │ │ - 349 continue; │ │ │ │ │ - 350 │ │ │ │ │ - 351 const auto pxi = interpolate(images[i], ys); │ │ │ │ │ - 352 const auto pxj = interpolate(images[j], ys); │ │ │ │ │ - 353 const auto pxjpxi = pxj - pxi; │ │ │ │ │ - 354 │ │ │ │ │ - 355 typedef Dune::FieldMatrix Matrix; │ │ │ │ │ - 356 typedef Dune::FieldVector Vector; │ │ │ │ │ - 357 │ │ │ │ │ - 358 for (unsigned edgey = 0; edgey < dim; ++edgey) { │ │ │ │ │ - 359 unsigned k, l; │ │ │ │ │ - 360 std::tie(k, l) = edgeToCorners(edgey); │ │ │ │ │ - 361 │ │ │ │ │ - 362 /* Both sides of edgey lie in the projected triangle means no edge │ │ │ │ │ -intersection */ │ │ │ │ │ - 363 if (get<1>(m_success)[k] && get<1>(m_success)[l]) │ │ │ │ │ - 364 continue; │ │ │ │ │ - 365 │ │ │ │ │ - 366 const auto ykyl = ys[k] - ys[l]; │ │ │ │ │ - 367 const auto ykpxi = ys[k] - pxi; │ │ │ │ │ - 368 │ │ │ │ │ - 369 /* If edges are parallel then the intersection is already computed by │ │ │ │ │ -vertex projections. */ │ │ │ │ │ - 370 bool parallel = true; │ │ │ │ │ - 371 for (unsigned h=0; h<3; h++) │ │ │ │ │ - 372 parallel &= std::abs(ykyl[(h+1)%3]*pxjpxi[(h+2)%3] - ykyl[(h+2)%3]*pxjpxi[ │ │ │ │ │ -(h+1)%3])<1e-14; │ │ │ │ │ - 373 if (parallel) │ │ │ │ │ - 374 continue; │ │ │ │ │ - 375 │ │ │ │ │ - 376 Matrix mat; │ │ │ │ │ - 377 Vector rhs, z; │ │ │ │ │ - 378 │ │ │ │ │ - 379 for (unsigned m = 0; m < dim-1; ++m) { │ │ │ │ │ - 380 const auto ym1y0 = ys[m+1] - ys[0]; │ │ │ │ │ - 381 mat[m][0] = pxjpxi * ym1y0; │ │ │ │ │ - 382 mat[m][1] = ykyl * ym1y0; │ │ │ │ │ - 383 rhs[m] = ykpxi * ym1y0; │ │ │ │ │ - 384 } │ │ │ │ │ - 385 │ │ │ │ │ - 386 try { │ │ │ │ │ - 387 using std::isfinite; │ │ │ │ │ - 388 │ │ │ │ │ - 389 mat.solve(z, rhs); │ │ │ │ │ - 390 │ │ │ │ │ - 391 /* If solving the system gives a NaN, the edges are probably parallel. */ │ │ │ │ │ - 392 if (!isfinite(z[0]) || !isfinite(z[1])) │ │ │ │ │ - 393 continue; │ │ │ │ │ - 394 │ │ │ │ │ - 395 /* Filter out corner (pre)images. We only want "real" edge-edge │ │ │ │ │ -intersections here. */ │ │ │ │ │ - 396 if (z[0] < m_epsilon || z[0] > Field(1) - m_epsilon │ │ │ │ │ - 397 || z[1] < m_epsilon || z[1] > Field(1) - m_epsilon) │ │ │ │ │ - 398 continue; │ │ │ │ │ - 399 │ │ │ │ │ - 400 Coordinate local_x = corner(i); │ │ │ │ │ - 401 local_x.axpy(z[0], corner(j) - corner(i)); │ │ │ │ │ - 402 Coordinate local_y = corner(k); │ │ │ │ │ - 403 local_y.axpy(z[1], corner(l) - corner(k)); │ │ │ │ │ - 404 │ │ │ │ │ - 405 /* Make sure the intersection is in the triangle. */ │ │ │ │ │ - 406 if (!inside(local_x, m_epsilon) || !inside(local_y, m_epsilon)) │ │ │ │ │ - 407 continue; │ │ │ │ │ - 408 │ │ │ │ │ - 409 /* Make sure the intersection respects overlap. */ │ │ │ │ │ - 410 auto xy = interpolate(local_x, get<0>(corners)); │ │ │ │ │ - 411 xy -= interpolate(local_y, get<1>(corners)); │ │ │ │ │ - 412 const auto nx = interpolate_unit_normals(local_x, get<0>(normals)); │ │ │ │ │ - 413 const auto ny = interpolate_unit_normals(local_y, get<1>(normals)); │ │ │ │ │ - 414 local_x[dim-1] = -(xy*nx); │ │ │ │ │ - 415 local_y[dim-1] = xy*ny; │ │ │ │ │ - 416 │ │ │ │ │ - 417 if (local_x[dim-1] < -m_overlap-m_epsilon || local_y[dim-1] < -m_overlap- │ │ │ │ │ -m_epsilon) │ │ │ │ │ - 418 continue; │ │ │ │ │ - 419 │ │ │ │ │ - 420 /* Normals should be opposing. */ │ │ │ │ │ - 421 if (nx*ny > m_max_normal_product + m_epsilon) │ │ │ │ │ - 422 continue; │ │ │ │ │ - 423 │ │ │ │ │ - 424 /* Intersection is feasible. Store it. */ │ │ │ │ │ - 425 auto& intersection = m_edge_intersections │ │ │ │ │ -[m_number_of_edge_intersections++]; │ │ │ │ │ - 426 intersection = { {{edgex, edgey}}, {{local_x, local_y}} }; │ │ │ │ │ - 427 } │ │ │ │ │ - 428 catch(const Dune::FMatrixError&) { │ │ │ │ │ - 429 /* Edges might be parallel, ignore and continue with next edge */ │ │ │ │ │ - 430 } │ │ │ │ │ - 431 } │ │ │ │ │ - 432 } │ │ │ │ │ - 433} │ │ │ │ │ - 434 │ │ │ │ │ - 435template │ │ │ │ │ - 436template │ │ │ │ │ - 437bool Projection │ │ │ │ │ - 438::projectionFeasible(const Coordinate& x, const Coordinate& nx, const │ │ │ │ │ -Coordinate& px, const Corners& corners, const Normals& normals) const │ │ │ │ │ - 439{ │ │ │ │ │ - 440 using namespace ProjectionImplementation; │ │ │ │ │ - 441 │ │ │ │ │ - 442 /* Image must be within simplex. */ │ │ │ │ │ - 443 if (!inside(px, m_epsilon)) │ │ │ │ │ - 444 return false; │ │ │ │ │ - 445 │ │ │ │ │ - 446 /* Distance along normal must not be smaller than -overlap. */ │ │ │ │ │ - 447 if (px[dim-1] < -m_overlap-m_epsilon) │ │ │ │ │ - 448 return false; │ │ │ │ │ - 449 │ │ │ │ │ - 450 /* Distance along normal at image must not be smaller than -overlap. */ │ │ │ │ │ - 451 auto xmy = x; │ │ │ │ │ - 452 xmy -= interpolate(px, corners); │ │ │ │ │ - 453 const auto n = interpolate_unit_normals(px, normals); │ │ │ │ │ - 454 const auto d = xmy * n; │ │ │ │ │ - 455 if (d < -m_overlap-m_epsilon) │ │ │ │ │ - 456 return false; │ │ │ │ │ - 457 │ │ │ │ │ - 458 /* Normals at x and Φ(x) are opposing. */ │ │ │ │ │ - 459 if (nx * n > m_max_normal_product + m_epsilon) │ │ │ │ │ - 460 return false; │ │ │ │ │ - 461 │ │ │ │ │ - 462 /* Okay, projection is feasible. */ │ │ │ │ │ - 463 return true; │ │ │ │ │ - 464} │ │ │ │ │ - 465 │ │ │ │ │ - 466template │ │ │ │ │ - 467template │ │ │ │ │ - 468void Projection │ │ │ │ │ -469::project(const std::tuple& corners, const std:: │ │ │ │ │ -tuple& normals) │ │ │ │ │ - 470{ │ │ │ │ │ - 471 doProjection(corners, normals); │ │ │ │ │ - 472 doInverseProjection(corners, normals); │ │ │ │ │ - 473 doEdgeIntersection(corners, normals); │ │ │ │ │ - 474} │ │ │ │ │ - 475 │ │ │ │ │ - 476} /* namespace GridGlue */ │ │ │ │ │ - 477} /* namespace Dune */ │ │ │ │ │ + 12template │ │ │ │ │ + 13void write_glue_area_vtk(const Glue& glue, std::ostream& out); │ │ │ │ │ + 14 │ │ │ │ │ + 15template │ │ │ │ │ + 16void write_glue_area_vtk(const Glue& glue, const std::string& filename); │ │ │ │ │ + 17 │ │ │ │ │ + 37template │ │ │ │ │ + 38void write_glue_areas_vtk(const Glue& glue, const std::string& base); │ │ │ │ │ + 39 │ │ │ │ │ + 40} /* namespace GridGlue */ │ │ │ │ │ + 41} /* namespace Dune */ │ │ │ │ │ + 42 │ │ │ │ │ + 43#include "areawriter_impl.hh" │ │ │ │ │ + 44 │ │ │ │ │ + 45#endif │ │ │ │ │ +areawriter_impl.hh │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::interpolate │ │ │ │ │ -Corners::value_type interpolate(const Coordinate &x, const Corners &corners) │ │ │ │ │ -Definition: projection_impl.hh:70 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::inside │ │ │ │ │ -bool inside(const Coordinate &x, const Field &epsilon) │ │ │ │ │ -Definition: projection_impl.hh:111 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::edgeToCorners │ │ │ │ │ -std::pair< unsigned, unsigned > edgeToCorners(unsigned edge) │ │ │ │ │ -Definition: projection_impl.hh:43 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::corner │ │ │ │ │ -Coordinate corner(unsigned c) │ │ │ │ │ -Definition: projection_impl.hh:24 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals │ │ │ │ │ -Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals │ │ │ │ │ -&normals) │ │ │ │ │ -Definition: projection_impl.hh:91 │ │ │ │ │ -Dune::GridGlue::Projection │ │ │ │ │ -Projection of a line (triangle) on another line (triangle). │ │ │ │ │ -Definition: projection.hh:21 │ │ │ │ │ -Dune::GridGlue::Projection::Field │ │ │ │ │ -Coordinate::field_type Field │ │ │ │ │ -Scalar type. │ │ │ │ │ -Definition: projection.hh:61 │ │ │ │ │ -Dune::GridGlue::Projection::Projection │ │ │ │ │ -Projection(const Field overlap=Field(0), const Field max_normal_product=Field(- │ │ │ │ │ -0.1)) │ │ │ │ │ -Definition: projection_impl.hh:130 │ │ │ │ │ -Dune::GridGlue::Projection::epsilon │ │ │ │ │ -void epsilon(const Field epsilon) │ │ │ │ │ -Set epsilon used for floating-point comparisons. │ │ │ │ │ -Definition: projection_impl.hh:140 │ │ │ │ │ -Dune::GridGlue::Projection::project │ │ │ │ │ -void project(const std::tuple< Corners &, Corners & > &corners, const std:: │ │ │ │ │ -tuple< Normals &, Normals & > &normals) │ │ │ │ │ -Do the actual projection. │ │ │ │ │ -Definition: projection_impl.hh:469 │ │ │ │ │ +Dune::GridGlue::write_glue_area_vtk │ │ │ │ │ +void write_glue_area_vtk(const Glue &glue, std::ostream &out) │ │ │ │ │ +Definition: areawriter_impl.hh:84 │ │ │ │ │ +Dune::GridGlue::write_glue_areas_vtk │ │ │ │ │ +void write_glue_areas_vtk(const Glue &glue, const std::string &base) │ │ │ │ │ +Definition: areawriter_impl.hh:129 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projectionwriter.hh File Reference │ │ │ │ +dune-grid-glue: projectionwriter_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,33 +65,47 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
projectionwriter.hh File Reference
│ │ │ │ +
projectionwriter_impl.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <string>
│ │ │ │ -#include <dune/grid-glue/common/projection.hh>
│ │ │ │ -#include "projectionwriter_impl.hh"
│ │ │ │ +
#include <fstream>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
namespace  Dune::GridGlue::ProjectionWriterImplementation
 
│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,26 +6,49 @@ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -projectionwriter.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "projectionwriter_impl.hh" │ │ │ │ │ +projectionwriter_impl.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +namespace  Dune::GridGlue::ProjectionWriterImplementation │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::ProjectionWriterImplementation::write_points (const │ │ │ │ │ + Projection< Coordinate > &projection, const Corners &corners, std:: │ │ │ │ │ + ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::ProjectionWriterImplementation::write_normals (const │ │ │ │ │ + Projection< Coordinate > &projection, const Normals &normals, std:: │ │ │ │ │ + ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::ProjectionWriterImplementation:: │ │ │ │ │ + write_edge_intersection_points (const Projection< Coordinate > │ │ │ │ │ + &projection, const Corners &corners, std::ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::ProjectionWriterImplementation:: │ │ │ │ │ + write_edge_intersection_normals (const Projection< Coordinate > │ │ │ │ │ + &projection, const Normals &normals, std::ostream &out) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::ProjectionWriterImplementation::write_success (const │ │ │ │ │ + Projection< Coordinate > &projection, std::ostream &out) │ │ │ │ │ +  │ │ │ │ │ template │ │ │ │ │ void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ Corners &corners, const Normals &normals, std::ostream &out) │ │ │ │ │   write projection in VTK format More... │ │ │ │ │   │ │ │ │ │ template │ │ │ │ │ void Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projectionwriter.hh Source File │ │ │ │ +dune-grid-glue: projectionwriter_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,57 +62,195 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
projectionwriter.hh
│ │ │ │ +
projectionwriter_impl.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ -
5
│ │ │ │ -
6#include <iostream>
│ │ │ │ -
7#include <string>
│ │ │ │ -
8
│ │ │ │ - │ │ │ │ -
10
│ │ │ │ -
11namespace Dune {
│ │ │ │ -
12namespace GridGlue {
│ │ │ │ -
13
│ │ │ │ -
28template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
29void write(const Projection<Coordinate>& projection,
│ │ │ │ -
30 const Corners& corners,
│ │ │ │ -
31 const Normals& normals,
│ │ │ │ -
32 std::ostream& out);
│ │ │ │ -
33
│ │ │ │ -
40template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
41void write(const Projection<Coordinate>& projection,
│ │ │ │ -
42 const Corners& corners,
│ │ │ │ -
43 const Normals& normals,
│ │ │ │ -
44 const std::string& filename);
│ │ │ │ -
54template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ -
55void print(const Projection<Coordinate>& projection,
│ │ │ │ -
56 const Corners& corners,
│ │ │ │ -
57 const Normals& normals);
│ │ │ │ -
58
│ │ │ │ -
59} /* namespace GridGlue */
│ │ │ │ -
60} /* namespace Dune */
│ │ │ │ -
61
│ │ │ │ - │ │ │ │ -
63
│ │ │ │ -
64#endif
│ │ │ │ - │ │ │ │ - │ │ │ │ +
3#include <fstream>
│ │ │ │ +
4
│ │ │ │ +
5namespace Dune {
│ │ │ │ +
6namespace GridGlue {
│ │ │ │ +
7
│ │ │ │ +
8namespace ProjectionWriterImplementation {
│ │ │ │ +
9
│ │ │ │ +
10template<unsigned side, typename Coordinate, typename Corners>
│ │ │ │ +
11void write_points(const Projection<Coordinate>& projection, const Corners& corners, std::ostream& out)
│ │ │ │ +
12{
│ │ │ │ +
13 using namespace ProjectionImplementation;
│ │ │ │ +
14 using std::get;
│ │ │ │ +
15 const unsigned other_side = 1 - side;
│ │ │ │ +
16
│ │ │ │ +
17 for (const auto& c : get<side>(corners))
│ │ │ │ +
18 out << c << "\n";
│ │ │ │ +
19
│ │ │ │ +
20 for (const auto& i : get<side>(projection.images())) {
│ │ │ │ +
21 const auto global = interpolate(i, get<other_side>(corners));
│ │ │ │ +
22 out << global << "\n";
│ │ │ │ +
23 }
│ │ │ │ +
24}
│ │ │ │ +
25
│ │ │ │ +
26template<unsigned side, typename Coordinate, typename Normals>
│ │ │ │ +
27void write_normals(const Projection<Coordinate>& projection, const Normals& normals, std::ostream& out)
│ │ │ │ +
28{
│ │ │ │ +
29 using namespace ProjectionImplementation;
│ │ │ │ +
30 using std::get;
│ │ │ │ +
31 const unsigned other_side = 1 - side;
│ │ │ │ +
32
│ │ │ │ +
33 for (const auto& n : get<side>(normals))
│ │ │ │ +
34 out << n << "\n";
│ │ │ │ +
35
│ │ │ │ +
36 for (const auto& x : get<side>(projection.images())) {
│ │ │ │ +
37 const auto n = interpolate_unit_normals(x, get<other_side>(normals));
│ │ │ │ +
38 out << n << "\n";
│ │ │ │ +
39 }
│ │ │ │ +
40}
│ │ │ │ +
41
│ │ │ │ +
42template<typename Coordinate, typename Corners>
│ │ │ │ +
43void write_edge_intersection_points(const Projection<Coordinate>& projection, const Corners& corners, std::ostream& out)
│ │ │ │ +
44{
│ │ │ │ +
45 using namespace ProjectionImplementation;
│ │ │ │ +
46 using std::get;
│ │ │ │ +
47
│ │ │ │ +
48 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) {
│ │ │ │ +
49 const auto& local = projection.edgeIntersections()[i].local;
│ │ │ │ +
50 out << interpolate(local[0], get<0>(corners)) << "\n"
│ │ │ │ +
51 << interpolate(local[1], get<1>(corners)) << "\n";
│ │ │ │ +
52 }
│ │ │ │ +
53}
│ │ │ │ +
54
│ │ │ │ +
55template<typename Coordinate, typename Normals>
│ │ │ │ +
56void write_edge_intersection_normals(const Projection<Coordinate>& projection, const Normals& normals, std::ostream& out)
│ │ │ │ +
57{
│ │ │ │ +
58 using namespace ProjectionImplementation;
│ │ │ │ +
59 using std::get;
│ │ │ │ +
60
│ │ │ │ +
61 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) {
│ │ │ │ +
62 const auto& local = projection.edgeIntersections()[i].local;
│ │ │ │ +
63 const auto n0 = interpolate_unit_normals(local[0], get<0>(normals));
│ │ │ │ +
64 const auto n1 = interpolate_unit_normals(local[1], get<1>(normals));
│ │ │ │ +
65
│ │ │ │ +
66 out << n0 << "\n"
│ │ │ │ +
67 << n1 << "\n";
│ │ │ │ +
68 }
│ │ │ │ +
69}
│ │ │ │ +
70
│ │ │ │ +
71template<unsigned side, typename Coordinate>
│ │ │ │ +
72void write_success(const Projection<Coordinate>& projection, std::ostream& out)
│ │ │ │ +
73{
│ │ │ │ +
74 using std::get;
│ │ │ │ +
75
│ │ │ │ +
76 out << side << "\n";
│ │ │ │ +
77
│ │ │ │ +
78 const auto& success = get<side>(projection.success());
│ │ │ │ +
79 for (std::size_t i = 0; i < success.size(); ++i)
│ │ │ │ +
80 out << (success[i] ? "1\n" : "0\n");
│ │ │ │ +
81}
│ │ │ │ +
82
│ │ │ │ +
83} /* namespace ProjectionWriterImplementation */
│ │ │ │ +
84
│ │ │ │ +
85template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
86void write(const Projection<Coordinate>& projection,
│ │ │ │ +
87 const Corners& corners,
│ │ │ │ +
88 const Normals& normals,
│ │ │ │ +
89 std::ostream& out)
│ │ │ │ +
90{
│ │ │ │ +
91 using namespace ProjectionWriterImplementation;
│ │ │ │ +
92
│ │ │ │ +
93 const auto numberOfEdgeIntersections = projection.numberOfEdgeIntersections();
│ │ │ │ +
94 const auto nPoints = 12 + 2 * numberOfEdgeIntersections;
│ │ │ │ +
95
│ │ │ │ +
96 out << "# vtk DataFile Version2.0\n"
│ │ │ │ +
97 << "Filename: projection\n"
│ │ │ │ +
98 << "ASCII\n"
│ │ │ │ +
99 << "DATASET UNSTRUCTURED_GRID\n"
│ │ │ │ +
100 << "POINTS " << nPoints << " double\n";
│ │ │ │ +
101 write_points<0>(projection, corners, out);
│ │ │ │ +
102 write_points<1>(projection, corners, out);
│ │ │ │ +
103 write_edge_intersection_points(projection, corners, out);
│ │ │ │ +
104 out << "CELLS " << (8 + numberOfEdgeIntersections) << " " << (26 + 3 * numberOfEdgeIntersections) << "\n";
│ │ │ │ +
105 out << "3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n"
│ │ │ │ +
106 << "3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n";
│ │ │ │ +
107 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ +
108 out << "2 " << (12 + 2*i) << " " << (12 + 2*i + 1) << "\n";
│ │ │ │ +
109 out << "CELL_TYPES " << (8 + numberOfEdgeIntersections) << "\n" "5\n3\n3\n3\n" "5\n3\n3\n3\n";
│ │ │ │ +
110 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ +
111 out << "3\n";
│ │ │ │ +
112 out << "CELL_DATA " << (8 + numberOfEdgeIntersections) << "\n";
│ │ │ │ +
113 out << "SCALARS success int 1\n"
│ │ │ │ +
114 << "LOOKUP_TABLE success\n";
│ │ │ │ +
115 write_success<0>(projection, out);
│ │ │ │ +
116 write_success<1>(projection, out);
│ │ │ │ +
117 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i)
│ │ │ │ +
118 out << "2\n";
│ │ │ │ +
119 out << "LOOKUP_TABLE success 2\n"
│ │ │ │ +
120 << "1.0 0.0 0.0 1.0\n"
│ │ │ │ +
121 << "0.0 1.0 0.0 1.0\n";
│ │ │ │ +
122 out << "POINT_DATA " << nPoints << "\n"
│ │ │ │ +
123 << "NORMALS normals double\n";
│ │ │ │ +
124 write_normals<0>(projection, normals, out);
│ │ │ │ +
125 write_normals<1>(projection, normals, out);
│ │ │ │ +
126 write_edge_intersection_normals(projection, normals, out);
│ │ │ │ +
127}
│ │ │ │ +
128
│ │ │ │ +
129template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
130void write(const Projection<Coordinate>& projection,
│ │ │ │ +
131 const Corners& corners,
│ │ │ │ +
132 const Normals& normals,
│ │ │ │ +
133 const std::string& filename)
│ │ │ │ +
134{
│ │ │ │ +
135 std::ofstream out(filename.c_str());
│ │ │ │ +
136 write(projection, corners, normals, out);
│ │ │ │ +
137}
│ │ │ │ +
138
│ │ │ │ +
139template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
140void print(const Projection<Coordinate>& projection,
│ │ │ │ +
141 const Corners& corners,
│ │ │ │ +
142 const Normals& normals)
│ │ │ │ +
143{
│ │ │ │ +
144 using namespace ProjectionWriterImplementation;
│ │ │ │ +
145
│ │ │ │ +
146 std::cout << "Side 0 corners and images:\n";
│ │ │ │ +
147 write_points<0>(projection, corners, std::cout);
│ │ │ │ +
148 std::cout << "Side 0 success:\n";
│ │ │ │ +
149 write_success<0>(projection, std::cout);
│ │ │ │ +
150 std::cout << "Side 1 corners and images:\n";
│ │ │ │ +
151 write_points<1>(projection, corners, std::cout);
│ │ │ │ +
152 std::cout << "Side 1 success:\n";
│ │ │ │ +
153 write_success<1>(projection, std::cout);
│ │ │ │ +
154 std::cout << "Side 0 normals and projected normals:\n";
│ │ │ │ +
155 write_normals<0>(projection, normals, std::cout);
│ │ │ │ +
156 std::cout << "Side 1 normals and projected normals:\n";
│ │ │ │ +
157 write_normals<1>(projection, normals, std::cout);
│ │ │ │ +
158 std::cout << projection.numberOfEdgeIntersections() << " edge intersections:\n";
│ │ │ │ +
159 write_edge_intersection_points(projection, corners, std::cout);
│ │ │ │ +
160}
│ │ │ │ +
161
│ │ │ │ +
162} /* namespace GridGlue */
│ │ │ │ +
163} /* namespace Dune */
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │
void write(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
write projection in VTK format
Definition: projectionwriter_impl.hh:86
│ │ │ │
void print(const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals)
Print information about the projection to std::cout stream.
Definition: projectionwriter_impl.hh:140
│ │ │ │ +
Corners::value_type interpolate(const Coordinate &x, const Corners &corners)
Definition: projection_impl.hh:70
│ │ │ │ +
Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals &normals)
Definition: projection_impl.hh:91
│ │ │ │ +
void write_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:27
│ │ │ │ +
void write_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:11
│ │ │ │ +
void write_success(const Projection< Coordinate > &projection, std::ostream &out)
Definition: projectionwriter_impl.hh:72
│ │ │ │ +
void write_edge_intersection_points(const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
Definition: projectionwriter_impl.hh:43
│ │ │ │ +
void write_edge_intersection_normals(const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
Definition: projectionwriter_impl.hh:56
│ │ │ │ +
Projection of a line (triangle) on another line (triangle).
Definition: projection.hh:21
│ │ │ │ +
const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const
Indicate whether projection (inverse projection) is valid for each corner or not.
Definition: projection.hh:252
│ │ │ │ +
unsigned numberOfEdgeIntersections() const
Number of edge intersections.
Definition: projection.hh:262
│ │ │ │ +
const std::tuple< Images, Preimages > & images() const
Images and preimages of corners.
Definition: projection.hh:235
│ │ │ │ +
const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections() const
Edge-edge intersections.
Definition: projection.hh:273
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,63 +5,246 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projectionwriter.hh │ │ │ │ │ +projectionwriter_impl.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ - 4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8 │ │ │ │ │ - 9#include │ │ │ │ │ - 10 │ │ │ │ │ - 11namespace Dune { │ │ │ │ │ - 12namespace GridGlue { │ │ │ │ │ - 13 │ │ │ │ │ - 28template │ │ │ │ │ - 29void write(const Projection& projection, │ │ │ │ │ - 30 const Corners& corners, │ │ │ │ │ - 31 const Normals& normals, │ │ │ │ │ - 32 std::ostream& out); │ │ │ │ │ - 33 │ │ │ │ │ - 40template │ │ │ │ │ - 41void write(const Projection& projection, │ │ │ │ │ - 42 const Corners& corners, │ │ │ │ │ - 43 const Normals& normals, │ │ │ │ │ - 44 const std::string& filename); │ │ │ │ │ - 54template │ │ │ │ │ - 55void print(const Projection& projection, │ │ │ │ │ - 56 const Corners& corners, │ │ │ │ │ - 57 const Normals& normals); │ │ │ │ │ - 58 │ │ │ │ │ - 59} /* namespace GridGlue */ │ │ │ │ │ - 60} /* namespace Dune */ │ │ │ │ │ - 61 │ │ │ │ │ - 62#include "projectionwriter_impl.hh" │ │ │ │ │ - 63 │ │ │ │ │ - 64#endif │ │ │ │ │ -projectionwriter_impl.hh │ │ │ │ │ -projection.hh │ │ │ │ │ + 3#include │ │ │ │ │ + 4 │ │ │ │ │ + 5namespace Dune { │ │ │ │ │ + 6namespace GridGlue { │ │ │ │ │ + 7 │ │ │ │ │ +8namespace ProjectionWriterImplementation { │ │ │ │ │ + 9 │ │ │ │ │ + 10template │ │ │ │ │ +11void write_points(const Projection& projection, const Corners& │ │ │ │ │ +corners, std::ostream& out) │ │ │ │ │ + 12{ │ │ │ │ │ + 13 using namespace ProjectionImplementation; │ │ │ │ │ + 14 using std::get; │ │ │ │ │ + 15 const unsigned other_side = 1 - side; │ │ │ │ │ + 16 │ │ │ │ │ + 17 for (const auto& c : get(corners)) │ │ │ │ │ + 18 out << c << "\n"; │ │ │ │ │ + 19 │ │ │ │ │ + 20 for (const auto& i : get(projection.images())) { │ │ │ │ │ + 21 const auto global = interpolate(i, get(corners)); │ │ │ │ │ + 22 out << global << "\n"; │ │ │ │ │ + 23 } │ │ │ │ │ + 24} │ │ │ │ │ + 25 │ │ │ │ │ + 26template │ │ │ │ │ +27void write_normals(const Projection& projection, const Normals& │ │ │ │ │ +normals, std::ostream& out) │ │ │ │ │ + 28{ │ │ │ │ │ + 29 using namespace ProjectionImplementation; │ │ │ │ │ + 30 using std::get; │ │ │ │ │ + 31 const unsigned other_side = 1 - side; │ │ │ │ │ + 32 │ │ │ │ │ + 33 for (const auto& n : get(normals)) │ │ │ │ │ + 34 out << n << "\n"; │ │ │ │ │ + 35 │ │ │ │ │ + 36 for (const auto& x : get(projection.images())) { │ │ │ │ │ + 37 const auto n = interpolate_unit_normals(x, get(normals)); │ │ │ │ │ + 38 out << n << "\n"; │ │ │ │ │ + 39 } │ │ │ │ │ + 40} │ │ │ │ │ + 41 │ │ │ │ │ + 42template │ │ │ │ │ +43void write_edge_intersection_points(const Projection& projection, │ │ │ │ │ +const Corners& corners, std::ostream& out) │ │ │ │ │ + 44{ │ │ │ │ │ + 45 using namespace ProjectionImplementation; │ │ │ │ │ + 46 using std::get; │ │ │ │ │ + 47 │ │ │ │ │ + 48 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ + 49 const auto& local = projection.edgeIntersections()[i].local; │ │ │ │ │ + 50 out << interpolate(local[0], get<0>(corners)) << "\n" │ │ │ │ │ + 51 << interpolate(local[1], get<1>(corners)) << "\n"; │ │ │ │ │ + 52 } │ │ │ │ │ + 53} │ │ │ │ │ + 54 │ │ │ │ │ + 55template │ │ │ │ │ +56void write_edge_intersection_normals(const Projection& │ │ │ │ │ +projection, const Normals& normals, std::ostream& out) │ │ │ │ │ + 57{ │ │ │ │ │ + 58 using namespace ProjectionImplementation; │ │ │ │ │ + 59 using std::get; │ │ │ │ │ + 60 │ │ │ │ │ + 61 for (std::size_t i = 0; i < projection.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ + 62 const auto& local = projection.edgeIntersections()[i].local; │ │ │ │ │ + 63 const auto n0 = interpolate_unit_normals(local[0], get<0>(normals)); │ │ │ │ │ + 64 const auto n1 = interpolate_unit_normals(local[1], get<1>(normals)); │ │ │ │ │ + 65 │ │ │ │ │ + 66 out << n0 << "\n" │ │ │ │ │ + 67 << n1 << "\n"; │ │ │ │ │ + 68 } │ │ │ │ │ + 69} │ │ │ │ │ + 70 │ │ │ │ │ + 71template │ │ │ │ │ +72void write_success(const Projection& projection, std::ostream& │ │ │ │ │ +out) │ │ │ │ │ + 73{ │ │ │ │ │ + 74 using std::get; │ │ │ │ │ + 75 │ │ │ │ │ + 76 out << side << "\n"; │ │ │ │ │ + 77 │ │ │ │ │ + 78 const auto& success = get(projection.success()); │ │ │ │ │ + 79 for (std::size_t i = 0; i < success.size(); ++i) │ │ │ │ │ + 80 out << (success[i] ? "1\n" : "0\n"); │ │ │ │ │ + 81} │ │ │ │ │ + 82 │ │ │ │ │ + 83} /* namespace ProjectionWriterImplementation */ │ │ │ │ │ + 84 │ │ │ │ │ + 85template │ │ │ │ │ +86void write(const Projection& projection, │ │ │ │ │ + 87 const Corners& corners, │ │ │ │ │ + 88 const Normals& normals, │ │ │ │ │ + 89 std::ostream& out) │ │ │ │ │ + 90{ │ │ │ │ │ + 91 using namespace ProjectionWriterImplementation; │ │ │ │ │ + 92 │ │ │ │ │ + 93 const auto numberOfEdgeIntersections = projection.numberOfEdgeIntersections │ │ │ │ │ +(); │ │ │ │ │ + 94 const auto nPoints = 12 + 2 * numberOfEdgeIntersections; │ │ │ │ │ + 95 │ │ │ │ │ + 96 out << "# vtk DataFile Version2.0\n" │ │ │ │ │ + 97 << "Filename: projection\n" │ │ │ │ │ + 98 << "ASCII\n" │ │ │ │ │ + 99 << "DATASET UNSTRUCTURED_GRID\n" │ │ │ │ │ + 100 << "POINTS " << nPoints << " double\n"; │ │ │ │ │ + 101 write_points<0>(projection, corners, out); │ │ │ │ │ + 102 write_points<1>(projection, corners, out); │ │ │ │ │ + 103 write_edge_intersection_points(projection, corners, out); │ │ │ │ │ + 104 out << "CELLS " << (8 + numberOfEdgeIntersections) << " " << (26 + 3 * │ │ │ │ │ +numberOfEdgeIntersections) << "\n"; │ │ │ │ │ + 105 out << "3 0 1 2\n" "2 0 3\n" "2 1 4\n" "2 2 5\n" │ │ │ │ │ + 106 << "3 6 7 8\n" "2 6 9\n" "2 7 10\n" "2 8 11\n"; │ │ │ │ │ + 107 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ + 108 out << "2 " << (12 + 2*i) << " " << (12 + 2*i + 1) << "\n"; │ │ │ │ │ + 109 out << "CELL_TYPES " << (8 + numberOfEdgeIntersections) << "\n" │ │ │ │ │ +"5\n3\n3\n3\n" "5\n3\n3\n3\n"; │ │ │ │ │ + 110 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ + 111 out << "3\n"; │ │ │ │ │ + 112 out << "CELL_DATA " << (8 + numberOfEdgeIntersections) << "\n"; │ │ │ │ │ + 113 out << "SCALARS success int 1\n" │ │ │ │ │ + 114 << "LOOKUP_TABLE success\n"; │ │ │ │ │ + 115 write_success<0>(projection, out); │ │ │ │ │ + 116 write_success<1>(projection, out); │ │ │ │ │ + 117 for (std::size_t i = 0; i < numberOfEdgeIntersections; ++i) │ │ │ │ │ + 118 out << "2\n"; │ │ │ │ │ + 119 out << "LOOKUP_TABLE success 2\n" │ │ │ │ │ + 120 << "1.0 0.0 0.0 1.0\n" │ │ │ │ │ + 121 << "0.0 1.0 0.0 1.0\n"; │ │ │ │ │ + 122 out << "POINT_DATA " << nPoints << "\n" │ │ │ │ │ + 123 << "NORMALS normals double\n"; │ │ │ │ │ + 124 write_normals<0>(projection, normals, out); │ │ │ │ │ + 125 write_normals<1>(projection, normals, out); │ │ │ │ │ + 126 write_edge_intersection_normals(projection, normals, out); │ │ │ │ │ + 127} │ │ │ │ │ + 128 │ │ │ │ │ + 129template │ │ │ │ │ +130void write(const Projection& projection, │ │ │ │ │ + 131 const Corners& corners, │ │ │ │ │ + 132 const Normals& normals, │ │ │ │ │ + 133 const std::string& filename) │ │ │ │ │ + 134{ │ │ │ │ │ + 135 std::ofstream out(filename.c_str()); │ │ │ │ │ + 136 write(projection, corners, normals, out); │ │ │ │ │ + 137} │ │ │ │ │ + 138 │ │ │ │ │ + 139template │ │ │ │ │ +140void print(const Projection& projection, │ │ │ │ │ + 141 const Corners& corners, │ │ │ │ │ + 142 const Normals& normals) │ │ │ │ │ + 143{ │ │ │ │ │ + 144 using namespace ProjectionWriterImplementation; │ │ │ │ │ + 145 │ │ │ │ │ + 146 std::cout << "Side 0 corners and images:\n"; │ │ │ │ │ + 147 write_points<0>(projection, corners, std::cout); │ │ │ │ │ + 148 std::cout << "Side 0 success:\n"; │ │ │ │ │ + 149 write_success<0>(projection, std::cout); │ │ │ │ │ + 150 std::cout << "Side 1 corners and images:\n"; │ │ │ │ │ + 151 write_points<1>(projection, corners, std::cout); │ │ │ │ │ + 152 std::cout << "Side 1 success:\n"; │ │ │ │ │ + 153 write_success<1>(projection, std::cout); │ │ │ │ │ + 154 std::cout << "Side 0 normals and projected normals:\n"; │ │ │ │ │ + 155 write_normals<0>(projection, normals, std::cout); │ │ │ │ │ + 156 std::cout << "Side 1 normals and projected normals:\n"; │ │ │ │ │ + 157 write_normals<1>(projection, normals, std::cout); │ │ │ │ │ + 158 std::cout << projection.numberOfEdgeIntersections() << " edge │ │ │ │ │ +intersections:\n"; │ │ │ │ │ + 159 write_edge_intersection_points(projection, corners, std::cout); │ │ │ │ │ + 160} │ │ │ │ │ + 161 │ │ │ │ │ + 162} /* namespace GridGlue */ │ │ │ │ │ + 163} /* namespace Dune */ │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ Dune::GridGlue::write │ │ │ │ │ void write(const Projection< Coordinate > &projection, const Corners &corners, │ │ │ │ │ const Normals &normals, std::ostream &out) │ │ │ │ │ write projection in VTK format │ │ │ │ │ Definition: projectionwriter_impl.hh:86 │ │ │ │ │ Dune::GridGlue::print │ │ │ │ │ void print(const Projection< Coordinate > &projection, const Corners &corners, │ │ │ │ │ const Normals &normals) │ │ │ │ │ Print information about the projection to std::cout stream. │ │ │ │ │ Definition: projectionwriter_impl.hh:140 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::interpolate │ │ │ │ │ +Corners::value_type interpolate(const Coordinate &x, const Corners &corners) │ │ │ │ │ +Definition: projection_impl.hh:70 │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::interpolate_unit_normals │ │ │ │ │ +Normals::value_type interpolate_unit_normals(const Coordinate &x, const Normals │ │ │ │ │ +&normals) │ │ │ │ │ +Definition: projection_impl.hh:91 │ │ │ │ │ +Dune::GridGlue::ProjectionWriterImplementation::write_normals │ │ │ │ │ +void write_normals(const Projection< Coordinate > &projection, const Normals │ │ │ │ │ +&normals, std::ostream &out) │ │ │ │ │ +Definition: projectionwriter_impl.hh:27 │ │ │ │ │ +Dune::GridGlue::ProjectionWriterImplementation::write_points │ │ │ │ │ +void write_points(const Projection< Coordinate > &projection, const Corners │ │ │ │ │ +&corners, std::ostream &out) │ │ │ │ │ +Definition: projectionwriter_impl.hh:11 │ │ │ │ │ +Dune::GridGlue::ProjectionWriterImplementation::write_success │ │ │ │ │ +void write_success(const Projection< Coordinate > &projection, std::ostream │ │ │ │ │ +&out) │ │ │ │ │ +Definition: projectionwriter_impl.hh:72 │ │ │ │ │ +Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_points │ │ │ │ │ +void write_edge_intersection_points(const Projection< Coordinate > &projection, │ │ │ │ │ +const Corners &corners, std::ostream &out) │ │ │ │ │ +Definition: projectionwriter_impl.hh:43 │ │ │ │ │ +Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_normals │ │ │ │ │ +void write_edge_intersection_normals(const Projection< Coordinate > │ │ │ │ │ +&projection, const Normals &normals, std::ostream &out) │ │ │ │ │ +Definition: projectionwriter_impl.hh:56 │ │ │ │ │ +Dune::GridGlue::Projection │ │ │ │ │ +Projection of a line (triangle) on another line (triangle). │ │ │ │ │ +Definition: projection.hh:21 │ │ │ │ │ +Dune::GridGlue::Projection::success │ │ │ │ │ +const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const │ │ │ │ │ +Indicate whether projection (inverse projection) is valid for each corner or │ │ │ │ │ +not. │ │ │ │ │ +Definition: projection.hh:252 │ │ │ │ │ +Dune::GridGlue::Projection::numberOfEdgeIntersections │ │ │ │ │ +unsigned numberOfEdgeIntersections() const │ │ │ │ │ +Number of edge intersections. │ │ │ │ │ +Definition: projection.hh:262 │ │ │ │ │ +Dune::GridGlue::Projection::images │ │ │ │ │ +const std::tuple< Images, Preimages > & images() const │ │ │ │ │ +Images and preimages of corners. │ │ │ │ │ +Definition: projection.hh:235 │ │ │ │ │ +Dune::GridGlue::Projection::edgeIntersections │ │ │ │ │ +const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections │ │ │ │ │ +() const │ │ │ │ │ +Edge-edge intersections. │ │ │ │ │ +Definition: projection.hh:273 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062.html │ │ │ │ @@ -77,15 +77,15 @@ │ │ │ │ More...

│ │ │ │
#include "extractor.hh"
│ │ │ │ #include <array>
│ │ │ │ #include <deque>
│ │ │ │ #include <functional>
│ │ │ │ #include <dune/common/deprecated.hh>
│ │ │ │ #include <dune/common/version.hh>
│ │ │ │ -#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ +#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Functions

template<unsigned side, typename Coordinate , typename Corners >
void Dune::GridGlue::ProjectionWriterImplementation::write_points (const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
 
template<unsigned side, typename Coordinate , typename Normals >
void Dune::GridGlue::ProjectionWriterImplementation::write_normals (const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
 
template<typename Coordinate , typename Corners >
void Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_points (const Projection< Coordinate > &projection, const Corners &corners, std::ostream &out)
 
template<typename Coordinate , typename Normals >
void Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_normals (const Projection< Coordinate > &projection, const Normals &normals, std::ostream &out)
 
template<unsigned side, typename Coordinate >
void Dune::GridGlue::ProjectionWriterImplementation::write_success (const Projection< Coordinate > &projection, std::ostream &out)
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, std::ostream &out)
 write projection in VTK format More...
 
template<typename Coordinate , typename Corners , typename Normals >
void Dune::GridGlue::write (const Projection< Coordinate > &projection, const Corners &corners, const Normals &normals, const std::string &filename)
 write projection in VTK format More...
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062_source.html │ │ │ │ @@ -90,15 +90,15 @@ │ │ │ │
24
│ │ │ │
25#include <array>
│ │ │ │
26#include <deque>
│ │ │ │
27#include <functional>
│ │ │ │
28
│ │ │ │
29#include <dune/common/deprecated.hh>
│ │ │ │
30#include <dune/common/version.hh>
│ │ │ │ - │ │ │ │ + │ │ │ │
32
│ │ │ │
33namespace Dune {
│ │ │ │
34
│ │ │ │
35 namespace GridGlue {
│ │ │ │
36
│ │ │ │
40template<typename GV>
│ │ │ │
41class Codim1Extractor : public Extractor<GV,1>
│ │ │ │ @@ -428,15 +428,15 @@ │ │ │ │
384}
│ │ │ │
385
│ │ │ │
386} // namespace GridGlue
│ │ │ │
387
│ │ │ │
388} // namespace Dune
│ │ │ │
389
│ │ │ │
390#endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │ - │ │ │ │ + │ │ │ │
extractor base class
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │
static Dune::FieldVector< T, dim > crossProduct(const Dune::FieldVector< T, dim > &a, const Dune::FieldVector< T, dim > &b)
compute cross product
Definition: crossproduct.hh:15
│ │ │ │
Definition: codim1extractor.hh:42
│ │ │ │
Extractor< GV, 1 >::IndexType IndexType
Definition: codim1extractor.hh:51
│ │ │ │
GV GridView
Definition: codim1extractor.hh:56
│ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.hh File Reference │ │ │ │ +dune-grid-glue: overlappingmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,46 +64,45 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
computeintersection.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
overlappingmerge.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/common/fvector.hh>
│ │ │ │ +
#include <iostream>
│ │ │ │ +#include <iomanip>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <algorithm>
│ │ │ │ #include <dune/common/fmatrix.hh>
│ │ │ │ -#include "simplexintersection.cc"
│ │ │ │ -#include "computeintersection.cc"
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/geometry/referenceelements.hh>
│ │ │ │ +#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ +#include <dune/grid/common/grid.hh>
│ │ │ │ +#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ +#include <dune/grid-glue/merging/computeintersection.hh>
│ │ │ │ +#include "overlappingmerge.cc"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::Codim1Extractor< GV >
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::ComputationMethod< dimWorld, dim1, dim2, T >
 
class  Dune::GridGlue::IntersectionComputation< CM >
 Intersection computation method for two elements of arbitrary dimension. More...
class  Dune::GridGlue::OverlappingMerge< dim1, dim2, dimworld, T >
 Computing overlapping grid intersections for grids of different dimensions. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class V >
int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,33 +5,35 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -computeintersection.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +overlappingmerge.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include "simplexintersection.cc" │ │ │ │ │ -#include "computeintersection.cc" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "overlappingmerge.cc" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::GridGlue::ComputationMethod<_dimWorld,_dim1,_dim2,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::IntersectionComputation<_CM_> │ │ │ │ │ -  Intersection computation method for two elements of arbitrary │ │ │ │ │ - dimension. More... │ │ │ │ │ +class  Dune::GridGlue::OverlappingMerge<_dim1,_dim2,_dimworld,_T_> │ │ │ │ │ +  Computing overlapping grid intersections for grids of different │ │ │ │ │ + dimensions. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P) │ │ │ │ │ -  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.hh Source File │ │ │ │ +dune-grid-glue: overlappingmerge.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,182 +62,98 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
computeintersection.hh
│ │ │ │ +
overlappingmerge.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
3#ifndef DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH
│ │ │ │ -
5
│ │ │ │ -
6#include <dune/common/fvector.hh>
│ │ │ │ -
7#include <dune/common/fmatrix.hh>
│ │ │ │ -
8
│ │ │ │ -
9namespace Dune {
│ │ │ │ -
10namespace GridGlue {
│ │ │ │ -
11
│ │ │ │ -
12template<int dimWorld, int dim1, int dim2, typename T = double>
│ │ │ │ - │ │ │ │ -
14public:
│ │ │ │ -
15 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
16 static const int grid1Dimension = dim1;
│ │ │ │ -
17 static const int grid2Dimension = dim2;
│ │ │ │ -
18 static const int intersectionDimension = (dim1 < dim2)?(dim1):(dim2);
│ │ │ │ -
19
│ │ │ │ -
20 static bool computeIntersectionPoints(const std::vector<Vector> X,
│ │ │ │ -
21 const std::vector<Vector> Y,
│ │ │ │ -
22 std::vector<std::vector<int> >& SX,
│ │ │ │ -
23 std::vector<std::vector<int> >& SY,
│ │ │ │ -
24 std::vector<Vector>& P);
│ │ │ │ -
25 static void grid1_subdivisions(const std::vector<Vector> elementCorners,
│ │ │ │ -
26 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
27 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
28 static void grid2_subdivisions(const std::vector<Vector> elementCorners,
│ │ │ │ -
29 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
30 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
31};
│ │ │ │ -
32
│ │ │ │ -
38template<class CM>
│ │ │ │ - │ │ │ │ -
40private:
│ │ │ │ -
41 typedef typename CM::Vector V;
│ │ │ │ -
42 const int dimWorld = V::dimension;
│ │ │ │ -
43 const int dim1 = CM::grid1Dimension;
│ │ │ │ -
44 const int dim2 = CM::grid2Dimension;
│ │ │ │ -
45public:
│ │ │ │ -
59 static bool computeIntersection(const std::vector<V>& X,
│ │ │ │ -
60 const std::vector<V>& Y,
│ │ │ │ -
61 std::vector<std::vector<int> >& SX,
│ │ │ │ -
62 std::vector<std::vector<int> >& SY,
│ │ │ │ -
63 std::vector<V>& P);
│ │ │ │ -
64
│ │ │ │ -
74 template<int isDim, int dW>
│ │ │ │ -
75 static void orderPoints(const V& centroid,
│ │ │ │ -
76 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
77 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
78 const std::vector<V>& P,
│ │ │ │ -
79 std::vector<std::vector<int> >& H)
│ │ │ │ -
80 {
│ │ │ │ -
81 if (isDim > 1)
│ │ │ │ -
82 orderPoints_(std::integral_constant<int,isDim>(),std::integral_constant<int,dW>(),
│ │ │ │ -
83 centroid, SX, SY, P,H);
│ │ │ │ -
84 }
│ │ │ │ -
85
│ │ │ │ -
86private:
│ │ │ │ -
87 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ -
88 std::integral_constant<int,1>,
│ │ │ │ -
89 const V& centroid,
│ │ │ │ -
90 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
91 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
92 const std::vector<V>& P,
│ │ │ │ -
93 std::vector<std::vector<int> >& H) {}
│ │ │ │ -
94 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ -
95 std::integral_constant<int,2>,
│ │ │ │ -
96 const V& centroid,
│ │ │ │ -
97 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
98 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
99 const std::vector<V>& P,
│ │ │ │ -
100 std::vector<std::vector<int> >& H) {}
│ │ │ │ -
101 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ -
102 std::integral_constant<int,3>,
│ │ │ │ -
103 const V& centroid,
│ │ │ │ -
104 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
105 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
106 const std::vector<V>& P,
│ │ │ │ -
107 std::vector<std::vector<int> >& H) {}
│ │ │ │ -
108 static void orderPoints_(std::integral_constant<int,2>,
│ │ │ │ -
109 std::integral_constant<int,2>,
│ │ │ │ -
110 const V& centroid,
│ │ │ │ -
111 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
112 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
113 const std::vector<V>& P,
│ │ │ │ -
114 std::vector<std::vector<int> >& H);
│ │ │ │ -
115 static void orderPoints_(std::integral_constant<int,2>,
│ │ │ │ -
116 std::integral_constant<int,3>,
│ │ │ │ -
117 const V& centroid,
│ │ │ │ -
118 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
119 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
120 const std::vector<V>& P,
│ │ │ │ -
121 std::vector<std::vector<int> >& H);
│ │ │ │ -
122 static void orderPoints_(std::integral_constant<int,3>,
│ │ │ │ -
123 std::integral_constant<int,3>,
│ │ │ │ -
124 const V& centroid,
│ │ │ │ -
125 const std::vector<std::vector<int> >& SX,
│ │ │ │ -
126 const std::vector<std::vector<int> >& SY,
│ │ │ │ -
127 const std::vector<V>& P,
│ │ │ │ -
128 std::vector<std::vector<int> > & H);
│ │ │ │ -
129
│ │ │ │ -
137 static void orderPointsCC(std::integral_constant<int,2>,
│ │ │ │ -
138 const V& centroid,
│ │ │ │ -
139 std::vector<int> &id,
│ │ │ │ -
140 const std::vector<V>& P);
│ │ │ │ -
141 static void orderPointsCC(std::integral_constant<int,3>,
│ │ │ │ -
142 const V& centroid,
│ │ │ │ -
143 std::vector<int> &id,
│ │ │ │ -
144 const std::vector<V>& P);
│ │ │ │ -
145
│ │ │ │ -
150 static void removeDuplicates( std::vector<int> & p);
│ │ │ │ -
151
│ │ │ │ -
159 static bool newFace3D(const std::vector<int>& id,
│ │ │ │ -
160 const std::vector<std::vector<int> >& H);
│ │ │ │ -
161};
│ │ │ │ -
162
│ │ │ │ -
163template<class V>
│ │ │ │ -
164inline int insertPoint(const V p, std::vector<V>& P)
│ │ │ │ -
165{
│ │ │ │ -
166 double eps= 1e-8; // tolerance for identical nodes
│ │ │ │ -
167 std::size_t k=0 ;
│ │ │ │ -
168
│ │ │ │ -
169 if (P.size()>0) {
│ │ │ │ -
170
│ │ │ │ -
171 while ((k<P.size())&&
│ │ │ │ -
172 ((p - P[k]).infinity_norm()>eps*(P[k].infinity_norm()) &&
│ │ │ │ -
173 (p - P[k]).infinity_norm()>eps*(p.infinity_norm())) &&
│ │ │ │ -
174 !(p.infinity_norm() < eps && P[k].infinity_norm() <eps &&
│ │ │ │ -
175 (p - P[k]).infinity_norm() < eps))
│ │ │ │ -
176 k++ ;
│ │ │ │ -
177
│ │ │ │ -
178 if (k>=P.size())
│ │ │ │ -
179 P.push_back(p) ; // new node is not contained in P
│ │ │ │ -
180
│ │ │ │ -
181 }
│ │ │ │ -
182 else
│ │ │ │ -
183 P.push_back(p);
│ │ │ │ -
184
│ │ │ │ -
185 return k ;
│ │ │ │ -
186}
│ │ │ │ -
187
│ │ │ │ -
188
│ │ │ │ -
189} /* namespace Dune::GridGlue */
│ │ │ │ -
190} /* namespace Dune */
│ │ │ │ -
191
│ │ │ │ -
192#include "simplexintersection.cc"
│ │ │ │ -
193#include "computeintersection.cc"
│ │ │ │ -
194
│ │ │ │ -
195#endif
│ │ │ │ - │ │ │ │ - │ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ +
5#ifndef DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ +
6#define DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <iostream>
│ │ │ │ +
9#include <iomanip>
│ │ │ │ +
10#include <vector>
│ │ │ │ +
11#include <algorithm>
│ │ │ │ +
12
│ │ │ │ +
13#include <dune/common/fmatrix.hh>
│ │ │ │ +
14#include <dune/common/fvector.hh>
│ │ │ │ +
15
│ │ │ │ +
16#include <dune/geometry/referenceelements.hh>
│ │ │ │ +
17#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ +
18
│ │ │ │ +
19#include <dune/grid/common/grid.hh>
│ │ │ │ +
20
│ │ │ │ + │ │ │ │ + │ │ │ │ +
23
│ │ │ │ +
24namespace Dune {
│ │ │ │ +
25namespace GridGlue {
│ │ │ │ +
26
│ │ │ │ +
34template<int dim1, int dim2, int dimworld, typename T = double>
│ │ │ │ + │ │ │ │ +
36 : public StandardMerge<T,dim1,dim2,dimworld>
│ │ │ │ +
37{
│ │ │ │ +
38
│ │ │ │ +
39public:
│ │ │ │ +
40
│ │ │ │ +
41 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */
│ │ │ │ +
42
│ │ │ │ +
44 typedef T ctype;
│ │ │ │ +
45
│ │ │ │ +
47 typedef Dune::FieldVector<T, dimworld> WorldCoords;
│ │ │ │ +
48
│ │ │ │ +
50 //typedef Dune::FieldVector<T, dim> LocalCoords;
│ │ │ │ +
51
│ │ │ │ + │ │ │ │ +
53 {}
│ │ │ │ +
54
│ │ │ │ +
55protected:
│ │ │ │ + │ │ │ │ +
57
│ │ │ │ +
69 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
70 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
71 std::bitset<(1<<dim1)>& neighborIntersects1,
│ │ │ │ +
72 unsigned int grid1Index,
│ │ │ │ +
73 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
74 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
75 std::bitset<(1<<dim2)>& neighborIntersects2,
│ │ │ │ +
76 unsigned int grid2Index,
│ │ │ │ +
77 std::vector<SimplicialIntersection>& intersections);
│ │ │ │ +
78
│ │ │ │ +
79private:
│ │ │ │ +
80 bool inPlane(std::vector<FieldVector<T,dimworld> >& points);
│ │ │ │ +
81
│ │ │ │ +
82};
│ │ │ │ +
83
│ │ │ │ +
84} /* namespace Dune::GridGlue */
│ │ │ │ +
85} /* namespace Dune */
│ │ │ │ +
86
│ │ │ │ +
87#include "overlappingmerge.cc"
│ │ │ │ +
88
│ │ │ │ +
89
│ │ │ │ +
90#endif // DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ + │ │ │ │ + │ │ │ │ +
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
int insertPoint(const V p, std::vector< V > &P)
Definition: computeintersection.hh:164
│ │ │ │ -
Definition: computeintersection.hh:13
│ │ │ │ -
static void grid2_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< Vector > X, const std::vector< Vector > Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< Vector > &P)
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition: computeintersection.hh:15
│ │ │ │ -
static const int grid1Dimension
Definition: computeintersection.hh:16
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
│ │ │ │ -
static const int grid2Dimension
Definition: computeintersection.hh:17
│ │ │ │ -
static const int intersectionDimension
Definition: computeintersection.hh:18
│ │ │ │ -
Intersection computation method for two elements of arbitrary dimension.
Definition: computeintersection.hh:39
│ │ │ │ -
static void orderPoints(const V &centroid, const std::vector< std::vector< int > > &SX, const std::vector< std::vector< int > > &SY, const std::vector< V > &P, std::vector< std::vector< int > > &H)
Order Points in the point list P face-wise such that a subsimplex subdivision can be constructed.
Definition: computeintersection.hh:75
│ │ │ │ -
static bool computeIntersection(const std::vector< V > &X, const std::vector< V > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< V > &P)
Compute the intersection of two elements X and Y Compute the intersection of two elements X and Y,...
Definition: computeintersection.cc:14
│ │ │ │ +
Computing overlapping grid intersections for grids of different dimensions.
Definition: overlappingmerge.hh:37
│ │ │ │ +
StandardMerge< T, dim1, dim2, dimworld >::SimplicialIntersection SimplicialIntersection
Definition: overlappingmerge.hh:56
│ │ │ │ +
OverlappingMerge()
the coordinate type used in this interface
Definition: overlappingmerge.hh:52
│ │ │ │ +
void computeIntersections(const Dune::GeometryType &grid1ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std::bitset<(1<< dim1)> &neighborIntersects1, unsigned int grid1Index, const Dune::GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< dim2)> &neighborIntersects2, unsigned int grid2Index, std::vector< SimplicialIntersection > &intersections)
Compute the intersection between two overlapping elements.
Definition: overlappingmerge.cc:34
│ │ │ │ +
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: overlappingmerge.hh:47
│ │ │ │ +
T ctype
the numeric type used in this interface
Definition: overlappingmerge.hh:44
│ │ │ │ +
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition: standardmerge.hh:58
│ │ │ │ +
typename IntersectionListProvider::SimplicialIntersection SimplicialIntersection
Definition: standardmerge.hh:83
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,215 +5,128 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -computeintersection.hh │ │ │ │ │ +overlappingmerge.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ + 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ + 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ + 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ - 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ + 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 3#ifndef DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH │ │ │ │ │ - 4#define DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH │ │ │ │ │ - 5 │ │ │ │ │ - 6#include │ │ │ │ │ - 7#include │ │ │ │ │ - 8 │ │ │ │ │ - 9namespace Dune { │ │ │ │ │ - 10namespace GridGlue { │ │ │ │ │ - 11 │ │ │ │ │ - 12template │ │ │ │ │ -13class ComputationMethod { │ │ │ │ │ - 14public: │ │ │ │ │ -15 typedef FieldVector Vector; │ │ │ │ │ -16 static const int grid1Dimension = dim1; │ │ │ │ │ -17 static const int grid2Dimension = dim2; │ │ │ │ │ -18 static const int intersectionDimension = (dim1 < dim2)?(dim1):(dim2); │ │ │ │ │ - 19 │ │ │ │ │ -20 static bool computeIntersectionPoints(const std::vector X, │ │ │ │ │ - 21 const std::vector Y, │ │ │ │ │ - 22 std::vector >& SX, │ │ │ │ │ - 23 std::vector >& SY, │ │ │ │ │ - 24 std::vector& P); │ │ │ │ │ -25 static void grid1_subdivisions(const std::vector elementCorners, │ │ │ │ │ - 26 std::vector >& subElements, │ │ │ │ │ - 27 std::vector >& faceIds); │ │ │ │ │ -28 static void grid2_subdivisions(const std::vector elementCorners, │ │ │ │ │ - 29 std::vector >& subElements, │ │ │ │ │ - 30 std::vector >& faceIds); │ │ │ │ │ - 31}; │ │ │ │ │ - 32 │ │ │ │ │ - 38template │ │ │ │ │ -39class IntersectionComputation { │ │ │ │ │ - 40private: │ │ │ │ │ - 41 typedef typename CM::Vector V; │ │ │ │ │ - 42 const int dimWorld = V::dimension; │ │ │ │ │ - 43 const int dim1 = CM::grid1Dimension; │ │ │ │ │ - 44 const int dim2 = CM::grid2Dimension; │ │ │ │ │ - 45public: │ │ │ │ │ - 59 static bool computeIntersection(const std::vector& X, │ │ │ │ │ - 60 const std::vector& Y, │ │ │ │ │ - 61 std::vector >& SX, │ │ │ │ │ - 62 std::vector >& SY, │ │ │ │ │ - 63 std::vector& P); │ │ │ │ │ - 64 │ │ │ │ │ - 74 template │ │ │ │ │ -75 static void orderPoints(const V& centroid, │ │ │ │ │ - 76 const std::vector >& SX, │ │ │ │ │ - 77 const std::vector >& SY, │ │ │ │ │ - 78 const std::vector& P, │ │ │ │ │ - 79 std::vector >& H) │ │ │ │ │ - 80 { │ │ │ │ │ - 81 if (isDim > 1) │ │ │ │ │ - 82 orderPoints_(std::integral_constant(),std:: │ │ │ │ │ -integral_constant(), │ │ │ │ │ - 83 centroid, SX, SY, P,H); │ │ │ │ │ - 84 } │ │ │ │ │ - 85 │ │ │ │ │ - 86private: │ │ │ │ │ - 87 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 88 std::integral_constant, │ │ │ │ │ - 89 const V& centroid, │ │ │ │ │ - 90 const std::vector >& SX, │ │ │ │ │ - 91 const std::vector >& SY, │ │ │ │ │ - 92 const std::vector& P, │ │ │ │ │ - 93 std::vector >& H) {} │ │ │ │ │ - 94 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 95 std::integral_constant, │ │ │ │ │ - 96 const V& centroid, │ │ │ │ │ - 97 const std::vector >& SX, │ │ │ │ │ - 98 const std::vector >& SY, │ │ │ │ │ - 99 const std::vector& P, │ │ │ │ │ - 100 std::vector >& H) {} │ │ │ │ │ - 101 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 102 std::integral_constant, │ │ │ │ │ - 103 const V& centroid, │ │ │ │ │ - 104 const std::vector >& SX, │ │ │ │ │ - 105 const std::vector >& SY, │ │ │ │ │ - 106 const std::vector& P, │ │ │ │ │ - 107 std::vector >& H) {} │ │ │ │ │ - 108 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 109 std::integral_constant, │ │ │ │ │ - 110 const V& centroid, │ │ │ │ │ - 111 const std::vector >& SX, │ │ │ │ │ - 112 const std::vector >& SY, │ │ │ │ │ - 113 const std::vector& P, │ │ │ │ │ - 114 std::vector >& H); │ │ │ │ │ - 115 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 116 std::integral_constant, │ │ │ │ │ - 117 const V& centroid, │ │ │ │ │ - 118 const std::vector >& SX, │ │ │ │ │ - 119 const std::vector >& SY, │ │ │ │ │ - 120 const std::vector& P, │ │ │ │ │ - 121 std::vector >& H); │ │ │ │ │ - 122 static void orderPoints_(std::integral_constant, │ │ │ │ │ - 123 std::integral_constant, │ │ │ │ │ - 124 const V& centroid, │ │ │ │ │ - 125 const std::vector >& SX, │ │ │ │ │ - 126 const std::vector >& SY, │ │ │ │ │ - 127 const std::vector& P, │ │ │ │ │ - 128 std::vector > & H); │ │ │ │ │ - 129 │ │ │ │ │ - 137 static void orderPointsCC(std::integral_constant, │ │ │ │ │ - 138 const V& centroid, │ │ │ │ │ - 139 std::vector &id, │ │ │ │ │ - 140 const std::vector& P); │ │ │ │ │ - 141 static void orderPointsCC(std::integral_constant, │ │ │ │ │ - 142 const V& centroid, │ │ │ │ │ - 143 std::vector &id, │ │ │ │ │ - 144 const std::vector& P); │ │ │ │ │ - 145 │ │ │ │ │ - 150 static void removeDuplicates( std::vector & p); │ │ │ │ │ - 151 │ │ │ │ │ - 159 static bool newFace3D(const std::vector& id, │ │ │ │ │ - 160 const std::vector >& H); │ │ │ │ │ - 161}; │ │ │ │ │ - 162 │ │ │ │ │ - 163template │ │ │ │ │ -164inline int insertPoint(const V p, std::vector& P) │ │ │ │ │ - 165{ │ │ │ │ │ - 166 double eps= 1e-8; // tolerance for identical nodes │ │ │ │ │ - 167 std::size_t k=0 ; │ │ │ │ │ - 168 │ │ │ │ │ - 169 if (P.size()>0) { │ │ │ │ │ - 170 │ │ │ │ │ - 171 while ((keps*(P[k].infinity_norm()) && │ │ │ │ │ - 173 (p - P[k]).infinity_norm()>eps*(p.infinity_norm())) && │ │ │ │ │ - 174 !(p.infinity_norm() < eps && P[k].infinity_norm() =P.size()) │ │ │ │ │ - 179 P.push_back(p) ; // new node is not contained in P │ │ │ │ │ - 180 │ │ │ │ │ - 181 } │ │ │ │ │ - 182 else │ │ │ │ │ - 183 P.push_back(p); │ │ │ │ │ - 184 │ │ │ │ │ - 185 return k ; │ │ │ │ │ - 186} │ │ │ │ │ - 187 │ │ │ │ │ - 188 │ │ │ │ │ - 189} /* namespace Dune::GridGlue */ │ │ │ │ │ - 190} /* namespace Dune */ │ │ │ │ │ - 191 │ │ │ │ │ - 192#include "simplexintersection.cc" │ │ │ │ │ - 193#include "computeintersection.cc" │ │ │ │ │ - 194 │ │ │ │ │ - 195#endif │ │ │ │ │ -computeintersection.cc │ │ │ │ │ -simplexintersection.cc │ │ │ │ │ + 5#ifndef DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ + 6#define DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include │ │ │ │ │ + 9#include │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ + 12 │ │ │ │ │ + 13#include │ │ │ │ │ + 14#include │ │ │ │ │ + 15 │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18 │ │ │ │ │ + 19#include │ │ │ │ │ + 20 │ │ │ │ │ + 21#include │ │ │ │ │ + 22#include │ │ │ │ │ + 23 │ │ │ │ │ + 24namespace Dune { │ │ │ │ │ + 25namespace GridGlue { │ │ │ │ │ + 26 │ │ │ │ │ + 34template │ │ │ │ │ +35class OverlappingMerge │ │ │ │ │ + 36 : public StandardMerge │ │ │ │ │ + 37{ │ │ │ │ │ + 38 │ │ │ │ │ + 39public: │ │ │ │ │ + 40 │ │ │ │ │ + 41 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */ │ │ │ │ │ + 42 │ │ │ │ │ +44 typedef T ctype; │ │ │ │ │ + 45 │ │ │ │ │ +47 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ + 48 │ │ │ │ │ + 50 //typedef Dune::FieldVector LocalCoords; │ │ │ │ │ + 51 │ │ │ │ │ +52 OverlappingMerge() │ │ │ │ │ + 53 {} │ │ │ │ │ + 54 │ │ │ │ │ + 55protected: │ │ │ │ │ +56 typedef typename StandardMerge::SimplicialIntersection │ │ │ │ │ +SimplicialIntersection; │ │ │ │ │ + 57 │ │ │ │ │ + 69 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ + 70 const std::vector >& grid1ElementCorners, │ │ │ │ │ + 71 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ + 72 unsigned int grid1Index, │ │ │ │ │ + 73 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ + 74 const std::vector >& grid2ElementCorners, │ │ │ │ │ + 75 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ + 76 unsigned int grid2Index, │ │ │ │ │ + 77 std::vector& intersections); │ │ │ │ │ + 78 │ │ │ │ │ + 79private: │ │ │ │ │ + 80 bool inPlane(std::vector >& points); │ │ │ │ │ + 81 │ │ │ │ │ + 82}; │ │ │ │ │ + 83 │ │ │ │ │ + 84} /* namespace Dune::GridGlue */ │ │ │ │ │ + 85} /* namespace Dune */ │ │ │ │ │ + 86 │ │ │ │ │ + 87#include "overlappingmerge.cc" │ │ │ │ │ + 88 │ │ │ │ │ + 89 │ │ │ │ │ + 90#endif // DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ +computeintersection.hh │ │ │ │ │ +overlappingmerge.cc │ │ │ │ │ +standardmerge.hh │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::insertPoint │ │ │ │ │ -int insertPoint(const V p, std::vector< V > &P) │ │ │ │ │ -Definition: computeintersection.hh:164 │ │ │ │ │ -Dune::GridGlue::ComputationMethod │ │ │ │ │ -Definition: computeintersection.hh:13 │ │ │ │ │ -Dune::GridGlue::ComputationMethod::grid2_subdivisions │ │ │ │ │ -static void grid2_subdivisions(const std::vector< Vector > elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Dune::GridGlue::ComputationMethod::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< Vector > X, const │ │ │ │ │ -std::vector< Vector > Y, std::vector< std::vector< int > > &SX, std::vector< │ │ │ │ │ -std::vector< int > > &SY, std::vector< Vector > &P) │ │ │ │ │ -Dune::GridGlue::ComputationMethod::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition: computeintersection.hh:15 │ │ │ │ │ -Dune::GridGlue::ComputationMethod::grid1Dimension │ │ │ │ │ -static const int grid1Dimension │ │ │ │ │ -Definition: computeintersection.hh:16 │ │ │ │ │ -Dune::GridGlue::ComputationMethod::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Dune::GridGlue::ComputationMethod::grid2Dimension │ │ │ │ │ -static const int grid2Dimension │ │ │ │ │ -Definition: computeintersection.hh:17 │ │ │ │ │ -Dune::GridGlue::ComputationMethod::intersectionDimension │ │ │ │ │ -static const int intersectionDimension │ │ │ │ │ -Definition: computeintersection.hh:18 │ │ │ │ │ -Dune::GridGlue::IntersectionComputation │ │ │ │ │ -Intersection computation method for two elements of arbitrary dimension. │ │ │ │ │ -Definition: computeintersection.hh:39 │ │ │ │ │ -Dune::GridGlue::IntersectionComputation::orderPoints │ │ │ │ │ -static void orderPoints(const V ¢roid, const std::vector< std::vector< int │ │ │ │ │ -> > &SX, const std::vector< std::vector< int > > &SY, const std::vector< V > │ │ │ │ │ -&P, std::vector< std::vector< int > > &H) │ │ │ │ │ -Order Points in the point list P face-wise such that a subsimplex subdivision │ │ │ │ │ -can be constructed. │ │ │ │ │ -Definition: computeintersection.hh:75 │ │ │ │ │ -Dune::GridGlue::IntersectionComputation::computeIntersection │ │ │ │ │ -static bool computeIntersection(const std::vector< V > &X, const std::vector< V │ │ │ │ │ -> &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > │ │ │ │ │ -&SY, std::vector< V > &P) │ │ │ │ │ -Compute the intersection of two elements X and Y Compute the intersection of │ │ │ │ │ -two elements X and Y,... │ │ │ │ │ -Definition: computeintersection.cc:14 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge │ │ │ │ │ +Computing overlapping grid intersections for grids of different dimensions. │ │ │ │ │ +Definition: overlappingmerge.hh:37 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge::SimplicialIntersection │ │ │ │ │ +StandardMerge< T, dim1, dim2, dimworld >::SimplicialIntersection │ │ │ │ │ +SimplicialIntersection │ │ │ │ │ +Definition: overlappingmerge.hh:56 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge::OverlappingMerge │ │ │ │ │ +OverlappingMerge() │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition: overlappingmerge.hh:52 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge::computeIntersections │ │ │ │ │ +void computeIntersections(const Dune::GeometryType &grid1ElementType, const │ │ │ │ │ +std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std:: │ │ │ │ │ +bitset<(1<< dim1)> &neighborIntersects1, unsigned int grid1Index, const Dune:: │ │ │ │ │ +GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, │ │ │ │ │ +dimworld > > &grid2ElementCorners, std::bitset<(1<< dim2)> │ │ │ │ │ +&neighborIntersects2, unsigned int grid2Index, std::vector< │ │ │ │ │ +SimplicialIntersection > &intersections) │ │ │ │ │ +Compute the intersection between two overlapping elements. │ │ │ │ │ +Definition: overlappingmerge.cc:34 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge::WorldCoords │ │ │ │ │ +Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition: overlappingmerge.hh:47 │ │ │ │ │ +Dune::GridGlue::OverlappingMerge::ctype │ │ │ │ │ +T ctype │ │ │ │ │ +the numeric type used in this interface │ │ │ │ │ +Definition: overlappingmerge.hh:44 │ │ │ │ │ +Dune::GridGlue::StandardMerge │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. │ │ │ │ │ +Definition: standardmerge.hh:58 │ │ │ │ │ +Dune::GridGlue::StandardMerge::SimplicialIntersection │ │ │ │ │ +typename IntersectionListProvider::SimplicialIntersection │ │ │ │ │ +SimplicialIntersection │ │ │ │ │ +Definition: standardmerge.hh:83 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: standardmerge.cc File Reference │ │ │ │ +dune-grid-glue: conformingmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,110 +63,48 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
standardmerge.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
conformingmerge.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include "config.h"
│ │ │ │ -#include "standardmerge.hh"
│ │ │ │ -
│ │ │ │ + │ │ │ │ +

Implementation of the Merger concept for conforming interfaces. │ │ │ │ +More...

│ │ │ │ +
#include <iomanip>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <algorithm>
│ │ │ │ +#include <bitset>
│ │ │ │ +#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/geometry/referenceelements.hh>
│ │ │ │ +#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::GridGlue::ConformingMerge< dim, dimworld, T >
 Implementation of the Merger concept for conforming interfaces. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define DECL
 
#define STANDARD_MERGE_INSTANTIATE(T, A, B, C)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 1, 1, 1)
 
 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 2, 2, 2)
 
 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 3, 3, 3)
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DECL

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DECL
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ STANDARD_MERGE_INSTANTIATE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define STANDARD_MERGE_INSTANTIATE( T,
 A,
 B,
 
)
│ │ │ │ -
│ │ │ │ -Value:
DECL template \
│ │ │ │ -
void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1_coords, \
│ │ │ │ -
const std::vector<unsigned int>& grid1_elements, \
│ │ │ │ -
const std::vector<Dune::GeometryType>& grid1_element_types, \
│ │ │ │ -
const std::vector<Dune::FieldVector<T,C> >& grid2_coords, \
│ │ │ │ -
const std::vector<unsigned int>& grid2_elements, \
│ │ │ │ -
const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │ -
)
│ │ │ │ -
#define DECL
Definition: standardmerge.cc:12
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Implementation of the Merger concept for conforming interfaces.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,53 +5,33 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -standardmerge.cc File Reference │ │ │ │ │ -#include "config.h" │ │ │ │ │ -#include "standardmerge.hh" │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +conformingmerge.hh File Reference │ │ │ │ │ +Implementation of the Merger concept for conforming interfaces. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::GridGlue::ConformingMerge<_dim,_dimworld,_T_> │ │ │ │ │ +  Implementation of the Merger concept for conforming interfaces. More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ - Macros │ │ │ │ │ -#define DECL │ │ │ │ │ -  │ │ │ │ │ -#define STANDARD_MERGE_INSTANTIATE(T, A, B, C) │ │ │ │ │ -  │ │ │ │ │ - Functions │ │ │ │ │ - Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 1, 1, 1) │ │ │ │ │ -  │ │ │ │ │ - Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 2, 2, 2) │ │ │ │ │ -  │ │ │ │ │ - Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 3, 3, 3) │ │ │ │ │ -  │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DECL ***** │ │ │ │ │ -#define DECL │ │ │ │ │ -***** ◆ STANDARD_MERGE_INSTANTIATE ***** │ │ │ │ │ -#define STANDARD_MERGE_INSTANTIATE (  T, │ │ │ │ │ -  A, │ │ │ │ │ -  B, │ │ │ │ │ -  C  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -DECL template \ │ │ │ │ │ -void StandardMerge::build(const std::vector >& │ │ │ │ │ -grid1_coords, \ │ │ │ │ │ -const std::vector& grid1_elements, \ │ │ │ │ │ -const std::vector& grid1_element_types, \ │ │ │ │ │ -const std::vector >& grid2_coords, \ │ │ │ │ │ -const std::vector& grid2_elements, \ │ │ │ │ │ -const std::vector& grid2_element_types \ │ │ │ │ │ -) │ │ │ │ │ -DECL │ │ │ │ │ -#define DECL │ │ │ │ │ -Definition: standardmerge.cc:12 │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Implementation of the Merger concept for conforming interfaces. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.hh File Reference │ │ │ │ +dune-grid-glue: merger.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,54 +65,37 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
contactmerge.hh File Reference
│ │ │ │ +
merger.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Merge two grid boundary surfaces that may be a positive distance apart. │ │ │ │ -More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <fstream>
│ │ │ │ -#include <iomanip>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <limits>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <functional>
│ │ │ │ +
#include <vector>
│ │ │ │ #include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/bitsetvector.hh>
│ │ │ │ -#include <dune/common/deprecated.hh>
│ │ │ │ -#include <dune/grid/common/grid.hh>
│ │ │ │ -#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ -#include <dune/grid-glue/gridglue.hh>
│ │ │ │ -#include "contactmerge.cc"
│ │ │ │ +#include <dune/geometry/type.hh>
│ │ │ │ +#include <dune/grid-glue/merging/intersectionlist.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::ContactMerge< dimworld, T >
 Merge two codimension-1 surfaces that may be a positive distance apart. More...
class  Dune::GridGlue::Merger< ctype, grid1Dim, grid2Dim, dimworld >
 Abstract base for all classes that take extracted grids and build sets of intersections. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Merge two grid boundary surfaces that may be a positive distance apart.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,41 +6,26 @@ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -contactmerge.hh File Reference │ │ │ │ │ -Merge two grid boundary surfaces that may be a positive distance apart. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +merger.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "contactmerge.cc" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::GridGlue::ContactMerge<_dimworld,_T_> │ │ │ │ │ -  Merge two codimension-1 surfaces that may be a positive distance apart. │ │ │ │ │ - More... │ │ │ │ │ +class  Dune::GridGlue::Merger<_ctype,_grid1Dim,_grid2Dim,_dimworld_> │ │ │ │ │ +  Abstract base for all classes that take extracted grids and build sets │ │ │ │ │ + of intersections. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Merge two grid boundary surfaces that may be a positive distance apart. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.hh Source File │ │ │ │ +dune-grid-glue: merger.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,217 +62,101 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
contactmerge.hh
│ │ │ │ +
merger.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
10#ifndef DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │ -
11#define DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │ +
5#ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH
│ │ │ │ +
6#define DUNE_GRIDGLUE_MERGING_MERGER_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <vector>
│ │ │ │ +
9
│ │ │ │ +
10#include <dune/common/fvector.hh>
│ │ │ │ +
11#include <dune/geometry/type.hh>
│ │ │ │
12
│ │ │ │ -
13
│ │ │ │ -
14#include <iostream>
│ │ │ │ -
15#include <fstream>
│ │ │ │ -
16#include <iomanip>
│ │ │ │ -
17#include <vector>
│ │ │ │ -
18#include <algorithm>
│ │ │ │ -
19#include <limits>
│ │ │ │ -
20#include <memory>
│ │ │ │ -
21#include <functional>
│ │ │ │ -
22
│ │ │ │ -
23#include <dune/common/fvector.hh>
│ │ │ │ -
24#include <dune/common/exceptions.hh>
│ │ │ │ -
25#include <dune/common/bitsetvector.hh>
│ │ │ │ -
26#include <dune/common/deprecated.hh>
│ │ │ │ -
27
│ │ │ │ -
28#include <dune/grid/common/grid.hh>
│ │ │ │ + │ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16namespace GridGlue {
│ │ │ │ +
17
│ │ │ │ +
25template <class ctype, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
26class Merger
│ │ │ │ +
27{
│ │ │ │ +
28public:
│ │ │ │
29
│ │ │ │ - │ │ │ │ - │ │ │ │ +
31 typedef Dune::FieldVector<ctype, grid1Dim> Grid1Coords;
│ │ │ │
32
│ │ │ │ -
33namespace Dune {
│ │ │ │ -
34namespace GridGlue {
│ │ │ │ +
34 typedef Dune::FieldVector<ctype, grid2Dim> Grid2Coords;
│ │ │ │
35
│ │ │ │ -
41template<int dimworld, typename T = double>
│ │ │ │ - │ │ │ │ -
43: public StandardMerge<T,dimworld-1,dimworld-1,dimworld>
│ │ │ │ -
44{
│ │ │ │ -
45 static constexpr int dim = dimworld-1;
│ │ │ │ -
46
│ │ │ │ -
47 static_assert( dim==1 || dim==2,
│ │ │ │ -
48 "ContactMerge yet only handles the cases dim==1 and dim==2!");
│ │ │ │ -
49
│ │ │ │ - │ │ │ │ -
51public:
│ │ │ │ -
52
│ │ │ │ -
53 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */
│ │ │ │ -
54
│ │ │ │ -
56 typedef T ctype;
│ │ │ │ -
57
│ │ │ │ -
59 typedef Dune::FieldVector<T, dimworld> WorldCoords;
│ │ │ │ +
37 typedef Dune::FieldVector<ctype, dimworld> WorldCoords;
│ │ │ │ +
38
│ │ │ │ + │ │ │ │ +
40
│ │ │ │ +
54 virtual void build(const std::vector<Dune::FieldVector<ctype,dimworld> >& grid1_coords,
│ │ │ │ +
55 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
56 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
57 const std::vector<Dune::FieldVector<ctype,dimworld> >& grid2_coords,
│ │ │ │ +
58 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
59 const std::vector<Dune::GeometryType>& grid2_element_types) = 0;
│ │ │ │
60
│ │ │ │ -
62 typedef Dune::FieldVector<T, dim> LocalCoords;
│ │ │ │ -
63
│ │ │ │ - │ │ │ │ -
73 ContactMerge(const T allowedOverlap=T(0),
│ │ │ │ -
74 std::function<WorldCoords(WorldCoords)> domainDirections=nullptr,
│ │ │ │ -
75 std::function<WorldCoords(WorldCoords)> targetDirections=nullptr,
│ │ │ │ - │ │ │ │ -
77 : domainDirections_(domainDirections), targetDirections_(targetDirections),
│ │ │ │ -
78 overlap_(allowedOverlap), type_(type)
│ │ │ │ -
79 {}
│ │ │ │ -
80
│ │ │ │ -
86 ContactMerge(const T allowedOverlap, ProjectionType type)
│ │ │ │ -
87 : overlap_(allowedOverlap),
│ │ │ │ -
88 type_(type)
│ │ │ │ -
89 {}
│ │ │ │ -
90
│ │ │ │ -
99 inline
│ │ │ │ -
100 void setSurfaceDirections(std::function<WorldCoords(WorldCoords)> domainDirections,
│ │ │ │ -
101 std::function<WorldCoords(WorldCoords)> targetDirections)
│ │ │ │ -
102 {
│ │ │ │ -
103 domainDirections_ = domainDirections;
│ │ │ │ -
104 targetDirections_ = targetDirections;
│ │ │ │ -
105 this->valid = false;
│ │ │ │ -
106 }
│ │ │ │ -
107
│ │ │ │ -
109 void setOverlap(T overlap)
│ │ │ │ -
110 {
│ │ │ │ -
111 overlap_ = overlap;
│ │ │ │ -
112 }
│ │ │ │ -
113
│ │ │ │ -
115 T getOverlap() const
│ │ │ │ -
116 {
│ │ │ │ -
117 return overlap_;
│ │ │ │ -
118 }
│ │ │ │ +
64 unsigned int nSimplices() const
│ │ │ │ +
65 { return intersectionList()->size(); }
│ │ │ │ +
66
│ │ │ │ +
67 virtual void clear() = 0;
│ │ │ │ +
68
│ │ │ │ +
74 virtual std::shared_ptr<IntersectionList> intersectionList() const = 0;
│ │ │ │ +
75
│ │ │ │ +
79 template<int n>
│ │ │ │ +
80 unsigned int parents(unsigned int idx) const {
│ │ │ │ +
81 return intersectionList()->template parents<n>(idx);
│ │ │ │ +
82 }
│ │ │ │ +
83
│ │ │ │ +
90 template<int n>
│ │ │ │ +
91 unsigned int parent(unsigned int idx, unsigned int parId = 0) const
│ │ │ │ +
92 {
│ │ │ │ +
93 return intersectionList()->template parent<n>(idx, parId);
│ │ │ │ +
94 }
│ │ │ │ +
95
│ │ │ │ +
104 template<int n>
│ │ │ │ +
105 auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId = 0) const
│ │ │ │ +
106 {
│ │ │ │ +
107 return intersectionList()->template corner<n>(idx, corner, parId);
│ │ │ │ +
108 }
│ │ │ │ +
109
│ │ │ │ +
114 unsigned int counter;
│ │ │ │ +
115};
│ │ │ │ +
116
│ │ │ │ +
117} /* namespace GridGlue */
│ │ │ │ +
118} /* namespace Dune */
│ │ │ │
119
│ │ │ │ -
123 void minNormalAngle(T angle)
│ │ │ │ -
124 {
│ │ │ │ -
125 using std::cos;
│ │ │ │ -
126 maxNormalProduct_ = cos(angle);
│ │ │ │ -
127 }
│ │ │ │ -
128
│ │ │ │ - │ │ │ │ -
133 {
│ │ │ │ -
134 using std::acos;
│ │ │ │ -
135 return acos(maxNormalProduct_);
│ │ │ │ -
136 }
│ │ │ │ -
137
│ │ │ │ -
138protected:
│ │ │ │ -
139 typedef typename StandardMerge<T,dimworld-1,dimworld-1,dimworld>::SimplicialIntersection SimplicialIntersection;
│ │ │ │ -
140
│ │ │ │ -
141private:
│ │ │ │ -
145 std::function<WorldCoords(WorldCoords)> domainDirections_;
│ │ │ │ -
146 std::vector<WorldCoords> nodalDomainDirections_;
│ │ │ │ -
147
│ │ │ │ -
156 std::function<WorldCoords(WorldCoords)> targetDirections_;
│ │ │ │ -
157 std::vector<WorldCoords> nodalTargetDirections_;
│ │ │ │ -
158
│ │ │ │ -
160 T overlap_;
│ │ │ │ -
161
│ │ │ │ -
163 ProjectionType type_;
│ │ │ │ -
164
│ │ │ │ -
168 T maxNormalProduct_ = T(-0.1);
│ │ │ │ -
169
│ │ │ │ -
174 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
175 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
176 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ -
177 unsigned int grid1Index,
│ │ │ │ -
178 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
179 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
180 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ -
181 unsigned int grid2Index,
│ │ │ │ -
182 std::vector<SimplicialIntersection>& intersections) override;
│ │ │ │ -
183
│ │ │ │ -
187protected:
│ │ │ │ -
188 void build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
189 const std::vector<unsigned int>& grid1Elements,
│ │ │ │ -
190 const std::vector<Dune::GeometryType>& grid1ElementTypes,
│ │ │ │ -
191 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
192 const std::vector<unsigned int>& grid2Elements,
│ │ │ │ -
193 const std::vector<Dune::GeometryType>& grid2ElementTypes) override
│ │ │ │ -
194 {
│ │ │ │ -
195 std::cout<<"ContactMerge building grid!\n";
│ │ │ │ -
196 // setup the nodal direction vectors
│ │ │ │ -
197 setupNodalDirections(grid1Coords, grid1Elements, grid1ElementTypes,
│ │ │ │ -
198 grid2Coords, grid2Elements, grid2ElementTypes);
│ │ │ │ -
199
│ │ │ │ -
200 Base::build(grid1Coords, grid1Elements, grid1ElementTypes,
│ │ │ │ -
201 grid2Coords, grid2Elements, grid2ElementTypes);
│ │ │ │ -
202
│ │ │ │ -
203 }
│ │ │ │ -
204
│ │ │ │ -
205private:
│ │ │ │ -
206
│ │ │ │ -
208 static LocalCoords localCornerCoords(int i, const Dune::GeometryType& gt)
│ │ │ │ -
209 {
│ │ │ │ -
210 const auto& ref = Dune::ReferenceElements<T,dim>::general(gt);
│ │ │ │ -
211 return ref.position(i,dim);
│ │ │ │ -
212 }
│ │ │ │ -
213
│ │ │ │ -
214protected:
│ │ │ │ -
215
│ │ │ │ -
217 void computeCyclicOrder(const std::vector<std::array<LocalCoords,2> >& polytopeCorners,
│ │ │ │ -
218 const LocalCoords& center, std::vector<int>& ordering) const;
│ │ │ │ -
219
│ │ │ │ -
221 void setupNodalDirections(const std::vector<WorldCoords>& coords1,
│ │ │ │ -
222 const std::vector<unsigned int>& elements1,
│ │ │ │ -
223 const std::vector<Dune::GeometryType>& elementTypes1,
│ │ │ │ -
224 const std::vector<WorldCoords>& coords2,
│ │ │ │ -
225 const std::vector<unsigned int>& elements2,
│ │ │ │ -
226 const std::vector<Dune::GeometryType>& elementTypes2);
│ │ │ │ -
227
│ │ │ │ -
229 void computeOuterNormalField(const std::vector<WorldCoords>& coords,
│ │ │ │ -
230 const std::vector<unsigned int>& elements,
│ │ │ │ -
231 const std::vector<Dune::GeometryType>& elementTypes,
│ │ │ │ -
232 std::vector<WorldCoords>& normals);
│ │ │ │ -
233
│ │ │ │ -
235 void removeDoubles(std::vector<std::array<LocalCoords,2> >& polytopeCorners);
│ │ │ │ -
236};
│ │ │ │ -
237
│ │ │ │ -
238} /* namespace GridGlue */
│ │ │ │ -
239} /* namespace Dune */
│ │ │ │ -
240
│ │ │ │ -
241#include "contactmerge.cc"
│ │ │ │ -
242
│ │ │ │ -
243#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │ -
Central component of the module implementing the coupling of two grids.
│ │ │ │ - │ │ │ │ -
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │ +
120#endif
│ │ │ │ + │ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
Merge two codimension-1 surfaces that may be a positive distance apart.
Definition: contactmerge.hh:44
│ │ │ │ -
void computeCyclicOrder(const std::vector< std::array< LocalCoords, 2 > > &polytopeCorners, const LocalCoords &center, std::vector< int > &ordering) const
Order the corners of the intersection polytope in cyclic order.
Definition: contactmerge.cc:214
│ │ │ │ -
StandardMerge< T, dimworld-1, dimworld-1, dimworld >::SimplicialIntersection SimplicialIntersection
Definition: contactmerge.hh:139
│ │ │ │ -
void removeDoubles(std::vector< std::array< LocalCoords, 2 > > &polytopeCorners)
Remove all multiples.
Definition: contactmerge.cc:335
│ │ │ │ -
void setOverlap(T overlap)
Set the allowed overlap of the surfaces.
Definition: contactmerge.hh:109
│ │ │ │ -
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: contactmerge.hh:59
│ │ │ │ -
void setupNodalDirections(const std::vector< WorldCoords > &coords1, const std::vector< unsigned int > &elements1, const std::vector< Dune::GeometryType > &elementTypes1, const std::vector< WorldCoords > &coords2, const std::vector< unsigned int > &elements2, const std::vector< Dune::GeometryType > &elementTypes2)
Setup the direction vectors containing the directions for each vertex.
Definition: contactmerge.cc:269
│ │ │ │ -
void minNormalAngle(T angle)
set minimum angle in radians between normals at x and Φ(x)
Definition: contactmerge.hh:123
│ │ │ │ -
T ctype
the numeric type used in this interface
Definition: contactmerge.hh:56
│ │ │ │ -
ProjectionType
Type of the projection, closest point or outer normal projection.
Definition: contactmerge.hh:65
│ │ │ │ -
@ CLOSEST_POINT
Definition: contactmerge.hh:65
│ │ │ │ -
@ OUTER_NORMAL
Definition: contactmerge.hh:65
│ │ │ │ -
void computeOuterNormalField(const std::vector< WorldCoords > &coords, const std::vector< unsigned int > &elements, const std::vector< Dune::GeometryType > &elementTypes, std::vector< WorldCoords > &normals)
If no direction field was specified compute the outer normal field.
Definition: contactmerge.cc:296
│ │ │ │ -
T getOverlap() const
Get the allowed overlap of the surfaces.
Definition: contactmerge.hh:115
│ │ │ │ -
ContactMerge(const T allowedOverlap=T(0), std::function< WorldCoords(WorldCoords)> domainDirections=nullptr, std::function< WorldCoords(WorldCoords)> targetDirections=nullptr, ProjectionType type=OUTER_NORMAL)
Construct merger given overlap and possible projection directions.
Definition: contactmerge.hh:73
│ │ │ │ -
void setSurfaceDirections(std::function< WorldCoords(WorldCoords)> domainDirections, std::function< WorldCoords(WorldCoords)> targetDirections)
Set surface direction functions.
Definition: contactmerge.hh:100
│ │ │ │ -
void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std::vector< unsigned int > &grid1Elements, const std::vector< Dune::GeometryType > &grid1ElementTypes, const std::vector< Dune::FieldVector< T, dimworld > > &grid2Coords, const std::vector< unsigned int > &grid2Elements, const std::vector< Dune::GeometryType > &grid2ElementTypes) override
builds the merged grid
Definition: contactmerge.hh:188
│ │ │ │ -
ContactMerge(const T allowedOverlap, ProjectionType type)
Construct merger given overlap and type of the projection.
Definition: contactmerge.hh:86
│ │ │ │ -
T minNormalAngle() const
get minimum angle in radians between normals at x and Φ(x)
Definition: contactmerge.hh:132
│ │ │ │ -
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition: contactmerge.hh:62
│ │ │ │ -
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition: standardmerge.hh:58
│ │ │ │ -
void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1_Coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< T, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types) override
builds the merged grid
Definition: standardmerge.hh:392
│ │ │ │ - │ │ │ │ +
Coordinate corner(unsigned c)
Definition: projection_impl.hh:24
│ │ │ │ +
Definition: intersectionlist.hh:134
│ │ │ │ +
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:27
│ │ │ │ +
unsigned int parent(unsigned int idx, unsigned int parId=0) const
get index of grid-n's parent simplex for given merged grid simplex
Definition: merger.hh:91
│ │ │ │ +
virtual void clear()=0
│ │ │ │ +
Dune::FieldVector< ctype, dimworld > WorldCoords
the coordinate type used in this interface
Definition: merger.hh:37
│ │ │ │ +
Dune::FieldVector< ctype, grid1Dim > Grid1Coords
the local coordinate type for the grid1 coordinates
Definition: merger.hh:31
│ │ │ │ +
unsigned int counter
Counts the number of times the computeIntersection method has been called.
Definition: merger.hh:114
│ │ │ │ +
auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId=0) const
get the grid-n parent's simplex local coordinates for a particular merged grid simplex corner (parent...
Definition: merger.hh:105
│ │ │ │ +
virtual void build(const std::vector< Dune::FieldVector< ctype, dimworld > > &grid1_coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< ctype, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types)=0
builds the merged grid
│ │ │ │ +
unsigned int nSimplices() const
get the number of simplices in the merged grid The indices are then in 0..nSimplices()-1
Definition: merger.hh:64
│ │ │ │ +
virtual std::shared_ptr< IntersectionList > intersectionList() const =0
│ │ │ │ +
unsigned int parents(unsigned int idx) const
Definition: merger.hh:80
│ │ │ │ +
Dune::FieldVector< ctype, grid2Dim > Grid2Coords
the local coordinate type for the grid2 coordinates
Definition: merger.hh:34
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,308 +5,143 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -contactmerge.hh │ │ │ │ │ +merger.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 10#ifndef DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ - 11#define DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ + 5#ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ + 6#define DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ + 7 │ │ │ │ │ + 8#include │ │ │ │ │ + 9 │ │ │ │ │ + 10#include │ │ │ │ │ + 11#include │ │ │ │ │ 12 │ │ │ │ │ - 13 │ │ │ │ │ - 14#include │ │ │ │ │ - 15#include │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18#include │ │ │ │ │ - 19#include │ │ │ │ │ - 20#include │ │ │ │ │ - 21#include │ │ │ │ │ - 22 │ │ │ │ │ - 23#include │ │ │ │ │ - 24#include │ │ │ │ │ - 25#include │ │ │ │ │ - 26#include │ │ │ │ │ - 27 │ │ │ │ │ - 28#include │ │ │ │ │ + 13#include │ │ │ │ │ + 14 │ │ │ │ │ + 15namespace Dune { │ │ │ │ │ + 16namespace GridGlue { │ │ │ │ │ + 17 │ │ │ │ │ + 25template │ │ │ │ │ +26class Merger │ │ │ │ │ + 27{ │ │ │ │ │ + 28public: │ │ │ │ │ 29 │ │ │ │ │ - 30#include │ │ │ │ │ - 31#include │ │ │ │ │ +31 typedef Dune::FieldVector Grid1Coords; │ │ │ │ │ 32 │ │ │ │ │ - 33namespace Dune { │ │ │ │ │ - 34namespace GridGlue { │ │ │ │ │ +34 typedef Dune::FieldVector Grid2Coords; │ │ │ │ │ 35 │ │ │ │ │ - 41template │ │ │ │ │ -42class ContactMerge │ │ │ │ │ - 43: public StandardMerge │ │ │ │ │ - 44{ │ │ │ │ │ - 45 static constexpr int dim = dimworld-1; │ │ │ │ │ - 46 │ │ │ │ │ - 47 static_assert( dim==1 || dim==2, │ │ │ │ │ - 48 "ContactMerge yet only handles the cases dim==1 and dim==2!"); │ │ │ │ │ - 49 │ │ │ │ │ - 50 typedef StandardMerge Base; │ │ │ │ │ - 51public: │ │ │ │ │ - 52 │ │ │ │ │ - 53 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */ │ │ │ │ │ - 54 │ │ │ │ │ -56 typedef T ctype; │ │ │ │ │ - 57 │ │ │ │ │ -59 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ +37 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ + 38 │ │ │ │ │ +39 using IntersectionList = Dune::GridGlue::IntersectionList; │ │ │ │ │ + 40 │ │ │ │ │ +54 virtual void build(const std::vector >& │ │ │ │ │ +grid1_coords, │ │ │ │ │ + 55 const std::vector& grid1_elements, │ │ │ │ │ + 56 const std::vector& grid1_element_types, │ │ │ │ │ + 57 const std::vector >& grid2_coords, │ │ │ │ │ + 58 const std::vector& grid2_elements, │ │ │ │ │ + 59 const std::vector& grid2_element_types) = 0; │ │ │ │ │ 60 │ │ │ │ │ -62 typedef Dune::FieldVector LocalCoords; │ │ │ │ │ - 63 │ │ │ │ │ -65 enum ProjectionType {OUTER_NORMAL, CLOSEST_POINT}; │ │ │ │ │ -73 ContactMerge(const T allowedOverlap=T(0), │ │ │ │ │ - 74 std::function domainDirections=nullptr, │ │ │ │ │ - 75 std::function targetDirections=nullptr, │ │ │ │ │ - 76 ProjectionType type = OUTER_NORMAL) │ │ │ │ │ - 77 : domainDirections_(domainDirections), targetDirections_(targetDirections), │ │ │ │ │ - 78 overlap_(allowedOverlap), type_(type) │ │ │ │ │ - 79 {} │ │ │ │ │ - 80 │ │ │ │ │ -86 ContactMerge(const T allowedOverlap, ProjectionType type) │ │ │ │ │ - 87 : overlap_(allowedOverlap), │ │ │ │ │ - 88 type_(type) │ │ │ │ │ - 89 {} │ │ │ │ │ - 90 │ │ │ │ │ - 99 inline │ │ │ │ │ -100 void setSurfaceDirections(std::function │ │ │ │ │ -domainDirections, │ │ │ │ │ - 101 std::function targetDirections) │ │ │ │ │ - 102 { │ │ │ │ │ - 103 domainDirections_ = domainDirections; │ │ │ │ │ - 104 targetDirections_ = targetDirections; │ │ │ │ │ - 105 this->valid = false; │ │ │ │ │ - 106 } │ │ │ │ │ - 107 │ │ │ │ │ -109 void setOverlap(T overlap) │ │ │ │ │ - 110 { │ │ │ │ │ - 111 overlap_ = overlap; │ │ │ │ │ - 112 } │ │ │ │ │ - 113 │ │ │ │ │ -115 T getOverlap() const │ │ │ │ │ - 116 { │ │ │ │ │ - 117 return overlap_; │ │ │ │ │ - 118 } │ │ │ │ │ +64 unsigned int nSimplices() const │ │ │ │ │ + 65 { return intersectionList()->size(); } │ │ │ │ │ + 66 │ │ │ │ │ +67 virtual void clear() = 0; │ │ │ │ │ + 68 │ │ │ │ │ +74 virtual std::shared_ptr intersectionList() const = 0; │ │ │ │ │ + 75 │ │ │ │ │ + 79 template │ │ │ │ │ +80 unsigned int parents(unsigned int idx) const { │ │ │ │ │ + 81 return intersectionList()->template parents(idx); │ │ │ │ │ + 82 } │ │ │ │ │ + 83 │ │ │ │ │ + 90 template │ │ │ │ │ +91 unsigned int parent(unsigned int idx, unsigned int parId = 0) const │ │ │ │ │ + 92 { │ │ │ │ │ + 93 return intersectionList()->template parent(idx, parId); │ │ │ │ │ + 94 } │ │ │ │ │ + 95 │ │ │ │ │ + 104 template │ │ │ │ │ +105 auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId │ │ │ │ │ += 0) const │ │ │ │ │ + 106 { │ │ │ │ │ + 107 return intersectionList()->template corner(idx, corner, parId); │ │ │ │ │ + 108 } │ │ │ │ │ + 109 │ │ │ │ │ +114 unsigned int counter; │ │ │ │ │ + 115}; │ │ │ │ │ + 116 │ │ │ │ │ + 117} /* namespace GridGlue */ │ │ │ │ │ + 118} /* namespace Dune */ │ │ │ │ │ 119 │ │ │ │ │ -123 void minNormalAngle(T angle) │ │ │ │ │ - 124 { │ │ │ │ │ - 125 using std::cos; │ │ │ │ │ - 126 maxNormalProduct_ = cos(angle); │ │ │ │ │ - 127 } │ │ │ │ │ - 128 │ │ │ │ │ -132 T minNormalAngle() const │ │ │ │ │ - 133 { │ │ │ │ │ - 134 using std::acos; │ │ │ │ │ - 135 return acos(maxNormalProduct_); │ │ │ │ │ - 136 } │ │ │ │ │ - 137 │ │ │ │ │ - 138protected: │ │ │ │ │ -139 typedef typename StandardMerge:: │ │ │ │ │ -SimplicialIntersection SimplicialIntersection; │ │ │ │ │ - 140 │ │ │ │ │ - 141private: │ │ │ │ │ - 145 std::function domainDirections_; │ │ │ │ │ - 146 std::vector nodalDomainDirections_; │ │ │ │ │ - 147 │ │ │ │ │ - 156 std::function targetDirections_; │ │ │ │ │ - 157 std::vector nodalTargetDirections_; │ │ │ │ │ - 158 │ │ │ │ │ - 160 T overlap_; │ │ │ │ │ - 161 │ │ │ │ │ - 163 ProjectionType type_; │ │ │ │ │ - 164 │ │ │ │ │ - 168 T maxNormalProduct_ = T(-0.1); │ │ │ │ │ - 169 │ │ │ │ │ - 174 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ - 175 const std::vector >& grid1ElementCorners, │ │ │ │ │ - 176 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ - 177 unsigned int grid1Index, │ │ │ │ │ - 178 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ - 179 const std::vector >& grid2ElementCorners, │ │ │ │ │ - 180 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ - 181 unsigned int grid2Index, │ │ │ │ │ - 182 std::vector& intersections) override; │ │ │ │ │ - 183 │ │ │ │ │ - 187protected: │ │ │ │ │ -188 void build(const std::vector >& grid1Coords, │ │ │ │ │ - 189 const std::vector& grid1Elements, │ │ │ │ │ - 190 const std::vector& grid1ElementTypes, │ │ │ │ │ - 191 const std::vector >& grid2Coords, │ │ │ │ │ - 192 const std::vector& grid2Elements, │ │ │ │ │ - 193 const std::vector& grid2ElementTypes) override │ │ │ │ │ - 194 { │ │ │ │ │ - 195 std::cout<<"ContactMerge building grid!\n"; │ │ │ │ │ - 196 // setup the nodal direction vectors │ │ │ │ │ - 197 setupNodalDirections(grid1Coords, grid1Elements, grid1ElementTypes, │ │ │ │ │ - 198 grid2Coords, grid2Elements, grid2ElementTypes); │ │ │ │ │ - 199 │ │ │ │ │ - 200 Base::build(grid1Coords, grid1Elements, grid1ElementTypes, │ │ │ │ │ - 201 grid2Coords, grid2Elements, grid2ElementTypes); │ │ │ │ │ - 202 │ │ │ │ │ - 203 } │ │ │ │ │ - 204 │ │ │ │ │ - 205private: │ │ │ │ │ - 206 │ │ │ │ │ - 208 static LocalCoords localCornerCoords(int i, const Dune::GeometryType& gt) │ │ │ │ │ - 209 { │ │ │ │ │ - 210 const auto& ref = Dune::ReferenceElements::general(gt); │ │ │ │ │ - 211 return ref.position(i,dim); │ │ │ │ │ - 212 } │ │ │ │ │ - 213 │ │ │ │ │ - 214protected: │ │ │ │ │ - 215 │ │ │ │ │ - 217 void computeCyclicOrder(const std::vector >& │ │ │ │ │ -polytopeCorners, │ │ │ │ │ - 218 const LocalCoords& center, std::vector& ordering) const; │ │ │ │ │ - 219 │ │ │ │ │ - 221 void setupNodalDirections(const std::vector& coords1, │ │ │ │ │ - 222 const std::vector& elements1, │ │ │ │ │ - 223 const std::vector& elementTypes1, │ │ │ │ │ - 224 const std::vector& coords2, │ │ │ │ │ - 225 const std::vector& elements2, │ │ │ │ │ - 226 const std::vector& elementTypes2); │ │ │ │ │ - 227 │ │ │ │ │ - 229 void computeOuterNormalField(const std::vector& coords, │ │ │ │ │ - 230 const std::vector& elements, │ │ │ │ │ - 231 const std::vector& elementTypes, │ │ │ │ │ - 232 std::vector& normals); │ │ │ │ │ - 233 │ │ │ │ │ - 235 void removeDoubles(std::vector >& │ │ │ │ │ -polytopeCorners); │ │ │ │ │ - 236}; │ │ │ │ │ - 237 │ │ │ │ │ - 238} /* namespace GridGlue */ │ │ │ │ │ - 239} /* namespace Dune */ │ │ │ │ │ - 240 │ │ │ │ │ - 241#include "contactmerge.cc" │ │ │ │ │ - 242 │ │ │ │ │ - 243#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ -gridglue.hh │ │ │ │ │ -Central component of the module implementing the coupling of two grids. │ │ │ │ │ -contactmerge.cc │ │ │ │ │ -standardmerge.hh │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ + 120#endif │ │ │ │ │ +intersectionlist.hh │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::ContactMerge │ │ │ │ │ -Merge two codimension-1 surfaces that may be a positive distance apart. │ │ │ │ │ -Definition: contactmerge.hh:44 │ │ │ │ │ -Dune::GridGlue::ContactMerge::computeCyclicOrder │ │ │ │ │ -void computeCyclicOrder(const std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ -&polytopeCorners, const LocalCoords ¢er, std::vector< int > &ordering) │ │ │ │ │ -const │ │ │ │ │ -Order the corners of the intersection polytope in cyclic order. │ │ │ │ │ -Definition: contactmerge.cc:214 │ │ │ │ │ -Dune::GridGlue::ContactMerge::SimplicialIntersection │ │ │ │ │ -StandardMerge< T, dimworld-1, dimworld-1, dimworld >::SimplicialIntersection │ │ │ │ │ -SimplicialIntersection │ │ │ │ │ -Definition: contactmerge.hh:139 │ │ │ │ │ -Dune::GridGlue::ContactMerge::removeDoubles │ │ │ │ │ -void removeDoubles(std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ -&polytopeCorners) │ │ │ │ │ -Remove all multiples. │ │ │ │ │ -Definition: contactmerge.cc:335 │ │ │ │ │ -Dune::GridGlue::ContactMerge::setOverlap │ │ │ │ │ -void setOverlap(T overlap) │ │ │ │ │ -Set the allowed overlap of the surfaces. │ │ │ │ │ -Definition: contactmerge.hh:109 │ │ │ │ │ -Dune::GridGlue::ContactMerge::WorldCoords │ │ │ │ │ -Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition: contactmerge.hh:59 │ │ │ │ │ -Dune::GridGlue::ContactMerge::setupNodalDirections │ │ │ │ │ -void setupNodalDirections(const std::vector< WorldCoords > &coords1, const │ │ │ │ │ -std::vector< unsigned int > &elements1, const std::vector< Dune::GeometryType > │ │ │ │ │ -&elementTypes1, const std::vector< WorldCoords > &coords2, const std::vector< │ │ │ │ │ -unsigned int > &elements2, const std::vector< Dune::GeometryType > │ │ │ │ │ -&elementTypes2) │ │ │ │ │ -Setup the direction vectors containing the directions for each vertex. │ │ │ │ │ -Definition: contactmerge.cc:269 │ │ │ │ │ -Dune::GridGlue::ContactMerge::minNormalAngle │ │ │ │ │ -void minNormalAngle(T angle) │ │ │ │ │ -set minimum angle in radians between normals at x and Φ(x) │ │ │ │ │ -Definition: contactmerge.hh:123 │ │ │ │ │ -Dune::GridGlue::ContactMerge::ctype │ │ │ │ │ -T ctype │ │ │ │ │ -the numeric type used in this interface │ │ │ │ │ -Definition: contactmerge.hh:56 │ │ │ │ │ -Dune::GridGlue::ContactMerge::ProjectionType │ │ │ │ │ -ProjectionType │ │ │ │ │ -Type of the projection, closest point or outer normal projection. │ │ │ │ │ -Definition: contactmerge.hh:65 │ │ │ │ │ -Dune::GridGlue::ContactMerge::CLOSEST_POINT │ │ │ │ │ -@ CLOSEST_POINT │ │ │ │ │ -Definition: contactmerge.hh:65 │ │ │ │ │ -Dune::GridGlue::ContactMerge::OUTER_NORMAL │ │ │ │ │ -@ OUTER_NORMAL │ │ │ │ │ -Definition: contactmerge.hh:65 │ │ │ │ │ -Dune::GridGlue::ContactMerge::computeOuterNormalField │ │ │ │ │ -void computeOuterNormalField(const std::vector< WorldCoords > &coords, const │ │ │ │ │ -std::vector< unsigned int > &elements, const std::vector< Dune::GeometryType > │ │ │ │ │ -&elementTypes, std::vector< WorldCoords > &normals) │ │ │ │ │ -If no direction field was specified compute the outer normal field. │ │ │ │ │ -Definition: contactmerge.cc:296 │ │ │ │ │ -Dune::GridGlue::ContactMerge::getOverlap │ │ │ │ │ -T getOverlap() const │ │ │ │ │ -Get the allowed overlap of the surfaces. │ │ │ │ │ -Definition: contactmerge.hh:115 │ │ │ │ │ -Dune::GridGlue::ContactMerge::ContactMerge │ │ │ │ │ -ContactMerge(const T allowedOverlap=T(0), std::function< WorldCoords │ │ │ │ │ -(WorldCoords)> domainDirections=nullptr, std::function< WorldCoords │ │ │ │ │ -(WorldCoords)> targetDirections=nullptr, ProjectionType type=OUTER_NORMAL) │ │ │ │ │ -Construct merger given overlap and possible projection directions. │ │ │ │ │ -Definition: contactmerge.hh:73 │ │ │ │ │ -Dune::GridGlue::ContactMerge::setSurfaceDirections │ │ │ │ │ -void setSurfaceDirections(std::function< WorldCoords(WorldCoords)> │ │ │ │ │ -domainDirections, std::function< WorldCoords(WorldCoords)> targetDirections) │ │ │ │ │ -Set surface direction functions. │ │ │ │ │ -Definition: contactmerge.hh:100 │ │ │ │ │ -Dune::GridGlue::ContactMerge::build │ │ │ │ │ -void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, │ │ │ │ │ -const std::vector< unsigned int > &grid1Elements, const std::vector< Dune:: │ │ │ │ │ -GeometryType > &grid1ElementTypes, const std::vector< Dune::FieldVector< T, │ │ │ │ │ -dimworld > > &grid2Coords, const std::vector< unsigned int > &grid2Elements, │ │ │ │ │ -const std::vector< Dune::GeometryType > &grid2ElementTypes) override │ │ │ │ │ -builds the merged grid │ │ │ │ │ -Definition: contactmerge.hh:188 │ │ │ │ │ -Dune::GridGlue::ContactMerge::ContactMerge │ │ │ │ │ -ContactMerge(const T allowedOverlap, ProjectionType type) │ │ │ │ │ -Construct merger given overlap and type of the projection. │ │ │ │ │ -Definition: contactmerge.hh:86 │ │ │ │ │ -Dune::GridGlue::ContactMerge::minNormalAngle │ │ │ │ │ -T minNormalAngle() const │ │ │ │ │ -get minimum angle in radians between normals at x and Φ(x) │ │ │ │ │ -Definition: contactmerge.hh:132 │ │ │ │ │ -Dune::GridGlue::ContactMerge::LocalCoords │ │ │ │ │ -Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ +Dune::GridGlue::ProjectionImplementation::corner │ │ │ │ │ +Coordinate corner(unsigned c) │ │ │ │ │ +Definition: projection_impl.hh:24 │ │ │ │ │ +Dune::GridGlue::IntersectionList │ │ │ │ │ +Definition: intersectionlist.hh:134 │ │ │ │ │ +Dune::GridGlue::Merger │ │ │ │ │ +Abstract base for all classes that take extracted grids and build sets of │ │ │ │ │ +intersections. │ │ │ │ │ +Definition: merger.hh:27 │ │ │ │ │ +Dune::GridGlue::Merger::parent │ │ │ │ │ +unsigned int parent(unsigned int idx, unsigned int parId=0) const │ │ │ │ │ +get index of grid-n's parent simplex for given merged grid simplex │ │ │ │ │ +Definition: merger.hh:91 │ │ │ │ │ +Dune::GridGlue::Merger::clear │ │ │ │ │ +virtual void clear()=0 │ │ │ │ │ +Dune::GridGlue::Merger::WorldCoords │ │ │ │ │ +Dune::FieldVector< ctype, dimworld > WorldCoords │ │ │ │ │ the coordinate type used in this interface │ │ │ │ │ -Definition: contactmerge.hh:62 │ │ │ │ │ -Dune::GridGlue::StandardMerge │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ -Definition: standardmerge.hh:58 │ │ │ │ │ -Dune::GridGlue::StandardMerge::build │ │ │ │ │ -void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1_Coords, │ │ │ │ │ -const std::vector< unsigned int > &grid1_elements, const std::vector< Dune:: │ │ │ │ │ -GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< T, │ │ │ │ │ -dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, │ │ │ │ │ -const std::vector< Dune::GeometryType > &grid2_element_types) override │ │ │ │ │ +Definition: merger.hh:37 │ │ │ │ │ +Dune::GridGlue::Merger::Grid1Coords │ │ │ │ │ +Dune::FieldVector< ctype, grid1Dim > Grid1Coords │ │ │ │ │ +the local coordinate type for the grid1 coordinates │ │ │ │ │ +Definition: merger.hh:31 │ │ │ │ │ +Dune::GridGlue::Merger::counter │ │ │ │ │ +unsigned int counter │ │ │ │ │ +Counts the number of times the computeIntersection method has been called. │ │ │ │ │ +Definition: merger.hh:114 │ │ │ │ │ +Dune::GridGlue::Merger::parentLocal │ │ │ │ │ +auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId=0) │ │ │ │ │ +const │ │ │ │ │ +get the grid-n parent's simplex local coordinates for a particular merged grid │ │ │ │ │ +simplex corner (parent... │ │ │ │ │ +Definition: merger.hh:105 │ │ │ │ │ +Dune::GridGlue::Merger::build │ │ │ │ │ +virtual void build(const std::vector< Dune::FieldVector< ctype, dimworld > > │ │ │ │ │ +&grid1_coords, const std::vector< unsigned int > &grid1_elements, const std:: │ │ │ │ │ +vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune:: │ │ │ │ │ +FieldVector< ctype, dimworld > > &grid2_coords, const std::vector< unsigned int │ │ │ │ │ +> &grid2_elements, const std::vector< Dune::GeometryType > │ │ │ │ │ +&grid2_element_types)=0 │ │ │ │ │ builds the merged grid │ │ │ │ │ -Definition: standardmerge.hh:392 │ │ │ │ │ -Dune::GridGlue::StandardMerge<_double,_dimworld-1,_dimworld-1,_dimworld_>:: │ │ │ │ │ -valid │ │ │ │ │ -bool valid │ │ │ │ │ -Definition: standardmerge.hh:86 │ │ │ │ │ +Dune::GridGlue::Merger::nSimplices │ │ │ │ │ +unsigned int nSimplices() const │ │ │ │ │ +get the number of simplices in the merged grid The indices are then in │ │ │ │ │ +0..nSimplices()-1 │ │ │ │ │ +Definition: merger.hh:64 │ │ │ │ │ +Dune::GridGlue::Merger::intersectionList │ │ │ │ │ +virtual std::shared_ptr< IntersectionList > intersectionList() const =0 │ │ │ │ │ +Dune::GridGlue::Merger::parents │ │ │ │ │ +unsigned int parents(unsigned int idx) const │ │ │ │ │ +Definition: merger.hh:80 │ │ │ │ │ +Dune::GridGlue::Merger::Grid2Coords │ │ │ │ │ +Dune::FieldVector< ctype, grid2Dim > Grid2Coords │ │ │ │ │ +the local coordinate type for the grid2 coordinates │ │ │ │ │ +Definition: merger.hh:34 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectionlist.hh File Reference │ │ │ │ +dune-grid-glue: computeintersection.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,38 +63,19 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces
│ │ │ │ -
intersectionlist.hh File Reference
│ │ │ │ +
computeintersection.cc File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <array>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::GridGlue::IntersectionListProvider< L0, L1 >
 
class  Dune::GridGlue::IntersectionList< Local0, Local1 >
 
class  Dune::GridGlue::SimplicialIntersectionListProvider< dim0, dim1 >
 
struct  Dune::GridGlue::SimplicialIntersectionListProvider< dim0, dim1 >::SimplicialIntersection
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,32 +5,16 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -intersectionlist.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ - Classes │ │ │ │ │ - class  Dune::GridGlue::IntersectionListProvider<_L0,_L1_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::GridGlue::IntersectionList<_Local0,_Local1_> │ │ │ │ │ -  │ │ │ │ │ - class  Dune::GridGlue::SimplicialIntersectionListProvider<_dim0,_dim1_> │ │ │ │ │ -  │ │ │ │ │ -struct  Dune::GridGlue::SimplicialIntersectionListProvider<_dim0,_dim1_>:: │ │ │ │ │ - SimplicialIntersection │ │ │ │ │ -  │ │ │ │ │ +Namespaces │ │ │ │ │ +computeintersection.cc File Reference │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: overlappingmerge.hh File Reference │ │ │ │ +dune-grid-glue: computeintersection.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -64,45 +64,46 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
overlappingmerge.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
computeintersection.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <iomanip>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <algorithm>
│ │ │ │ +
#include <dune/common/fvector.hh>
│ │ │ │ #include <dune/common/fmatrix.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/geometry/referenceelements.hh>
│ │ │ │ -#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ -#include <dune/grid/common/grid.hh>
│ │ │ │ -#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ -#include <dune/grid-glue/merging/computeintersection.hh>
│ │ │ │ -#include "overlappingmerge.cc"
│ │ │ │ +#include "simplexintersection.cc"
│ │ │ │ +#include "computeintersection.cc"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::OverlappingMerge< dim1, dim2, dimworld, T >
 Computing overlapping grid intersections for grids of different dimensions. More...
class  Dune::GridGlue::ComputationMethod< dimWorld, dim1, dim2, T >
 
class  Dune::GridGlue::IntersectionComputation< CM >
 Intersection computation method for two elements of arbitrary dimension. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class V >
int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,35 +5,33 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -overlappingmerge.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +computeintersection.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "overlappingmerge.cc" │ │ │ │ │ +#include │ │ │ │ │ +#include "simplexintersection.cc" │ │ │ │ │ +#include "computeintersection.cc" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::GridGlue::OverlappingMerge<_dim1,_dim2,_dimworld,_T_> │ │ │ │ │ -  Computing overlapping grid intersections for grids of different │ │ │ │ │ - dimensions. More... │ │ │ │ │ +class  Dune::GridGlue::ComputationMethod<_dimWorld,_dim1,_dim2,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::IntersectionComputation<_CM_> │ │ │ │ │ +  Intersection computation method for two elements of arbitrary │ │ │ │ │ + dimension. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P) │ │ │ │ │ +  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: overlappingmerge.hh Source File │ │ │ │ +dune-grid-glue: computeintersection.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,98 +62,182 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
overlappingmerge.hh
│ │ │ │ +
computeintersection.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
5#ifndef DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ -
6#define DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <iostream>
│ │ │ │ -
9#include <iomanip>
│ │ │ │ -
10#include <vector>
│ │ │ │ -
11#include <algorithm>
│ │ │ │ -
12
│ │ │ │ -
13#include <dune/common/fmatrix.hh>
│ │ │ │ -
14#include <dune/common/fvector.hh>
│ │ │ │ -
15
│ │ │ │ -
16#include <dune/geometry/referenceelements.hh>
│ │ │ │ -
17#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ -
18
│ │ │ │ -
19#include <dune/grid/common/grid.hh>
│ │ │ │ -
20
│ │ │ │ - │ │ │ │ - │ │ │ │ -
23
│ │ │ │ -
24namespace Dune {
│ │ │ │ -
25namespace GridGlue {
│ │ │ │ -
26
│ │ │ │ -
34template<int dim1, int dim2, int dimworld, typename T = double>
│ │ │ │ - │ │ │ │ -
36 : public StandardMerge<T,dim1,dim2,dimworld>
│ │ │ │ -
37{
│ │ │ │ -
38
│ │ │ │ -
39public:
│ │ │ │ -
40
│ │ │ │ -
41 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */
│ │ │ │ -
42
│ │ │ │ -
44 typedef T ctype;
│ │ │ │ -
45
│ │ │ │ -
47 typedef Dune::FieldVector<T, dimworld> WorldCoords;
│ │ │ │ -
48
│ │ │ │ -
50 //typedef Dune::FieldVector<T, dim> LocalCoords;
│ │ │ │ -
51
│ │ │ │ - │ │ │ │ -
53 {}
│ │ │ │ -
54
│ │ │ │ -
55protected:
│ │ │ │ - │ │ │ │ -
57
│ │ │ │ -
69 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
70 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
71 std::bitset<(1<<dim1)>& neighborIntersects1,
│ │ │ │ -
72 unsigned int grid1Index,
│ │ │ │ -
73 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
74 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
75 std::bitset<(1<<dim2)>& neighborIntersects2,
│ │ │ │ -
76 unsigned int grid2Index,
│ │ │ │ -
77 std::vector<SimplicialIntersection>& intersections);
│ │ │ │ -
78
│ │ │ │ -
79private:
│ │ │ │ -
80 bool inPlane(std::vector<FieldVector<T,dimworld> >& points);
│ │ │ │ -
81
│ │ │ │ -
82};
│ │ │ │ -
83
│ │ │ │ -
84} /* namespace Dune::GridGlue */
│ │ │ │ -
85} /* namespace Dune */
│ │ │ │ -
86
│ │ │ │ -
87#include "overlappingmerge.cc"
│ │ │ │ -
88
│ │ │ │ -
89
│ │ │ │ -
90#endif // DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH
│ │ │ │ - │ │ │ │ - │ │ │ │ -
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH
│ │ │ │ +
5
│ │ │ │ +
6#include <dune/common/fvector.hh>
│ │ │ │ +
7#include <dune/common/fmatrix.hh>
│ │ │ │ +
8
│ │ │ │ +
9namespace Dune {
│ │ │ │ +
10namespace GridGlue {
│ │ │ │ +
11
│ │ │ │ +
12template<int dimWorld, int dim1, int dim2, typename T = double>
│ │ │ │ + │ │ │ │ +
14public:
│ │ │ │ +
15 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
16 static const int grid1Dimension = dim1;
│ │ │ │ +
17 static const int grid2Dimension = dim2;
│ │ │ │ +
18 static const int intersectionDimension = (dim1 < dim2)?(dim1):(dim2);
│ │ │ │ +
19
│ │ │ │ +
20 static bool computeIntersectionPoints(const std::vector<Vector> X,
│ │ │ │ +
21 const std::vector<Vector> Y,
│ │ │ │ +
22 std::vector<std::vector<int> >& SX,
│ │ │ │ +
23 std::vector<std::vector<int> >& SY,
│ │ │ │ +
24 std::vector<Vector>& P);
│ │ │ │ +
25 static void grid1_subdivisions(const std::vector<Vector> elementCorners,
│ │ │ │ +
26 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
27 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
28 static void grid2_subdivisions(const std::vector<Vector> elementCorners,
│ │ │ │ +
29 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
30 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
31};
│ │ │ │ +
32
│ │ │ │ +
38template<class CM>
│ │ │ │ + │ │ │ │ +
40private:
│ │ │ │ +
41 typedef typename CM::Vector V;
│ │ │ │ +
42 const int dimWorld = V::dimension;
│ │ │ │ +
43 const int dim1 = CM::grid1Dimension;
│ │ │ │ +
44 const int dim2 = CM::grid2Dimension;
│ │ │ │ +
45public:
│ │ │ │ +
59 static bool computeIntersection(const std::vector<V>& X,
│ │ │ │ +
60 const std::vector<V>& Y,
│ │ │ │ +
61 std::vector<std::vector<int> >& SX,
│ │ │ │ +
62 std::vector<std::vector<int> >& SY,
│ │ │ │ +
63 std::vector<V>& P);
│ │ │ │ +
64
│ │ │ │ +
74 template<int isDim, int dW>
│ │ │ │ +
75 static void orderPoints(const V& centroid,
│ │ │ │ +
76 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
77 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
78 const std::vector<V>& P,
│ │ │ │ +
79 std::vector<std::vector<int> >& H)
│ │ │ │ +
80 {
│ │ │ │ +
81 if (isDim > 1)
│ │ │ │ +
82 orderPoints_(std::integral_constant<int,isDim>(),std::integral_constant<int,dW>(),
│ │ │ │ +
83 centroid, SX, SY, P,H);
│ │ │ │ +
84 }
│ │ │ │ +
85
│ │ │ │ +
86private:
│ │ │ │ +
87 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ +
88 std::integral_constant<int,1>,
│ │ │ │ +
89 const V& centroid,
│ │ │ │ +
90 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
91 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
92 const std::vector<V>& P,
│ │ │ │ +
93 std::vector<std::vector<int> >& H) {}
│ │ │ │ +
94 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ +
95 std::integral_constant<int,2>,
│ │ │ │ +
96 const V& centroid,
│ │ │ │ +
97 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
98 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
99 const std::vector<V>& P,
│ │ │ │ +
100 std::vector<std::vector<int> >& H) {}
│ │ │ │ +
101 static void orderPoints_(std::integral_constant<int,1>,
│ │ │ │ +
102 std::integral_constant<int,3>,
│ │ │ │ +
103 const V& centroid,
│ │ │ │ +
104 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
105 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
106 const std::vector<V>& P,
│ │ │ │ +
107 std::vector<std::vector<int> >& H) {}
│ │ │ │ +
108 static void orderPoints_(std::integral_constant<int,2>,
│ │ │ │ +
109 std::integral_constant<int,2>,
│ │ │ │ +
110 const V& centroid,
│ │ │ │ +
111 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
112 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
113 const std::vector<V>& P,
│ │ │ │ +
114 std::vector<std::vector<int> >& H);
│ │ │ │ +
115 static void orderPoints_(std::integral_constant<int,2>,
│ │ │ │ +
116 std::integral_constant<int,3>,
│ │ │ │ +
117 const V& centroid,
│ │ │ │ +
118 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
119 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
120 const std::vector<V>& P,
│ │ │ │ +
121 std::vector<std::vector<int> >& H);
│ │ │ │ +
122 static void orderPoints_(std::integral_constant<int,3>,
│ │ │ │ +
123 std::integral_constant<int,3>,
│ │ │ │ +
124 const V& centroid,
│ │ │ │ +
125 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
126 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
127 const std::vector<V>& P,
│ │ │ │ +
128 std::vector<std::vector<int> > & H);
│ │ │ │ +
129
│ │ │ │ +
137 static void orderPointsCC(std::integral_constant<int,2>,
│ │ │ │ +
138 const V& centroid,
│ │ │ │ +
139 std::vector<int> &id,
│ │ │ │ +
140 const std::vector<V>& P);
│ │ │ │ +
141 static void orderPointsCC(std::integral_constant<int,3>,
│ │ │ │ +
142 const V& centroid,
│ │ │ │ +
143 std::vector<int> &id,
│ │ │ │ +
144 const std::vector<V>& P);
│ │ │ │ +
145
│ │ │ │ +
150 static void removeDuplicates( std::vector<int> & p);
│ │ │ │ +
151
│ │ │ │ +
159 static bool newFace3D(const std::vector<int>& id,
│ │ │ │ +
160 const std::vector<std::vector<int> >& H);
│ │ │ │ +
161};
│ │ │ │ +
162
│ │ │ │ +
163template<class V>
│ │ │ │ +
164inline int insertPoint(const V p, std::vector<V>& P)
│ │ │ │ +
165{
│ │ │ │ +
166 double eps= 1e-8; // tolerance for identical nodes
│ │ │ │ +
167 std::size_t k=0 ;
│ │ │ │ +
168
│ │ │ │ +
169 if (P.size()>0) {
│ │ │ │ +
170
│ │ │ │ +
171 while ((k<P.size())&&
│ │ │ │ +
172 ((p - P[k]).infinity_norm()>eps*(P[k].infinity_norm()) &&
│ │ │ │ +
173 (p - P[k]).infinity_norm()>eps*(p.infinity_norm())) &&
│ │ │ │ +
174 !(p.infinity_norm() < eps && P[k].infinity_norm() <eps &&
│ │ │ │ +
175 (p - P[k]).infinity_norm() < eps))
│ │ │ │ +
176 k++ ;
│ │ │ │ +
177
│ │ │ │ +
178 if (k>=P.size())
│ │ │ │ +
179 P.push_back(p) ; // new node is not contained in P
│ │ │ │ +
180
│ │ │ │ +
181 }
│ │ │ │ +
182 else
│ │ │ │ +
183 P.push_back(p);
│ │ │ │ +
184
│ │ │ │ +
185 return k ;
│ │ │ │ +
186}
│ │ │ │ +
187
│ │ │ │ +
188
│ │ │ │ +
189} /* namespace Dune::GridGlue */
│ │ │ │ +
190} /* namespace Dune */
│ │ │ │ +
191
│ │ │ │ +
192#include "simplexintersection.cc"
│ │ │ │ +
193#include "computeintersection.cc"
│ │ │ │ +
194
│ │ │ │ +
195#endif
│ │ │ │ + │ │ │ │ + │ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
Computing overlapping grid intersections for grids of different dimensions.
Definition: overlappingmerge.hh:37
│ │ │ │ -
StandardMerge< T, dim1, dim2, dimworld >::SimplicialIntersection SimplicialIntersection
Definition: overlappingmerge.hh:56
│ │ │ │ -
OverlappingMerge()
the coordinate type used in this interface
Definition: overlappingmerge.hh:52
│ │ │ │ -
void computeIntersections(const Dune::GeometryType &grid1ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std::bitset<(1<< dim1)> &neighborIntersects1, unsigned int grid1Index, const Dune::GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< dim2)> &neighborIntersects2, unsigned int grid2Index, std::vector< SimplicialIntersection > &intersections)
Compute the intersection between two overlapping elements.
Definition: overlappingmerge.cc:34
│ │ │ │ -
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: overlappingmerge.hh:47
│ │ │ │ -
T ctype
the numeric type used in this interface
Definition: overlappingmerge.hh:44
│ │ │ │ -
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition: standardmerge.hh:58
│ │ │ │ -
typename IntersectionListProvider::SimplicialIntersection SimplicialIntersection
Definition: standardmerge.hh:83
│ │ │ │ +
int insertPoint(const V p, std::vector< V > &P)
Definition: computeintersection.hh:164
│ │ │ │ +
Definition: computeintersection.hh:13
│ │ │ │ +
static void grid2_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< Vector > X, const std::vector< Vector > Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< Vector > &P)
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition: computeintersection.hh:15
│ │ │ │ +
static const int grid1Dimension
Definition: computeintersection.hh:16
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
│ │ │ │ +
static const int grid2Dimension
Definition: computeintersection.hh:17
│ │ │ │ +
static const int intersectionDimension
Definition: computeintersection.hh:18
│ │ │ │ +
Intersection computation method for two elements of arbitrary dimension.
Definition: computeintersection.hh:39
│ │ │ │ +
static void orderPoints(const V &centroid, const std::vector< std::vector< int > > &SX, const std::vector< std::vector< int > > &SY, const std::vector< V > &P, std::vector< std::vector< int > > &H)
Order Points in the point list P face-wise such that a subsimplex subdivision can be constructed.
Definition: computeintersection.hh:75
│ │ │ │ +
static bool computeIntersection(const std::vector< V > &X, const std::vector< V > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< V > &P)
Compute the intersection of two elements X and Y Compute the intersection of two elements X and Y,...
Definition: computeintersection.cc:14
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,128 +5,215 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -overlappingmerge.hh │ │ │ │ │ +computeintersection.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ - 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ - 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ - 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ + 1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ - 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ + 2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 5#ifndef DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ - 6#define DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9#include │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ - 12 │ │ │ │ │ - 13#include │ │ │ │ │ - 14#include │ │ │ │ │ - 15 │ │ │ │ │ - 16#include │ │ │ │ │ - 17#include │ │ │ │ │ - 18 │ │ │ │ │ - 19#include │ │ │ │ │ - 20 │ │ │ │ │ - 21#include │ │ │ │ │ - 22#include │ │ │ │ │ - 23 │ │ │ │ │ - 24namespace Dune { │ │ │ │ │ - 25namespace GridGlue { │ │ │ │ │ - 26 │ │ │ │ │ - 34template │ │ │ │ │ -35class OverlappingMerge │ │ │ │ │ - 36 : public StandardMerge │ │ │ │ │ - 37{ │ │ │ │ │ - 38 │ │ │ │ │ - 39public: │ │ │ │ │ - 40 │ │ │ │ │ - 41 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */ │ │ │ │ │ - 42 │ │ │ │ │ -44 typedef T ctype; │ │ │ │ │ - 45 │ │ │ │ │ -47 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ - 48 │ │ │ │ │ - 50 //typedef Dune::FieldVector LocalCoords; │ │ │ │ │ - 51 │ │ │ │ │ -52 OverlappingMerge() │ │ │ │ │ - 53 {} │ │ │ │ │ - 54 │ │ │ │ │ - 55protected: │ │ │ │ │ -56 typedef typename StandardMerge::SimplicialIntersection │ │ │ │ │ -SimplicialIntersection; │ │ │ │ │ - 57 │ │ │ │ │ - 69 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ - 70 const std::vector >& grid1ElementCorners, │ │ │ │ │ - 71 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ - 72 unsigned int grid1Index, │ │ │ │ │ - 73 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ - 74 const std::vector >& grid2ElementCorners, │ │ │ │ │ - 75 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ - 76 unsigned int grid2Index, │ │ │ │ │ - 77 std::vector& intersections); │ │ │ │ │ - 78 │ │ │ │ │ - 79private: │ │ │ │ │ - 80 bool inPlane(std::vector >& points); │ │ │ │ │ - 81 │ │ │ │ │ - 82}; │ │ │ │ │ - 83 │ │ │ │ │ - 84} /* namespace Dune::GridGlue */ │ │ │ │ │ - 85} /* namespace Dune */ │ │ │ │ │ - 86 │ │ │ │ │ - 87#include "overlappingmerge.cc" │ │ │ │ │ - 88 │ │ │ │ │ - 89 │ │ │ │ │ - 90#endif // DUNE_GRIDGLUE_MERGING_OVERLAPPINGMERGE_HH │ │ │ │ │ -computeintersection.hh │ │ │ │ │ -overlappingmerge.cc │ │ │ │ │ -standardmerge.hh │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ + 3#ifndef DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH │ │ │ │ │ + 4#define DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH │ │ │ │ │ + 5 │ │ │ │ │ + 6#include │ │ │ │ │ + 7#include │ │ │ │ │ + 8 │ │ │ │ │ + 9namespace Dune { │ │ │ │ │ + 10namespace GridGlue { │ │ │ │ │ + 11 │ │ │ │ │ + 12template │ │ │ │ │ +13class ComputationMethod { │ │ │ │ │ + 14public: │ │ │ │ │ +15 typedef FieldVector Vector; │ │ │ │ │ +16 static const int grid1Dimension = dim1; │ │ │ │ │ +17 static const int grid2Dimension = dim2; │ │ │ │ │ +18 static const int intersectionDimension = (dim1 < dim2)?(dim1):(dim2); │ │ │ │ │ + 19 │ │ │ │ │ +20 static bool computeIntersectionPoints(const std::vector X, │ │ │ │ │ + 21 const std::vector Y, │ │ │ │ │ + 22 std::vector >& SX, │ │ │ │ │ + 23 std::vector >& SY, │ │ │ │ │ + 24 std::vector& P); │ │ │ │ │ +25 static void grid1_subdivisions(const std::vector elementCorners, │ │ │ │ │ + 26 std::vector >& subElements, │ │ │ │ │ + 27 std::vector >& faceIds); │ │ │ │ │ +28 static void grid2_subdivisions(const std::vector elementCorners, │ │ │ │ │ + 29 std::vector >& subElements, │ │ │ │ │ + 30 std::vector >& faceIds); │ │ │ │ │ + 31}; │ │ │ │ │ + 32 │ │ │ │ │ + 38template │ │ │ │ │ +39class IntersectionComputation { │ │ │ │ │ + 40private: │ │ │ │ │ + 41 typedef typename CM::Vector V; │ │ │ │ │ + 42 const int dimWorld = V::dimension; │ │ │ │ │ + 43 const int dim1 = CM::grid1Dimension; │ │ │ │ │ + 44 const int dim2 = CM::grid2Dimension; │ │ │ │ │ + 45public: │ │ │ │ │ + 59 static bool computeIntersection(const std::vector& X, │ │ │ │ │ + 60 const std::vector& Y, │ │ │ │ │ + 61 std::vector >& SX, │ │ │ │ │ + 62 std::vector >& SY, │ │ │ │ │ + 63 std::vector& P); │ │ │ │ │ + 64 │ │ │ │ │ + 74 template │ │ │ │ │ +75 static void orderPoints(const V& centroid, │ │ │ │ │ + 76 const std::vector >& SX, │ │ │ │ │ + 77 const std::vector >& SY, │ │ │ │ │ + 78 const std::vector& P, │ │ │ │ │ + 79 std::vector >& H) │ │ │ │ │ + 80 { │ │ │ │ │ + 81 if (isDim > 1) │ │ │ │ │ + 82 orderPoints_(std::integral_constant(),std:: │ │ │ │ │ +integral_constant(), │ │ │ │ │ + 83 centroid, SX, SY, P,H); │ │ │ │ │ + 84 } │ │ │ │ │ + 85 │ │ │ │ │ + 86private: │ │ │ │ │ + 87 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 88 std::integral_constant, │ │ │ │ │ + 89 const V& centroid, │ │ │ │ │ + 90 const std::vector >& SX, │ │ │ │ │ + 91 const std::vector >& SY, │ │ │ │ │ + 92 const std::vector& P, │ │ │ │ │ + 93 std::vector >& H) {} │ │ │ │ │ + 94 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 95 std::integral_constant, │ │ │ │ │ + 96 const V& centroid, │ │ │ │ │ + 97 const std::vector >& SX, │ │ │ │ │ + 98 const std::vector >& SY, │ │ │ │ │ + 99 const std::vector& P, │ │ │ │ │ + 100 std::vector >& H) {} │ │ │ │ │ + 101 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 102 std::integral_constant, │ │ │ │ │ + 103 const V& centroid, │ │ │ │ │ + 104 const std::vector >& SX, │ │ │ │ │ + 105 const std::vector >& SY, │ │ │ │ │ + 106 const std::vector& P, │ │ │ │ │ + 107 std::vector >& H) {} │ │ │ │ │ + 108 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 109 std::integral_constant, │ │ │ │ │ + 110 const V& centroid, │ │ │ │ │ + 111 const std::vector >& SX, │ │ │ │ │ + 112 const std::vector >& SY, │ │ │ │ │ + 113 const std::vector& P, │ │ │ │ │ + 114 std::vector >& H); │ │ │ │ │ + 115 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 116 std::integral_constant, │ │ │ │ │ + 117 const V& centroid, │ │ │ │ │ + 118 const std::vector >& SX, │ │ │ │ │ + 119 const std::vector >& SY, │ │ │ │ │ + 120 const std::vector& P, │ │ │ │ │ + 121 std::vector >& H); │ │ │ │ │ + 122 static void orderPoints_(std::integral_constant, │ │ │ │ │ + 123 std::integral_constant, │ │ │ │ │ + 124 const V& centroid, │ │ │ │ │ + 125 const std::vector >& SX, │ │ │ │ │ + 126 const std::vector >& SY, │ │ │ │ │ + 127 const std::vector& P, │ │ │ │ │ + 128 std::vector > & H); │ │ │ │ │ + 129 │ │ │ │ │ + 137 static void orderPointsCC(std::integral_constant, │ │ │ │ │ + 138 const V& centroid, │ │ │ │ │ + 139 std::vector &id, │ │ │ │ │ + 140 const std::vector& P); │ │ │ │ │ + 141 static void orderPointsCC(std::integral_constant, │ │ │ │ │ + 142 const V& centroid, │ │ │ │ │ + 143 std::vector &id, │ │ │ │ │ + 144 const std::vector& P); │ │ │ │ │ + 145 │ │ │ │ │ + 150 static void removeDuplicates( std::vector & p); │ │ │ │ │ + 151 │ │ │ │ │ + 159 static bool newFace3D(const std::vector& id, │ │ │ │ │ + 160 const std::vector >& H); │ │ │ │ │ + 161}; │ │ │ │ │ + 162 │ │ │ │ │ + 163template │ │ │ │ │ +164inline int insertPoint(const V p, std::vector& P) │ │ │ │ │ + 165{ │ │ │ │ │ + 166 double eps= 1e-8; // tolerance for identical nodes │ │ │ │ │ + 167 std::size_t k=0 ; │ │ │ │ │ + 168 │ │ │ │ │ + 169 if (P.size()>0) { │ │ │ │ │ + 170 │ │ │ │ │ + 171 while ((keps*(P[k].infinity_norm()) && │ │ │ │ │ + 173 (p - P[k]).infinity_norm()>eps*(p.infinity_norm())) && │ │ │ │ │ + 174 !(p.infinity_norm() < eps && P[k].infinity_norm() =P.size()) │ │ │ │ │ + 179 P.push_back(p) ; // new node is not contained in P │ │ │ │ │ + 180 │ │ │ │ │ + 181 } │ │ │ │ │ + 182 else │ │ │ │ │ + 183 P.push_back(p); │ │ │ │ │ + 184 │ │ │ │ │ + 185 return k ; │ │ │ │ │ + 186} │ │ │ │ │ + 187 │ │ │ │ │ + 188 │ │ │ │ │ + 189} /* namespace Dune::GridGlue */ │ │ │ │ │ + 190} /* namespace Dune */ │ │ │ │ │ + 191 │ │ │ │ │ + 192#include "simplexintersection.cc" │ │ │ │ │ + 193#include "computeintersection.cc" │ │ │ │ │ + 194 │ │ │ │ │ + 195#endif │ │ │ │ │ +computeintersection.cc │ │ │ │ │ +simplexintersection.cc │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge │ │ │ │ │ -Computing overlapping grid intersections for grids of different dimensions. │ │ │ │ │ -Definition: overlappingmerge.hh:37 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge::SimplicialIntersection │ │ │ │ │ -StandardMerge< T, dim1, dim2, dimworld >::SimplicialIntersection │ │ │ │ │ -SimplicialIntersection │ │ │ │ │ -Definition: overlappingmerge.hh:56 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge::OverlappingMerge │ │ │ │ │ -OverlappingMerge() │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition: overlappingmerge.hh:52 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge::computeIntersections │ │ │ │ │ -void computeIntersections(const Dune::GeometryType &grid1ElementType, const │ │ │ │ │ -std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std:: │ │ │ │ │ -bitset<(1<< dim1)> &neighborIntersects1, unsigned int grid1Index, const Dune:: │ │ │ │ │ -GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, │ │ │ │ │ -dimworld > > &grid2ElementCorners, std::bitset<(1<< dim2)> │ │ │ │ │ -&neighborIntersects2, unsigned int grid2Index, std::vector< │ │ │ │ │ -SimplicialIntersection > &intersections) │ │ │ │ │ -Compute the intersection between two overlapping elements. │ │ │ │ │ -Definition: overlappingmerge.cc:34 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge::WorldCoords │ │ │ │ │ -Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition: overlappingmerge.hh:47 │ │ │ │ │ -Dune::GridGlue::OverlappingMerge::ctype │ │ │ │ │ -T ctype │ │ │ │ │ -the numeric type used in this interface │ │ │ │ │ -Definition: overlappingmerge.hh:44 │ │ │ │ │ -Dune::GridGlue::StandardMerge │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ -Definition: standardmerge.hh:58 │ │ │ │ │ -Dune::GridGlue::StandardMerge::SimplicialIntersection │ │ │ │ │ -typename IntersectionListProvider::SimplicialIntersection │ │ │ │ │ -SimplicialIntersection │ │ │ │ │ -Definition: standardmerge.hh:83 │ │ │ │ │ +Dune::GridGlue::insertPoint │ │ │ │ │ +int insertPoint(const V p, std::vector< V > &P) │ │ │ │ │ +Definition: computeintersection.hh:164 │ │ │ │ │ +Dune::GridGlue::ComputationMethod │ │ │ │ │ +Definition: computeintersection.hh:13 │ │ │ │ │ +Dune::GridGlue::ComputationMethod::grid2_subdivisions │ │ │ │ │ +static void grid2_subdivisions(const std::vector< Vector > elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Dune::GridGlue::ComputationMethod::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< Vector > X, const │ │ │ │ │ +std::vector< Vector > Y, std::vector< std::vector< int > > &SX, std::vector< │ │ │ │ │ +std::vector< int > > &SY, std::vector< Vector > &P) │ │ │ │ │ +Dune::GridGlue::ComputationMethod::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition: computeintersection.hh:15 │ │ │ │ │ +Dune::GridGlue::ComputationMethod::grid1Dimension │ │ │ │ │ +static const int grid1Dimension │ │ │ │ │ +Definition: computeintersection.hh:16 │ │ │ │ │ +Dune::GridGlue::ComputationMethod::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Dune::GridGlue::ComputationMethod::grid2Dimension │ │ │ │ │ +static const int grid2Dimension │ │ │ │ │ +Definition: computeintersection.hh:17 │ │ │ │ │ +Dune::GridGlue::ComputationMethod::intersectionDimension │ │ │ │ │ +static const int intersectionDimension │ │ │ │ │ +Definition: computeintersection.hh:18 │ │ │ │ │ +Dune::GridGlue::IntersectionComputation │ │ │ │ │ +Intersection computation method for two elements of arbitrary dimension. │ │ │ │ │ +Definition: computeintersection.hh:39 │ │ │ │ │ +Dune::GridGlue::IntersectionComputation::orderPoints │ │ │ │ │ +static void orderPoints(const V ¢roid, const std::vector< std::vector< int │ │ │ │ │ +> > &SX, const std::vector< std::vector< int > > &SY, const std::vector< V > │ │ │ │ │ +&P, std::vector< std::vector< int > > &H) │ │ │ │ │ +Order Points in the point list P face-wise such that a subsimplex subdivision │ │ │ │ │ +can be constructed. │ │ │ │ │ +Definition: computeintersection.hh:75 │ │ │ │ │ +Dune::GridGlue::IntersectionComputation::computeIntersection │ │ │ │ │ +static bool computeIntersection(const std::vector< V > &X, const std::vector< V │ │ │ │ │ +> &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > │ │ │ │ │ +&SY, std::vector< V > &P) │ │ │ │ │ +Compute the intersection of two elements X and Y Compute the intersection of │ │ │ │ │ +two elements X and Y,... │ │ │ │ │ +Definition: computeintersection.cc:14 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.cc File Reference │ │ │ │ +dune-grid-glue: simplexintersection.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,25 +63,67 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Namespaces
│ │ │ │ -
computeintersection.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
simplexintersection.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::GridGlue::SimplexMethod< dimWorld, dim1, dim2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 0, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 1, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 1, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 2, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 2, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 3, 3, T >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 0 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 1 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 2 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 3 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,17 +5,65 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces │ │ │ │ │ -computeintersection.cc File Reference │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +simplexintersection.cc File Reference │ │ │ │ │ + Classes │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_dim1,_dim2,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_> │ │ │ │ │ +  │ │ │ │ │ +class  Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ + Functions │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 0 >, │ │ │ │ │ + const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ + std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ + std::vector< int > > &faceIds) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 1 >, │ │ │ │ │ + const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ + std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ + std::vector< int > > &faceIds) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 2 >, │ │ │ │ │ + const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ + std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ + std::vector< int > > &faceIds) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 3 >, │ │ │ │ │ + const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ + std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ + std::vector< int > > &faceIds) │ │ │ │ │ +  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.cc File Reference │ │ │ │ +dune-grid-glue: intersectionlist.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,21 +63,38 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces
│ │ │ │ -
contactmerge.cc File Reference
│ │ │ │ +
intersectionlist.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ -#include <dune/grid-glue/common/projection.hh>
│ │ │ │ -
│ │ │ │ +
#include <array>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::GridGlue::IntersectionListProvider< L0, L1 >
 
class  Dune::GridGlue::IntersectionList< Local0, Local1 >
 
class  Dune::GridGlue::SimplicialIntersectionListProvider< dim0, dim1 >
 
struct  Dune::GridGlue::SimplicialIntersectionListProvider< dim0, dim1 >::SimplicialIntersection
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,18 +5,32 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces │ │ │ │ │ -contactmerge.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +intersectionlist.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ + Classes │ │ │ │ │ + class  Dune::GridGlue::IntersectionListProvider<_L0,_L1_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GridGlue::IntersectionList<_Local0,_Local1_> │ │ │ │ │ +  │ │ │ │ │ + class  Dune::GridGlue::SimplicialIntersectionListProvider<_dim0,_dim1_> │ │ │ │ │ +  │ │ │ │ │ +struct  Dune::GridGlue::SimplicialIntersectionListProvider<_dim0,_dim1_>:: │ │ │ │ │ + SimplicialIntersection │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: merger.hh File Reference │ │ │ │ +dune-grid-glue: contactmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,37 +65,54 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
merger.hh File Reference
│ │ │ │ +
contactmerge.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <vector>
│ │ │ │ + │ │ │ │ +

Merge two grid boundary surfaces that may be a positive distance apart. │ │ │ │ +More...

│ │ │ │ +
#include <iostream>
│ │ │ │ +#include <fstream>
│ │ │ │ +#include <iomanip>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <algorithm>
│ │ │ │ +#include <limits>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <functional>
│ │ │ │ #include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/geometry/type.hh>
│ │ │ │ -#include <dune/grid-glue/merging/intersectionlist.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/bitsetvector.hh>
│ │ │ │ +#include <dune/common/deprecated.hh>
│ │ │ │ +#include <dune/grid/common/grid.hh>
│ │ │ │ +#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ +#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +#include "contactmerge.cc"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::Merger< ctype, grid1Dim, grid2Dim, dimworld >
 Abstract base for all classes that take extracted grids and build sets of intersections. More...
class  Dune::GridGlue::ContactMerge< dimworld, T >
 Merge two codimension-1 surfaces that may be a positive distance apart. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Merge two grid boundary surfaces that may be a positive distance apart.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -6,26 +6,41 @@ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -merger.hh File Reference │ │ │ │ │ +contactmerge.hh File Reference │ │ │ │ │ +Merge two grid boundary surfaces that may be a positive distance apart. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "contactmerge.cc" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class  Dune::GridGlue::Merger<_ctype,_grid1Dim,_grid2Dim,_dimworld_> │ │ │ │ │ -  Abstract base for all classes that take extracted grids and build sets │ │ │ │ │ - of intersections. More... │ │ │ │ │ +class  Dune::GridGlue::ContactMerge<_dimworld,_T_> │ │ │ │ │ +  Merge two codimension-1 surfaces that may be a positive distance apart. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Merge two grid boundary surfaces that may be a positive distance apart. │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: merger.hh Source File │ │ │ │ +dune-grid-glue: contactmerge.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -62,101 +62,217 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
merger.hh
│ │ │ │ +
contactmerge.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
│ │ │ │ -
5#ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH
│ │ │ │ -
6#define DUNE_GRIDGLUE_MERGING_MERGER_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <vector>
│ │ │ │ -
9
│ │ │ │ -
10#include <dune/common/fvector.hh>
│ │ │ │ -
11#include <dune/geometry/type.hh>
│ │ │ │ +
10#ifndef DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │ +
11#define DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │
12
│ │ │ │ - │ │ │ │ -
14
│ │ │ │ -
15namespace Dune {
│ │ │ │ -
16namespace GridGlue {
│ │ │ │ -
17
│ │ │ │ -
25template <class ctype, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
26class Merger
│ │ │ │ -
27{
│ │ │ │ -
28public:
│ │ │ │ +
13
│ │ │ │ +
14#include <iostream>
│ │ │ │ +
15#include <fstream>
│ │ │ │ +
16#include <iomanip>
│ │ │ │ +
17#include <vector>
│ │ │ │ +
18#include <algorithm>
│ │ │ │ +
19#include <limits>
│ │ │ │ +
20#include <memory>
│ │ │ │ +
21#include <functional>
│ │ │ │ +
22
│ │ │ │ +
23#include <dune/common/fvector.hh>
│ │ │ │ +
24#include <dune/common/exceptions.hh>
│ │ │ │ +
25#include <dune/common/bitsetvector.hh>
│ │ │ │ +
26#include <dune/common/deprecated.hh>
│ │ │ │ +
27
│ │ │ │ +
28#include <dune/grid/common/grid.hh>
│ │ │ │
29
│ │ │ │ -
31 typedef Dune::FieldVector<ctype, grid1Dim> Grid1Coords;
│ │ │ │ + │ │ │ │ + │ │ │ │
32
│ │ │ │ -
34 typedef Dune::FieldVector<ctype, grid2Dim> Grid2Coords;
│ │ │ │ +
33namespace Dune {
│ │ │ │ +
34namespace GridGlue {
│ │ │ │
35
│ │ │ │ -
37 typedef Dune::FieldVector<ctype, dimworld> WorldCoords;
│ │ │ │ -
38
│ │ │ │ - │ │ │ │ -
40
│ │ │ │ -
54 virtual void build(const std::vector<Dune::FieldVector<ctype,dimworld> >& grid1_coords,
│ │ │ │ -
55 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
56 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
57 const std::vector<Dune::FieldVector<ctype,dimworld> >& grid2_coords,
│ │ │ │ -
58 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
59 const std::vector<Dune::GeometryType>& grid2_element_types) = 0;
│ │ │ │ +
41template<int dimworld, typename T = double>
│ │ │ │ + │ │ │ │ +
43: public StandardMerge<T,dimworld-1,dimworld-1,dimworld>
│ │ │ │ +
44{
│ │ │ │ +
45 static constexpr int dim = dimworld-1;
│ │ │ │ +
46
│ │ │ │ +
47 static_assert( dim==1 || dim==2,
│ │ │ │ +
48 "ContactMerge yet only handles the cases dim==1 and dim==2!");
│ │ │ │ +
49
│ │ │ │ + │ │ │ │ +
51public:
│ │ │ │ +
52
│ │ │ │ +
53 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */
│ │ │ │ +
54
│ │ │ │ +
56 typedef T ctype;
│ │ │ │ +
57
│ │ │ │ +
59 typedef Dune::FieldVector<T, dimworld> WorldCoords;
│ │ │ │
60
│ │ │ │ -
64 unsigned int nSimplices() const
│ │ │ │ -
65 { return intersectionList()->size(); }
│ │ │ │ -
66
│ │ │ │ -
67 virtual void clear() = 0;
│ │ │ │ -
68
│ │ │ │ -
74 virtual std::shared_ptr<IntersectionList> intersectionList() const = 0;
│ │ │ │ -
75
│ │ │ │ -
79 template<int n>
│ │ │ │ -
80 unsigned int parents(unsigned int idx) const {
│ │ │ │ -
81 return intersectionList()->template parents<n>(idx);
│ │ │ │ -
82 }
│ │ │ │ -
83
│ │ │ │ -
90 template<int n>
│ │ │ │ -
91 unsigned int parent(unsigned int idx, unsigned int parId = 0) const
│ │ │ │ -
92 {
│ │ │ │ -
93 return intersectionList()->template parent<n>(idx, parId);
│ │ │ │ -
94 }
│ │ │ │ -
95
│ │ │ │ -
104 template<int n>
│ │ │ │ -
105 auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId = 0) const
│ │ │ │ -
106 {
│ │ │ │ -
107 return intersectionList()->template corner<n>(idx, corner, parId);
│ │ │ │ -
108 }
│ │ │ │ -
109
│ │ │ │ -
114 unsigned int counter;
│ │ │ │ -
115};
│ │ │ │ -
116
│ │ │ │ -
117} /* namespace GridGlue */
│ │ │ │ -
118} /* namespace Dune */
│ │ │ │ +
62 typedef Dune::FieldVector<T, dim> LocalCoords;
│ │ │ │ +
63
│ │ │ │ + │ │ │ │ +
73 ContactMerge(const T allowedOverlap=T(0),
│ │ │ │ +
74 std::function<WorldCoords(WorldCoords)> domainDirections=nullptr,
│ │ │ │ +
75 std::function<WorldCoords(WorldCoords)> targetDirections=nullptr,
│ │ │ │ + │ │ │ │ +
77 : domainDirections_(domainDirections), targetDirections_(targetDirections),
│ │ │ │ +
78 overlap_(allowedOverlap), type_(type)
│ │ │ │ +
79 {}
│ │ │ │ +
80
│ │ │ │ +
86 ContactMerge(const T allowedOverlap, ProjectionType type)
│ │ │ │ +
87 : overlap_(allowedOverlap),
│ │ │ │ +
88 type_(type)
│ │ │ │ +
89 {}
│ │ │ │ +
90
│ │ │ │ +
99 inline
│ │ │ │ +
100 void setSurfaceDirections(std::function<WorldCoords(WorldCoords)> domainDirections,
│ │ │ │ +
101 std::function<WorldCoords(WorldCoords)> targetDirections)
│ │ │ │ +
102 {
│ │ │ │ +
103 domainDirections_ = domainDirections;
│ │ │ │ +
104 targetDirections_ = targetDirections;
│ │ │ │ +
105 this->valid = false;
│ │ │ │ +
106 }
│ │ │ │ +
107
│ │ │ │ +
109 void setOverlap(T overlap)
│ │ │ │ +
110 {
│ │ │ │ +
111 overlap_ = overlap;
│ │ │ │ +
112 }
│ │ │ │ +
113
│ │ │ │ +
115 T getOverlap() const
│ │ │ │ +
116 {
│ │ │ │ +
117 return overlap_;
│ │ │ │ +
118 }
│ │ │ │
119
│ │ │ │ -
120#endif
│ │ │ │ - │ │ │ │ +
123 void minNormalAngle(T angle)
│ │ │ │ +
124 {
│ │ │ │ +
125 using std::cos;
│ │ │ │ +
126 maxNormalProduct_ = cos(angle);
│ │ │ │ +
127 }
│ │ │ │ +
128
│ │ │ │ + │ │ │ │ +
133 {
│ │ │ │ +
134 using std::acos;
│ │ │ │ +
135 return acos(maxNormalProduct_);
│ │ │ │ +
136 }
│ │ │ │ +
137
│ │ │ │ +
138protected:
│ │ │ │ +
139 typedef typename StandardMerge<T,dimworld-1,dimworld-1,dimworld>::SimplicialIntersection SimplicialIntersection;
│ │ │ │ +
140
│ │ │ │ +
141private:
│ │ │ │ +
145 std::function<WorldCoords(WorldCoords)> domainDirections_;
│ │ │ │ +
146 std::vector<WorldCoords> nodalDomainDirections_;
│ │ │ │ +
147
│ │ │ │ +
156 std::function<WorldCoords(WorldCoords)> targetDirections_;
│ │ │ │ +
157 std::vector<WorldCoords> nodalTargetDirections_;
│ │ │ │ +
158
│ │ │ │ +
160 T overlap_;
│ │ │ │ +
161
│ │ │ │ +
163 ProjectionType type_;
│ │ │ │ +
164
│ │ │ │ +
168 T maxNormalProduct_ = T(-0.1);
│ │ │ │ +
169
│ │ │ │ +
174 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
175 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
176 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ +
177 unsigned int grid1Index,
│ │ │ │ +
178 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
179 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
180 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ +
181 unsigned int grid2Index,
│ │ │ │ +
182 std::vector<SimplicialIntersection>& intersections) override;
│ │ │ │ +
183
│ │ │ │ +
187protected:
│ │ │ │ +
188 void build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
189 const std::vector<unsigned int>& grid1Elements,
│ │ │ │ +
190 const std::vector<Dune::GeometryType>& grid1ElementTypes,
│ │ │ │ +
191 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
192 const std::vector<unsigned int>& grid2Elements,
│ │ │ │ +
193 const std::vector<Dune::GeometryType>& grid2ElementTypes) override
│ │ │ │ +
194 {
│ │ │ │ +
195 std::cout<<"ContactMerge building grid!\n";
│ │ │ │ +
196 // setup the nodal direction vectors
│ │ │ │ +
197 setupNodalDirections(grid1Coords, grid1Elements, grid1ElementTypes,
│ │ │ │ +
198 grid2Coords, grid2Elements, grid2ElementTypes);
│ │ │ │ +
199
│ │ │ │ +
200 Base::build(grid1Coords, grid1Elements, grid1ElementTypes,
│ │ │ │ +
201 grid2Coords, grid2Elements, grid2ElementTypes);
│ │ │ │ +
202
│ │ │ │ +
203 }
│ │ │ │ +
204
│ │ │ │ +
205private:
│ │ │ │ +
206
│ │ │ │ +
208 static LocalCoords localCornerCoords(int i, const Dune::GeometryType& gt)
│ │ │ │ +
209 {
│ │ │ │ +
210 const auto& ref = Dune::ReferenceElements<T,dim>::general(gt);
│ │ │ │ +
211 return ref.position(i,dim);
│ │ │ │ +
212 }
│ │ │ │ +
213
│ │ │ │ +
214protected:
│ │ │ │ +
215
│ │ │ │ +
217 void computeCyclicOrder(const std::vector<std::array<LocalCoords,2> >& polytopeCorners,
│ │ │ │ +
218 const LocalCoords& center, std::vector<int>& ordering) const;
│ │ │ │ +
219
│ │ │ │ +
221 void setupNodalDirections(const std::vector<WorldCoords>& coords1,
│ │ │ │ +
222 const std::vector<unsigned int>& elements1,
│ │ │ │ +
223 const std::vector<Dune::GeometryType>& elementTypes1,
│ │ │ │ +
224 const std::vector<WorldCoords>& coords2,
│ │ │ │ +
225 const std::vector<unsigned int>& elements2,
│ │ │ │ +
226 const std::vector<Dune::GeometryType>& elementTypes2);
│ │ │ │ +
227
│ │ │ │ +
229 void computeOuterNormalField(const std::vector<WorldCoords>& coords,
│ │ │ │ +
230 const std::vector<unsigned int>& elements,
│ │ │ │ +
231 const std::vector<Dune::GeometryType>& elementTypes,
│ │ │ │ +
232 std::vector<WorldCoords>& normals);
│ │ │ │ +
233
│ │ │ │ +
235 void removeDoubles(std::vector<std::array<LocalCoords,2> >& polytopeCorners);
│ │ │ │ +
236};
│ │ │ │ +
237
│ │ │ │ +
238} /* namespace GridGlue */
│ │ │ │ +
239} /* namespace Dune */
│ │ │ │ +
240
│ │ │ │ +
241#include "contactmerge.cc"
│ │ │ │ +
242
│ │ │ │ +
243#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
│ │ │ │ +
Central component of the module implementing the coupling of two grids.
│ │ │ │ + │ │ │ │ +
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │
Definition: gridglue.hh:37
│ │ │ │ -
Coordinate corner(unsigned c)
Definition: projection_impl.hh:24
│ │ │ │ -
Definition: intersectionlist.hh:134
│ │ │ │ -
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:27
│ │ │ │ -
unsigned int parent(unsigned int idx, unsigned int parId=0) const
get index of grid-n's parent simplex for given merged grid simplex
Definition: merger.hh:91
│ │ │ │ -
virtual void clear()=0
│ │ │ │ -
Dune::FieldVector< ctype, dimworld > WorldCoords
the coordinate type used in this interface
Definition: merger.hh:37
│ │ │ │ -
Dune::FieldVector< ctype, grid1Dim > Grid1Coords
the local coordinate type for the grid1 coordinates
Definition: merger.hh:31
│ │ │ │ -
unsigned int counter
Counts the number of times the computeIntersection method has been called.
Definition: merger.hh:114
│ │ │ │ -
auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId=0) const
get the grid-n parent's simplex local coordinates for a particular merged grid simplex corner (parent...
Definition: merger.hh:105
│ │ │ │ -
virtual void build(const std::vector< Dune::FieldVector< ctype, dimworld > > &grid1_coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< ctype, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types)=0
builds the merged grid
│ │ │ │ -
unsigned int nSimplices() const
get the number of simplices in the merged grid The indices are then in 0..nSimplices()-1
Definition: merger.hh:64
│ │ │ │ -
virtual std::shared_ptr< IntersectionList > intersectionList() const =0
│ │ │ │ -
unsigned int parents(unsigned int idx) const
Definition: merger.hh:80
│ │ │ │ -
Dune::FieldVector< ctype, grid2Dim > Grid2Coords
the local coordinate type for the grid2 coordinates
Definition: merger.hh:34
│ │ │ │ +
Merge two codimension-1 surfaces that may be a positive distance apart.
Definition: contactmerge.hh:44
│ │ │ │ +
void computeCyclicOrder(const std::vector< std::array< LocalCoords, 2 > > &polytopeCorners, const LocalCoords &center, std::vector< int > &ordering) const
Order the corners of the intersection polytope in cyclic order.
Definition: contactmerge.cc:214
│ │ │ │ +
StandardMerge< T, dimworld-1, dimworld-1, dimworld >::SimplicialIntersection SimplicialIntersection
Definition: contactmerge.hh:139
│ │ │ │ +
void removeDoubles(std::vector< std::array< LocalCoords, 2 > > &polytopeCorners)
Remove all multiples.
Definition: contactmerge.cc:335
│ │ │ │ +
void setOverlap(T overlap)
Set the allowed overlap of the surfaces.
Definition: contactmerge.hh:109
│ │ │ │ +
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: contactmerge.hh:59
│ │ │ │ +
void setupNodalDirections(const std::vector< WorldCoords > &coords1, const std::vector< unsigned int > &elements1, const std::vector< Dune::GeometryType > &elementTypes1, const std::vector< WorldCoords > &coords2, const std::vector< unsigned int > &elements2, const std::vector< Dune::GeometryType > &elementTypes2)
Setup the direction vectors containing the directions for each vertex.
Definition: contactmerge.cc:269
│ │ │ │ +
void minNormalAngle(T angle)
set minimum angle in radians between normals at x and Φ(x)
Definition: contactmerge.hh:123
│ │ │ │ +
T ctype
the numeric type used in this interface
Definition: contactmerge.hh:56
│ │ │ │ +
ProjectionType
Type of the projection, closest point or outer normal projection.
Definition: contactmerge.hh:65
│ │ │ │ +
@ CLOSEST_POINT
Definition: contactmerge.hh:65
│ │ │ │ +
@ OUTER_NORMAL
Definition: contactmerge.hh:65
│ │ │ │ +
void computeOuterNormalField(const std::vector< WorldCoords > &coords, const std::vector< unsigned int > &elements, const std::vector< Dune::GeometryType > &elementTypes, std::vector< WorldCoords > &normals)
If no direction field was specified compute the outer normal field.
Definition: contactmerge.cc:296
│ │ │ │ +
T getOverlap() const
Get the allowed overlap of the surfaces.
Definition: contactmerge.hh:115
│ │ │ │ +
ContactMerge(const T allowedOverlap=T(0), std::function< WorldCoords(WorldCoords)> domainDirections=nullptr, std::function< WorldCoords(WorldCoords)> targetDirections=nullptr, ProjectionType type=OUTER_NORMAL)
Construct merger given overlap and possible projection directions.
Definition: contactmerge.hh:73
│ │ │ │ +
void setSurfaceDirections(std::function< WorldCoords(WorldCoords)> domainDirections, std::function< WorldCoords(WorldCoords)> targetDirections)
Set surface direction functions.
Definition: contactmerge.hh:100
│ │ │ │ +
void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std::vector< unsigned int > &grid1Elements, const std::vector< Dune::GeometryType > &grid1ElementTypes, const std::vector< Dune::FieldVector< T, dimworld > > &grid2Coords, const std::vector< unsigned int > &grid2Elements, const std::vector< Dune::GeometryType > &grid2ElementTypes) override
builds the merged grid
Definition: contactmerge.hh:188
│ │ │ │ +
ContactMerge(const T allowedOverlap, ProjectionType type)
Construct merger given overlap and type of the projection.
Definition: contactmerge.hh:86
│ │ │ │ +
T minNormalAngle() const
get minimum angle in radians between normals at x and Φ(x)
Definition: contactmerge.hh:132
│ │ │ │ +
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition: contactmerge.hh:62
│ │ │ │ +
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition: standardmerge.hh:58
│ │ │ │ +
void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1_Coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< T, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types) override
builds the merged grid
Definition: standardmerge.hh:392
│ │ │ │ + │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,143 +5,308 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -merger.hh │ │ │ │ │ +contactmerge.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only- │ │ │ │ │ with-dune-grid-glue-exception │ │ │ │ │ - 5#ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ - 6#define DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ - 7 │ │ │ │ │ - 8#include │ │ │ │ │ - 9 │ │ │ │ │ - 10#include │ │ │ │ │ - 11#include │ │ │ │ │ + 10#ifndef DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ + 11#define DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ 12 │ │ │ │ │ - 13#include │ │ │ │ │ - 14 │ │ │ │ │ - 15namespace Dune { │ │ │ │ │ - 16namespace GridGlue { │ │ │ │ │ - 17 │ │ │ │ │ - 25template │ │ │ │ │ -26class Merger │ │ │ │ │ - 27{ │ │ │ │ │ - 28public: │ │ │ │ │ + 13 │ │ │ │ │ + 14#include │ │ │ │ │ + 15#include │ │ │ │ │ + 16#include │ │ │ │ │ + 17#include │ │ │ │ │ + 18#include │ │ │ │ │ + 19#include │ │ │ │ │ + 20#include │ │ │ │ │ + 21#include │ │ │ │ │ + 22 │ │ │ │ │ + 23#include │ │ │ │ │ + 24#include │ │ │ │ │ + 25#include │ │ │ │ │ + 26#include │ │ │ │ │ + 27 │ │ │ │ │ + 28#include │ │ │ │ │ 29 │ │ │ │ │ -31 typedef Dune::FieldVector Grid1Coords; │ │ │ │ │ + 30#include │ │ │ │ │ + 31#include │ │ │ │ │ 32 │ │ │ │ │ -34 typedef Dune::FieldVector Grid2Coords; │ │ │ │ │ + 33namespace Dune { │ │ │ │ │ + 34namespace GridGlue { │ │ │ │ │ 35 │ │ │ │ │ -37 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ - 38 │ │ │ │ │ -39 using IntersectionList = Dune::GridGlue::IntersectionList; │ │ │ │ │ - 40 │ │ │ │ │ -54 virtual void build(const std::vector >& │ │ │ │ │ -grid1_coords, │ │ │ │ │ - 55 const std::vector& grid1_elements, │ │ │ │ │ - 56 const std::vector& grid1_element_types, │ │ │ │ │ - 57 const std::vector >& grid2_coords, │ │ │ │ │ - 58 const std::vector& grid2_elements, │ │ │ │ │ - 59 const std::vector& grid2_element_types) = 0; │ │ │ │ │ + 41template │ │ │ │ │ +42class ContactMerge │ │ │ │ │ + 43: public StandardMerge │ │ │ │ │ + 44{ │ │ │ │ │ + 45 static constexpr int dim = dimworld-1; │ │ │ │ │ + 46 │ │ │ │ │ + 47 static_assert( dim==1 || dim==2, │ │ │ │ │ + 48 "ContactMerge yet only handles the cases dim==1 and dim==2!"); │ │ │ │ │ + 49 │ │ │ │ │ + 50 typedef StandardMerge Base; │ │ │ │ │ + 51public: │ │ │ │ │ + 52 │ │ │ │ │ + 53 /* E X P O R T E D T Y P E S A N D C O N S T A N T S */ │ │ │ │ │ + 54 │ │ │ │ │ +56 typedef T ctype; │ │ │ │ │ + 57 │ │ │ │ │ +59 typedef Dune::FieldVector WorldCoords; │ │ │ │ │ 60 │ │ │ │ │ -64 unsigned int nSimplices() const │ │ │ │ │ - 65 { return intersectionList()->size(); } │ │ │ │ │ - 66 │ │ │ │ │ -67 virtual void clear() = 0; │ │ │ │ │ - 68 │ │ │ │ │ -74 virtual std::shared_ptr intersectionList() const = 0; │ │ │ │ │ - 75 │ │ │ │ │ - 79 template │ │ │ │ │ -80 unsigned int parents(unsigned int idx) const { │ │ │ │ │ - 81 return intersectionList()->template parents(idx); │ │ │ │ │ - 82 } │ │ │ │ │ - 83 │ │ │ │ │ - 90 template │ │ │ │ │ -91 unsigned int parent(unsigned int idx, unsigned int parId = 0) const │ │ │ │ │ - 92 { │ │ │ │ │ - 93 return intersectionList()->template parent(idx, parId); │ │ │ │ │ - 94 } │ │ │ │ │ - 95 │ │ │ │ │ - 104 template │ │ │ │ │ -105 auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId │ │ │ │ │ -= 0) const │ │ │ │ │ - 106 { │ │ │ │ │ - 107 return intersectionList()->template corner(idx, corner, parId); │ │ │ │ │ - 108 } │ │ │ │ │ - 109 │ │ │ │ │ -114 unsigned int counter; │ │ │ │ │ - 115}; │ │ │ │ │ - 116 │ │ │ │ │ - 117} /* namespace GridGlue */ │ │ │ │ │ - 118} /* namespace Dune */ │ │ │ │ │ +62 typedef Dune::FieldVector LocalCoords; │ │ │ │ │ + 63 │ │ │ │ │ +65 enum ProjectionType {OUTER_NORMAL, CLOSEST_POINT}; │ │ │ │ │ +73 ContactMerge(const T allowedOverlap=T(0), │ │ │ │ │ + 74 std::function domainDirections=nullptr, │ │ │ │ │ + 75 std::function targetDirections=nullptr, │ │ │ │ │ + 76 ProjectionType type = OUTER_NORMAL) │ │ │ │ │ + 77 : domainDirections_(domainDirections), targetDirections_(targetDirections), │ │ │ │ │ + 78 overlap_(allowedOverlap), type_(type) │ │ │ │ │ + 79 {} │ │ │ │ │ + 80 │ │ │ │ │ +86 ContactMerge(const T allowedOverlap, ProjectionType type) │ │ │ │ │ + 87 : overlap_(allowedOverlap), │ │ │ │ │ + 88 type_(type) │ │ │ │ │ + 89 {} │ │ │ │ │ + 90 │ │ │ │ │ + 99 inline │ │ │ │ │ +100 void setSurfaceDirections(std::function │ │ │ │ │ +domainDirections, │ │ │ │ │ + 101 std::function targetDirections) │ │ │ │ │ + 102 { │ │ │ │ │ + 103 domainDirections_ = domainDirections; │ │ │ │ │ + 104 targetDirections_ = targetDirections; │ │ │ │ │ + 105 this->valid = false; │ │ │ │ │ + 106 } │ │ │ │ │ + 107 │ │ │ │ │ +109 void setOverlap(T overlap) │ │ │ │ │ + 110 { │ │ │ │ │ + 111 overlap_ = overlap; │ │ │ │ │ + 112 } │ │ │ │ │ + 113 │ │ │ │ │ +115 T getOverlap() const │ │ │ │ │ + 116 { │ │ │ │ │ + 117 return overlap_; │ │ │ │ │ + 118 } │ │ │ │ │ 119 │ │ │ │ │ - 120#endif │ │ │ │ │ -intersectionlist.hh │ │ │ │ │ +123 void minNormalAngle(T angle) │ │ │ │ │ + 124 { │ │ │ │ │ + 125 using std::cos; │ │ │ │ │ + 126 maxNormalProduct_ = cos(angle); │ │ │ │ │ + 127 } │ │ │ │ │ + 128 │ │ │ │ │ +132 T minNormalAngle() const │ │ │ │ │ + 133 { │ │ │ │ │ + 134 using std::acos; │ │ │ │ │ + 135 return acos(maxNormalProduct_); │ │ │ │ │ + 136 } │ │ │ │ │ + 137 │ │ │ │ │ + 138protected: │ │ │ │ │ +139 typedef typename StandardMerge:: │ │ │ │ │ +SimplicialIntersection SimplicialIntersection; │ │ │ │ │ + 140 │ │ │ │ │ + 141private: │ │ │ │ │ + 145 std::function domainDirections_; │ │ │ │ │ + 146 std::vector nodalDomainDirections_; │ │ │ │ │ + 147 │ │ │ │ │ + 156 std::function targetDirections_; │ │ │ │ │ + 157 std::vector nodalTargetDirections_; │ │ │ │ │ + 158 │ │ │ │ │ + 160 T overlap_; │ │ │ │ │ + 161 │ │ │ │ │ + 163 ProjectionType type_; │ │ │ │ │ + 164 │ │ │ │ │ + 168 T maxNormalProduct_ = T(-0.1); │ │ │ │ │ + 169 │ │ │ │ │ + 174 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ + 175 const std::vector >& grid1ElementCorners, │ │ │ │ │ + 176 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ + 177 unsigned int grid1Index, │ │ │ │ │ + 178 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ + 179 const std::vector >& grid2ElementCorners, │ │ │ │ │ + 180 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ + 181 unsigned int grid2Index, │ │ │ │ │ + 182 std::vector& intersections) override; │ │ │ │ │ + 183 │ │ │ │ │ + 187protected: │ │ │ │ │ +188 void build(const std::vector >& grid1Coords, │ │ │ │ │ + 189 const std::vector& grid1Elements, │ │ │ │ │ + 190 const std::vector& grid1ElementTypes, │ │ │ │ │ + 191 const std::vector >& grid2Coords, │ │ │ │ │ + 192 const std::vector& grid2Elements, │ │ │ │ │ + 193 const std::vector& grid2ElementTypes) override │ │ │ │ │ + 194 { │ │ │ │ │ + 195 std::cout<<"ContactMerge building grid!\n"; │ │ │ │ │ + 196 // setup the nodal direction vectors │ │ │ │ │ + 197 setupNodalDirections(grid1Coords, grid1Elements, grid1ElementTypes, │ │ │ │ │ + 198 grid2Coords, grid2Elements, grid2ElementTypes); │ │ │ │ │ + 199 │ │ │ │ │ + 200 Base::build(grid1Coords, grid1Elements, grid1ElementTypes, │ │ │ │ │ + 201 grid2Coords, grid2Elements, grid2ElementTypes); │ │ │ │ │ + 202 │ │ │ │ │ + 203 } │ │ │ │ │ + 204 │ │ │ │ │ + 205private: │ │ │ │ │ + 206 │ │ │ │ │ + 208 static LocalCoords localCornerCoords(int i, const Dune::GeometryType& gt) │ │ │ │ │ + 209 { │ │ │ │ │ + 210 const auto& ref = Dune::ReferenceElements::general(gt); │ │ │ │ │ + 211 return ref.position(i,dim); │ │ │ │ │ + 212 } │ │ │ │ │ + 213 │ │ │ │ │ + 214protected: │ │ │ │ │ + 215 │ │ │ │ │ + 217 void computeCyclicOrder(const std::vector >& │ │ │ │ │ +polytopeCorners, │ │ │ │ │ + 218 const LocalCoords& center, std::vector& ordering) const; │ │ │ │ │ + 219 │ │ │ │ │ + 221 void setupNodalDirections(const std::vector& coords1, │ │ │ │ │ + 222 const std::vector& elements1, │ │ │ │ │ + 223 const std::vector& elementTypes1, │ │ │ │ │ + 224 const std::vector& coords2, │ │ │ │ │ + 225 const std::vector& elements2, │ │ │ │ │ + 226 const std::vector& elementTypes2); │ │ │ │ │ + 227 │ │ │ │ │ + 229 void computeOuterNormalField(const std::vector& coords, │ │ │ │ │ + 230 const std::vector& elements, │ │ │ │ │ + 231 const std::vector& elementTypes, │ │ │ │ │ + 232 std::vector& normals); │ │ │ │ │ + 233 │ │ │ │ │ + 235 void removeDoubles(std::vector >& │ │ │ │ │ +polytopeCorners); │ │ │ │ │ + 236}; │ │ │ │ │ + 237 │ │ │ │ │ + 238} /* namespace GridGlue */ │ │ │ │ │ + 239} /* namespace Dune */ │ │ │ │ │ + 240 │ │ │ │ │ + 241#include "contactmerge.cc" │ │ │ │ │ + 242 │ │ │ │ │ + 243#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ +gridglue.hh │ │ │ │ │ +Central component of the module implementing the coupling of two grids. │ │ │ │ │ +contactmerge.cc │ │ │ │ │ +standardmerge.hh │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. │ │ │ │ │ Dune │ │ │ │ │ Definition: gridglue.hh:37 │ │ │ │ │ -Dune::GridGlue::ProjectionImplementation::corner │ │ │ │ │ -Coordinate corner(unsigned c) │ │ │ │ │ -Definition: projection_impl.hh:24 │ │ │ │ │ -Dune::GridGlue::IntersectionList │ │ │ │ │ -Definition: intersectionlist.hh:134 │ │ │ │ │ -Dune::GridGlue::Merger │ │ │ │ │ -Abstract base for all classes that take extracted grids and build sets of │ │ │ │ │ -intersections. │ │ │ │ │ -Definition: merger.hh:27 │ │ │ │ │ -Dune::GridGlue::Merger::parent │ │ │ │ │ -unsigned int parent(unsigned int idx, unsigned int parId=0) const │ │ │ │ │ -get index of grid-n's parent simplex for given merged grid simplex │ │ │ │ │ -Definition: merger.hh:91 │ │ │ │ │ -Dune::GridGlue::Merger::clear │ │ │ │ │ -virtual void clear()=0 │ │ │ │ │ -Dune::GridGlue::Merger::WorldCoords │ │ │ │ │ -Dune::FieldVector< ctype, dimworld > WorldCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition: merger.hh:37 │ │ │ │ │ -Dune::GridGlue::Merger::Grid1Coords │ │ │ │ │ -Dune::FieldVector< ctype, grid1Dim > Grid1Coords │ │ │ │ │ -the local coordinate type for the grid1 coordinates │ │ │ │ │ -Definition: merger.hh:31 │ │ │ │ │ -Dune::GridGlue::Merger::counter │ │ │ │ │ -unsigned int counter │ │ │ │ │ -Counts the number of times the computeIntersection method has been called. │ │ │ │ │ -Definition: merger.hh:114 │ │ │ │ │ -Dune::GridGlue::Merger::parentLocal │ │ │ │ │ -auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId=0) │ │ │ │ │ +Dune::GridGlue::ContactMerge │ │ │ │ │ +Merge two codimension-1 surfaces that may be a positive distance apart. │ │ │ │ │ +Definition: contactmerge.hh:44 │ │ │ │ │ +Dune::GridGlue::ContactMerge::computeCyclicOrder │ │ │ │ │ +void computeCyclicOrder(const std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ +&polytopeCorners, const LocalCoords ¢er, std::vector< int > &ordering) │ │ │ │ │ const │ │ │ │ │ -get the grid-n parent's simplex local coordinates for a particular merged grid │ │ │ │ │ -simplex corner (parent... │ │ │ │ │ -Definition: merger.hh:105 │ │ │ │ │ -Dune::GridGlue::Merger::build │ │ │ │ │ -virtual void build(const std::vector< Dune::FieldVector< ctype, dimworld > > │ │ │ │ │ -&grid1_coords, const std::vector< unsigned int > &grid1_elements, const std:: │ │ │ │ │ -vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune:: │ │ │ │ │ -FieldVector< ctype, dimworld > > &grid2_coords, const std::vector< unsigned int │ │ │ │ │ -> &grid2_elements, const std::vector< Dune::GeometryType > │ │ │ │ │ -&grid2_element_types)=0 │ │ │ │ │ +Order the corners of the intersection polytope in cyclic order. │ │ │ │ │ +Definition: contactmerge.cc:214 │ │ │ │ │ +Dune::GridGlue::ContactMerge::SimplicialIntersection │ │ │ │ │ +StandardMerge< T, dimworld-1, dimworld-1, dimworld >::SimplicialIntersection │ │ │ │ │ +SimplicialIntersection │ │ │ │ │ +Definition: contactmerge.hh:139 │ │ │ │ │ +Dune::GridGlue::ContactMerge::removeDoubles │ │ │ │ │ +void removeDoubles(std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ +&polytopeCorners) │ │ │ │ │ +Remove all multiples. │ │ │ │ │ +Definition: contactmerge.cc:335 │ │ │ │ │ +Dune::GridGlue::ContactMerge::setOverlap │ │ │ │ │ +void setOverlap(T overlap) │ │ │ │ │ +Set the allowed overlap of the surfaces. │ │ │ │ │ +Definition: contactmerge.hh:109 │ │ │ │ │ +Dune::GridGlue::ContactMerge::WorldCoords │ │ │ │ │ +Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition: contactmerge.hh:59 │ │ │ │ │ +Dune::GridGlue::ContactMerge::setupNodalDirections │ │ │ │ │ +void setupNodalDirections(const std::vector< WorldCoords > &coords1, const │ │ │ │ │ +std::vector< unsigned int > &elements1, const std::vector< Dune::GeometryType > │ │ │ │ │ +&elementTypes1, const std::vector< WorldCoords > &coords2, const std::vector< │ │ │ │ │ +unsigned int > &elements2, const std::vector< Dune::GeometryType > │ │ │ │ │ +&elementTypes2) │ │ │ │ │ +Setup the direction vectors containing the directions for each vertex. │ │ │ │ │ +Definition: contactmerge.cc:269 │ │ │ │ │ +Dune::GridGlue::ContactMerge::minNormalAngle │ │ │ │ │ +void minNormalAngle(T angle) │ │ │ │ │ +set minimum angle in radians between normals at x and Φ(x) │ │ │ │ │ +Definition: contactmerge.hh:123 │ │ │ │ │ +Dune::GridGlue::ContactMerge::ctype │ │ │ │ │ +T ctype │ │ │ │ │ +the numeric type used in this interface │ │ │ │ │ +Definition: contactmerge.hh:56 │ │ │ │ │ +Dune::GridGlue::ContactMerge::ProjectionType │ │ │ │ │ +ProjectionType │ │ │ │ │ +Type of the projection, closest point or outer normal projection. │ │ │ │ │ +Definition: contactmerge.hh:65 │ │ │ │ │ +Dune::GridGlue::ContactMerge::CLOSEST_POINT │ │ │ │ │ +@ CLOSEST_POINT │ │ │ │ │ +Definition: contactmerge.hh:65 │ │ │ │ │ +Dune::GridGlue::ContactMerge::OUTER_NORMAL │ │ │ │ │ +@ OUTER_NORMAL │ │ │ │ │ +Definition: contactmerge.hh:65 │ │ │ │ │ +Dune::GridGlue::ContactMerge::computeOuterNormalField │ │ │ │ │ +void computeOuterNormalField(const std::vector< WorldCoords > &coords, const │ │ │ │ │ +std::vector< unsigned int > &elements, const std::vector< Dune::GeometryType > │ │ │ │ │ +&elementTypes, std::vector< WorldCoords > &normals) │ │ │ │ │ +If no direction field was specified compute the outer normal field. │ │ │ │ │ +Definition: contactmerge.cc:296 │ │ │ │ │ +Dune::GridGlue::ContactMerge::getOverlap │ │ │ │ │ +T getOverlap() const │ │ │ │ │ +Get the allowed overlap of the surfaces. │ │ │ │ │ +Definition: contactmerge.hh:115 │ │ │ │ │ +Dune::GridGlue::ContactMerge::ContactMerge │ │ │ │ │ +ContactMerge(const T allowedOverlap=T(0), std::function< WorldCoords │ │ │ │ │ +(WorldCoords)> domainDirections=nullptr, std::function< WorldCoords │ │ │ │ │ +(WorldCoords)> targetDirections=nullptr, ProjectionType type=OUTER_NORMAL) │ │ │ │ │ +Construct merger given overlap and possible projection directions. │ │ │ │ │ +Definition: contactmerge.hh:73 │ │ │ │ │ +Dune::GridGlue::ContactMerge::setSurfaceDirections │ │ │ │ │ +void setSurfaceDirections(std::function< WorldCoords(WorldCoords)> │ │ │ │ │ +domainDirections, std::function< WorldCoords(WorldCoords)> targetDirections) │ │ │ │ │ +Set surface direction functions. │ │ │ │ │ +Definition: contactmerge.hh:100 │ │ │ │ │ +Dune::GridGlue::ContactMerge::build │ │ │ │ │ +void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, │ │ │ │ │ +const std::vector< unsigned int > &grid1Elements, const std::vector< Dune:: │ │ │ │ │ +GeometryType > &grid1ElementTypes, const std::vector< Dune::FieldVector< T, │ │ │ │ │ +dimworld > > &grid2Coords, const std::vector< unsigned int > &grid2Elements, │ │ │ │ │ +const std::vector< Dune::GeometryType > &grid2ElementTypes) override │ │ │ │ │ +builds the merged grid │ │ │ │ │ +Definition: contactmerge.hh:188 │ │ │ │ │ +Dune::GridGlue::ContactMerge::ContactMerge │ │ │ │ │ +ContactMerge(const T allowedOverlap, ProjectionType type) │ │ │ │ │ +Construct merger given overlap and type of the projection. │ │ │ │ │ +Definition: contactmerge.hh:86 │ │ │ │ │ +Dune::GridGlue::ContactMerge::minNormalAngle │ │ │ │ │ +T minNormalAngle() const │ │ │ │ │ +get minimum angle in radians between normals at x and Φ(x) │ │ │ │ │ +Definition: contactmerge.hh:132 │ │ │ │ │ +Dune::GridGlue::ContactMerge::LocalCoords │ │ │ │ │ +Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition: contactmerge.hh:62 │ │ │ │ │ +Dune::GridGlue::StandardMerge │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. │ │ │ │ │ +Definition: standardmerge.hh:58 │ │ │ │ │ +Dune::GridGlue::StandardMerge::build │ │ │ │ │ +void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1_Coords, │ │ │ │ │ +const std::vector< unsigned int > &grid1_elements, const std::vector< Dune:: │ │ │ │ │ +GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< T, │ │ │ │ │ +dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, │ │ │ │ │ +const std::vector< Dune::GeometryType > &grid2_element_types) override │ │ │ │ │ builds the merged grid │ │ │ │ │ -Dune::GridGlue::Merger::nSimplices │ │ │ │ │ -unsigned int nSimplices() const │ │ │ │ │ -get the number of simplices in the merged grid The indices are then in │ │ │ │ │ -0..nSimplices()-1 │ │ │ │ │ -Definition: merger.hh:64 │ │ │ │ │ -Dune::GridGlue::Merger::intersectionList │ │ │ │ │ -virtual std::shared_ptr< IntersectionList > intersectionList() const =0 │ │ │ │ │ -Dune::GridGlue::Merger::parents │ │ │ │ │ -unsigned int parents(unsigned int idx) const │ │ │ │ │ -Definition: merger.hh:80 │ │ │ │ │ -Dune::GridGlue::Merger::Grid2Coords │ │ │ │ │ -Dune::FieldVector< ctype, grid2Dim > Grid2Coords │ │ │ │ │ -the local coordinate type for the grid2 coordinates │ │ │ │ │ -Definition: merger.hh:34 │ │ │ │ │ +Definition: standardmerge.hh:392 │ │ │ │ │ +Dune::GridGlue::StandardMerge<_double,_dimworld-1,_dimworld-1,_dimworld_>:: │ │ │ │ │ +valid │ │ │ │ │ +bool valid │ │ │ │ │ +Definition: standardmerge.hh:86 │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: simplexintersection.cc File Reference │ │ │ │ +dune-grid-glue: contactmerge.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,67 +63,27 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
simplexintersection.cc File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
contactmerge.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::GridGlue::SimplexMethod< dimWorld, dim1, dim2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 0, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 1, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 0, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 1, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 1, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 2, 2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 2, 3, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 3, 3, T >
 
│ │ │ │ +
#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ +#include <dune/grid-glue/common/projection.hh>
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 0 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 1 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 2 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
template<int dimworld, typename T >
void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 3 >, const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -5,65 +5,19 @@ │ │ │ │ │ │ │ │ │ │ dune-grid-glue 2.9 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -simplexintersection.cc File Reference │ │ │ │ │ - Classes │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_dim1,_dim2,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_> │ │ │ │ │ -  │ │ │ │ │ -class  Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_> │ │ │ │ │ -  │ │ │ │ │ +Namespaces │ │ │ │ │ +contactmerge.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Namespaces │ │ │ │ │ namespace  Dune │ │ │ │ │   │ │ │ │ │ namespace  Dune::GridGlue │ │ │ │ │   │ │ │ │ │ - Functions │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 0 >, │ │ │ │ │ - const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ - std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ - std::vector< int > > &faceIds) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 1 >, │ │ │ │ │ - const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ - std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ - std::vector< int > > &faceIds) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 2 >, │ │ │ │ │ - const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ - std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ - std::vector< int > > &faceIds) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void Dune::GridGlue::simplexSubdivision (std::integral_constant< int, 3 >, │ │ │ │ │ - const std::vector< Dune::FieldVector< T, dimworld > > &elementCorners, │ │ │ │ │ - std::vector< std::vector< unsigned int > > &subElements, std::vector< │ │ │ │ │ - std::vector< int > > &faceIds) │ │ │ │ │ -  │ │ │ │ │ │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.4 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: standardmerge.hh File Reference │ │ │ │ +dune-grid-glue: standardmerge.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -63,85 +63,55 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ Macros | │ │ │ │ Functions
│ │ │ │ -
standardmerge.hh File Reference
│ │ │ │ +
standardmerge.cc File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

Common base class for many merger implementations: produce pairs of entities that may intersect. │ │ │ │ -More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <iomanip>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <stack>
│ │ │ │ -#include <set>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <map>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/bitsetvector.hh>
│ │ │ │ -#include <dune/common/stdstreams.hh>
│ │ │ │ -#include <dune/common/timer.hh>
│ │ │ │ -#include <dune/geometry/referenceelements.hh>
│ │ │ │ -#include <dune/grid/common/grid.hh>
│ │ │ │ -#include <dune/grid-glue/merging/intersectionlist.hh>
│ │ │ │ -#include <dune/grid-glue/merging/merger.hh>
│ │ │ │ -#include <dune/grid-glue/merging/computeintersection.hh>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::GridGlue::StandardMerge< T, grid1Dim, grid2Dim, dimworld >
 Common base class for many merger implementations: produce pairs of entities that may intersect. More...
 
│ │ │ │ +
#include "config.h"
│ │ │ │ +#include "standardmerge.hh"
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Macros

#define DECL   extern
#define DECL
 
#define STANDARD_MERGE_INSTANTIATE(T, A, B, C)
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Functions

 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 1, 1, 1)
 
 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 2, 2, 2)
 
 Dune::GridGlue::STANDARD_MERGE_INSTANTIATE (double, 3, 3, 3)
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Common base class for many merger implementations: produce pairs of entities that may intersect.

│ │ │ │ -

Macro Definition Documentation

│ │ │ │ +

Macro Definition Documentation

│ │ │ │ │ │ │ │

◆ DECL

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │
#define DECL   extern#define DECL
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ @@ -178,22 +148,22 @@ │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ Value:
DECL template \
│ │ │ │ -
void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1Coords, \
│ │ │ │ +
void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1_coords, \
│ │ │ │
const std::vector<unsigned int>& grid1_elements, \
│ │ │ │
const std::vector<Dune::GeometryType>& grid1_element_types, \
│ │ │ │ -
const std::vector<Dune::FieldVector<T,C> >& grid2Coords, \
│ │ │ │ +
const std::vector<Dune::FieldVector<T,C> >& grid2_coords, \
│ │ │ │
const std::vector<unsigned int>& grid2_elements, \
│ │ │ │
const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │
)
│ │ │ │ -
#define DECL
Definition: standardmerge.hh:827
│ │ │ │ +
#define DECL
Definition: standardmerge.cc:12
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │