--- /srv/reproducible-results/rbuild-debian/r-b-build.LbKFBqPs/b1/dune-grid-glue_2.10.0-1_amd64.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.LbKFBqPs/b2/dune-grid-glue_2.10.0-1_amd64.changes ├── Files │ @@ -1,4 +1,4 @@ │ │ 825f7325168735546a531db06cd8b755 954080 debug optional libdune-grid-glue-dev-dbgsym_2.10.0-1_amd64.deb │ 2e548ba3dad82a9e4bf062b4ac864a10 109644 libdevel optional libdune-grid-glue-dev_2.10.0-1_amd64.deb │ - 3b6bc71956dd19413e7418f736ce66e2 958616 doc optional libdune-grid-glue-doc_2.10.0-1_all.deb │ + 353c76a7620887af8ab7eb756fa91260 958496 doc optional libdune-grid-glue-doc_2.10.0-1_all.deb ├── libdune-grid-glue-doc_2.10.0-1_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2024-11-14 21:31:44.000000 debian-binary │ │ --rw-r--r-- 0 0 0 7388 2024-11-14 21:31:44.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 951036 2024-11-14 21:31:44.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 7380 2024-11-14 21:31:44.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 950924 2024-11-14 21:31:44.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ │ │ │ ├── line order │ │ │ │ │ @@ -48,24 +48,24 @@ │ │ │ │ │ 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/a00080_source.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/a00089_source.html │ │ │ │ │ usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ │ +usr/share/doc/libdune-grid-glue-doc/doxygen/a00092_source.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 │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -5,77 +5,77 @@ │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 945 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/changelog.Debian.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1193 2024-09-04 15:07:05.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 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7139 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 81666 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5454 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 27384 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6158 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14374 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5322 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16900 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10872 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 70889 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8113 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 118079 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5798 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 52528 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5089 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16769 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8113 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 118079 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5089 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16769 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6158 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14374 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5798 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 52528 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5454 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 27384 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5322 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16900 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10872 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 70889 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5610 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 84448 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11614 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39772 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6620 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9139 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7371 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 44831 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5981 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 27622 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5361 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8501 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8223 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 30067 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8137 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 72682 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7676 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11026 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8137 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 72682 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00029_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7371 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 44831 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11614 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39772 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6620 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9139 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7676 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11026 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5361 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8501 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5981 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 27622 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00047_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8223 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 30067 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5430 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00053.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 44827 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00053_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8207 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 94036 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5563 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 70754 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5563 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 70754 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8207 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 94036 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5389 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 50227 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5485 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 36323 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00065_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12400 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 149555 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4560 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 63706 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5358 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22695 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4311 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 55660 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5968 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 37343 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5931 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19311 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11544 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 239994 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5968 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 37343 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10147 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5358 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22695 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6081 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 59846 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00083_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11544 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 239994 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6349 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45999 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10147 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5931 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19311 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6648 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 36463 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6648 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 36463 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4311 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 55660 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6349 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45999 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12400 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 149555 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4560 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 63706 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5860 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00101.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4620 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00103.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 67073 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00104.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5775 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00105.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 15143 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00106.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13627 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00107.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6281 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00108.html │ │ │ │ @@ -226,15 +226,15 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6781 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_65f347cff0208f20f00d27c542208238.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2198 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_65f347cff0208f20f00d27c542208238_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7641 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_68eff8a27dcb1cd0ff0ecf490070d3de.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13471 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_68eff8a27dcb1cd0ff0ecf490070d3de_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6671 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_eaad0bdad6fc03850e65b1fdad9faad4.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7018 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_eaad0bdad6fc03850e65b1fdad9faad4_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 45631 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/doxygen.css │ │ │ │ --rw-r--r-- 0 root (0) root (0) 27028 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dune-grid-glue.tag.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 27033 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dune-grid-glue.tag.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7704 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/dynsections.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 15974 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/files.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3222 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3787 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_b.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13457 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_c.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4847 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_d.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 6113 2024-11-14 21:31:44.000000 ./usr/share/doc/libdune-grid-glue-doc/doxygen/functions_e.html │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00002.html │ │ │ │ @@ -87,28 +87,28 @@ │ │ │ │ #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/rangegenerators.hh"
│ │ │ │ #include "adapter/gridglue.cc"
│ │ │ │ -#include "adapter/intersection.hh"
│ │ │ │ -#include "adapter/intersectioniterator.hh"
│ │ │ │ -#include "adapter/intersectionindexset.hh"
│ │ │ │ +#include "adapter/intersection.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 │ │ │ │ @@ -95,16 +95,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>
│ │ │ │ @@ -391,30 +391,30 @@ │ │ │ │ │ │ │ │
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"
│ │ │ │
406
│ │ │ │ -
407#include "adapter/intersection.hh"
│ │ │ │ -
408#include "adapter/intersectioniterator.hh"
│ │ │ │ -
409#include "adapter/intersectionindexset.hh"
│ │ │ │ +
407#include "adapter/intersection.hh"
│ │ │ │ +
408#include "adapter/intersectioniterator.hh"
│ │ │ │ +
409#include "adapter/intersectionindexset.hh"
│ │ │ │
410
│ │ │ │
411#endif // DUNE_GRIDGLUE_GRIDGLUE_HH
│ │ │ │ -
rangegenerators.hh
│ │ │ │ -
intersectioniterator.hh
Implement iterators over GridGlue intersections.
│ │ │ │ -
gridgluecommunicate.hh
Describes the parallel communication interface class for Dune::GridGlue.
│ │ │ │ -
intersection.hh
Model of the Intersection concept provided by GridGlue.
│ │ │ │ -
intersectionindexset.hh
│ │ │ │ +
intersection.hh
Model of the Intersection concept provided by GridGlue.
│ │ │ │ +
intersectionindexset.hh
│ │ │ │ +
rangegenerators.hh
│ │ │ │ +
intersectioniterator.hh
Implement iterators over GridGlue intersections.
│ │ │ │ +
gridgluecommunicate.hh
Describes the parallel communication interface class for Dune::GridGlue.
│ │ │ │
gridglue.cc
│ │ │ │ -
merger.hh
│ │ │ │ +
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 {} │ │ │ │ │ @@ -322,22 +322,22 @@ │ │ │ │ │ 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 │ │ │ │ │ +intersection.hh │ │ │ │ │ +Model of the Intersection concept provided by GridGlue. │ │ │ │ │ +intersectionindexset.hh │ │ │ │ │ rangegenerators.hh │ │ │ │ │ intersectioniterator.hh │ │ │ │ │ Implement iterators over GridGlue intersections. │ │ │ │ │ gridgluecommunicate.hh │ │ │ │ │ Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ -intersection.hh │ │ │ │ │ -Model of the Intersection concept provided by GridGlue. │ │ │ │ │ -intersectionindexset.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 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridglueamirawriter.hh File Reference │ │ │ │ +dune-grid-glue: intersection.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,42 +71,74 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
gridglueamirawriter.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Macros
│ │ │ │ +
intersection.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

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

Model of the Intersection concept provided by GridGlue. │ │ │ │ More...

│ │ │ │ -
#include <fstream>
│ │ │ │ -#include <sstream>
│ │ │ │ -#include <type_traits>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <optional>
│ │ │ │ +#include <tuple>
│ │ │ │ +#include <dune/common/deprecated.hh>
│ │ │ │ +#include <dune/common/version.hh>
│ │ │ │ +#include <dune/geometry/affinegeometry.hh>
│ │ │ │ +#include <dune/geometry/referenceelements.hh>
│ │ │ │ +#include <dune/grid-glue/gridglue.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::GridGlue< P0, P1 >
 sequential adapter to couple two grids at specified close together boundaries More...
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::GridGlueAmiraWriter
 Write remote intersections to a AmiraMesh file for debugging purposes. More...
class  Dune::GridGlue::IntersectionData< P0, P1 >
 storage class for Dune::GridGlue::Intersection related data More...
 
struct  Dune::GridGlue::IntersectionTraits< P0, P1, inside, outside >
 
class  Dune::GridGlue::Intersection< P0, P1, I, O >
 The intersection of two entities of the two patches of a GridGlue. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

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

│ │ │ │ +Macros

#define ONLY_SIMPLEX_INTERSECTIONS
 
│ │ │ │

Detailed Description

│ │ │ │ -

Write all remote intersections to a AmiraMesh file.

│ │ │ │ -
│ │ │ │ +

Model of the Intersection concept provided by GridGlue.

│ │ │ │ +
Author
Christian Engwer
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ ONLY_SIMPLEX_INTERSECTIONS

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,28 +1,46 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -gridglueamirawriter.hh File Reference │ │ │ │ │ -Write all remote intersections to a AmiraMesh file. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Macros │ │ │ │ │ +intersection.hh File Reference │ │ │ │ │ +Model of the Intersection concept provided by GridGlue. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#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... │ │ │ │ │ + class   Dune::GridGlue::IntersectionData<_P0,_P1_> │ │ │ │ │ +  storage class for Dune::GridGlue::Intersection related data More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::IntersectionTraits<_P0,_P1,_inside,_outside_> │ │ │ │ │ +  │ │ │ │ │ + class   Dune::GridGlue::Intersection<_P0,_P1,_I,_O_> │ │ │ │ │ +  The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +Macros │ │ │ │ │ +#define  ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Write all remote intersections to a AmiraMesh file. │ │ │ │ │ +Model of the Intersection concept provided by GridGlue. │ │ │ │ │ + Author │ │ │ │ │ + Christian Engwer │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ ONLY_SIMPLEX_INTERSECTIONS ***** │ │ │ │ │ +#define ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00005_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridglueamirawriter.hh Source File │ │ │ │ +dune-grid-glue: intersection.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,166 +74,569 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
gridglueamirawriter.hh
│ │ │ │ +
intersection.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
│ │ │ │ -
8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ -
9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ -
10
│ │ │ │ -
11#include <fstream>
│ │ │ │ -
12#include <sstream>
│ │ │ │ -
13#include <type_traits>
│ │ │ │ -
14
│ │ │ │ -
15namespace Dune {
│ │ │ │ -
16namespace GridGlue {
│ │ │ │ +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
│ │ │ │ +
11#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ +
12#define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ +
13
│ │ │ │ +
14#include <algorithm>
│ │ │ │ +
15#include <optional>
│ │ │ │ +
16#include <tuple>
│ │ │ │
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;
│ │ │ │ +
18#include <dune/common/deprecated.hh>
│ │ │ │ +
19#include <dune/common/version.hh>
│ │ │ │ +
20#include <dune/geometry/affinegeometry.hh>
│ │ │ │ +
21#include <dune/geometry/referenceelements.hh>
│ │ │ │ + │ │ │ │ +
23
│ │ │ │ +
24#define ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ +
25
│ │ │ │ +
26namespace Dune {
│ │ │ │ +
27 namespace GridGlue {
│ │ │ │ +
28
│ │ │ │ +
29 // forward declaration
│ │ │ │ +
30 template<typename P0, typename P1>
│ │ │ │ +
31 class IntersectionIndexSet;
│ │ │ │
32
│ │ │ │ -
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";
│ │ │ │ +
36 template<typename P0, typename P1>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
38 {
│ │ │ │ +
39 public:
│ │ │ │ +
40 typedef ::Dune::GridGlue::GridGlue<P0, P1> GridGlue;
│ │ │ │ +
41
│ │ │ │ + │ │ │ │
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 }
│ │ │ │ +
45 static constexpr int coorddim = GridGlue::dimworld;
│ │ │ │ +
46
│ │ │ │ +
47 private:
│ │ │ │ +
48 // intermediate quantities
│ │ │ │ +
49 template<int side>
│ │ │ │ +
50 static constexpr int dim() { return GridGlue::template GridView<side>::Grid::dimension - GridGlue::template GridPatch<side>::codim; }
│ │ │ │ +
51
│ │ │ │ +
52 public:
│ │ │ │ +
54 static constexpr int mydim = dim<0>() < dim<1>() ? dim<0>() : dim<1>();
│ │ │ │ +
55
│ │ │ │ +
56 template<int side>
│ │ │ │ +
57 using GridLocalGeometry = AffineGeometry<
│ │ │ │ +
58 typename GridGlue::template GridView<side>::ctype, mydim, GridGlue::template GridView<side>::dimension>;
│ │ │ │ +
59
│ │ │ │ +
60 using Grid0LocalGeometry [[deprecated("please use GridLocalGeometry<0> instead")]] = GridLocalGeometry<0>;
│ │ │ │ +
61 using Grid1LocalGeometry [[deprecated("please use GridLocalGeometry<1> instead")]] = GridLocalGeometry<1>;
│ │ │ │ +
62
│ │ │ │ +
63 template<int side>
│ │ │ │ +
64 using GridGeometry = AffineGeometry<
│ │ │ │ +
65 typename GridGlue::template GridView<side>::ctype, mydim, GridGlue::template GridView<side>::dimensionworld>;
│ │ │ │ +
66
│ │ │ │ +
67 using Grid0Geometry [[deprecated("please use GridGeometry<0> instead")]] = GridGeometry<0>;
│ │ │ │ +
68 using Grid1Geometry [[deprecated("please use GridGeometry<1> instead")]] = GridGeometry<1>;
│ │ │ │ +
69
│ │ │ │ +
70 template<int side>
│ │ │ │ +
71 using GridIndexType = typename GridGlue::template GridView<side>::IndexSet::IndexType;
│ │ │ │ +
72
│ │ │ │ +
73 using Grid0IndexType [[deprecated("please use GridIndexType<0> instead")]] = GridIndexType<0>;
│ │ │ │ +
74 using Grid1IndexType [[deprecated("please use GridIndexType<1> instead")]] = GridIndexType<1>;
│ │ │ │
75
│ │ │ │ -
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 }
│ │ │ │ +
77 IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int offset, bool grid0local, bool grid1local);
│ │ │ │ +
78
│ │ │ │ +
80 IntersectionData() = default;
│ │ │ │ +
81
│ │ │ │ +
82 /* Accessor Functions */
│ │ │ │ +
83
│ │ │ │ +
84 template<int side>
│ │ │ │ +
│ │ │ │ +
85 const GridLocalGeometry<side>& localGeometry(unsigned int parentId = 0) const
│ │ │ │ +
86 { return *std::get<side>(sideData_).gridlocalgeom[parentId]; }
│ │ │ │ +
│ │ │ │ +
87
│ │ │ │ +
88 template<int side>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
90 { return *std::get<side>(sideData_).gridgeom; }
│ │ │ │ +
│ │ │ │ +
91
│ │ │ │ +
92 template<int side>
│ │ │ │ +
│ │ │ │ +
93 bool local() const
│ │ │ │ +
94 { return std::get<side>(sideData_).gridlocal; }
│ │ │ │ +
│ │ │ │ +
95
│ │ │ │ +
96 template<int side>
│ │ │ │ +
│ │ │ │ +
97 IndexType index(unsigned int parentId = 0) const
│ │ │ │ +
98 { return std::get<side>(sideData_).gridindices[parentId]; }
│ │ │ │ +
│ │ │ │ +
99
│ │ │ │ +
100 template<int side>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
102 { return std::get<side>(sideData_).gridindices.size(); }
│ │ │ │ +
│ │ │ │ +
103
│ │ │ │ +
104 private:
│ │ │ │ +
105 template<int side>
│ │ │ │ +
106 void initializeGeometry(const GridGlue& glue, unsigned mergeindex);
│ │ │ │ +
107
│ │ │ │ +
108 /* M E M B E R V A R I A B L E S */
│ │ │ │ +
109
│ │ │ │ +
110 public:
│ │ │ │ + │ │ │ │ +
113
│ │ │ │ +
114 private:
│ │ │ │ +
115 template<int side>
│ │ │ │ +
116 struct SideData {
│ │ │ │ +
118 bool gridlocal = false;
│ │ │ │ +
119
│ │ │ │ +
121 std::vector< GridIndexType<side> > gridindices;
│ │ │ │ +
122
│ │ │ │ +
124 std::vector< std::optional< GridLocalGeometry<side> > > gridlocalgeom;
│ │ │ │
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 }
│ │ │ │ +
133 std::optional< GridGeometry<side> > gridgeom;
│ │ │ │ +
134 };
│ │ │ │ +
135
│ │ │ │ +
136 std::tuple< SideData<0>, SideData<1> > sideData_;
│ │ │ │ +
137 };
│ │ │ │
│ │ │ │ +
138
│ │ │ │ +
139 template<typename P0, typename P1>
│ │ │ │ +
140 template<int side>
│ │ │ │ +
141 void IntersectionData<P0, P1>::initializeGeometry(const GridGlue& glue, unsigned mergeindex)
│ │ │ │ +
142 {
│ │ │ │ +
143 auto& data = std::get<side>(sideData_);
│ │ │ │ +
144
│ │ │ │ +
145 const unsigned n_parents = glue.merger_->template parents<side>(mergeindex);
│ │ │ │
146
│ │ │ │ -
147};
│ │ │ │ +
147 // init containers
│ │ │ │ +
148 data.gridindices.resize(n_parents);
│ │ │ │ +
149 data.gridlocalgeom.resize(n_parents);
│ │ │ │ +
150
│ │ │ │ +
151 // default values
│ │ │ │ +
152 data.gridindices[0] = 0;
│ │ │ │ +
153
│ │ │ │ +
154 static constexpr int nSimplexCorners = mydim + 1;
│ │ │ │ +
155 using ctype = typename GridGlue::ctype;
│ │ │ │ +
156
│ │ │ │ +
157 // initialize the local and the global geometries of grid `side`
│ │ │ │ +
158
│ │ │ │ +
159 // compute the coordinates of the subface's corners in codim 0 entity local coordinates
│ │ │ │ +
160 static constexpr int elementdim = GridGlue::template GridView<side>::template Codim<0>::Geometry::mydimension;
│ │ │ │ +
161
│ │ │ │ +
162 // coordinates within the subentity that contains the remote intersection
│ │ │ │ +
163 std::array<Dune::FieldVector< ctype, dim<side>() >, nSimplexCorners> corners_subEntity_local;
│ │ │ │ +
164
│ │ │ │ +
165 for (unsigned int par = 0; par < n_parents; ++par) {
│ │ │ │ +
166 for (int i = 0; i < nSimplexCorners; ++i)
│ │ │ │ +
167 corners_subEntity_local[i] = glue.merger_->template parentLocal<side>(mergeindex, i, par);
│ │ │ │ +
168
│ │ │ │ +
169 // Coordinates of the remote intersection corners wrt the element coordinate system
│ │ │ │ +
170 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
│ │ │ │ +
171
│ │ │ │ +
172 if (data.gridlocal) {
│ │ │ │ +
173 data.gridindices[par] = glue.merger_->template parent<side>(mergeindex,par);
│ │ │ │ +
174
│ │ │ │ +
175 typename GridGlue::template GridPatch<side>::LocalGeometry
│ │ │ │ +
176 gridLocalGeometry = glue.template patch<side>().geometryLocal(data.gridindices[par]);
│ │ │ │ +
177 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
│ │ │ │ +
178 corners_element_local[i] = gridLocalGeometry.global(corners_subEntity_local[i]);
│ │ │ │ +
179 }
│ │ │ │ +
180
│ │ │ │ +
181 // set the corners of the local geometry
│ │ │ │ +
182#ifdef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ +
183 const Dune::GeometryType type = Dune::GeometryTypes::simplex(mydim);
│ │ │ │ +
184#else
│ │ │ │ +
185#error Not Implemented
│ │ │ │ +
186#endif
│ │ │ │ +
187 data.gridlocalgeom[par].emplace(type, corners_element_local);
│ │ │ │ +
188
│ │ │ │ +
189 // Add world geometry only for 0th parent
│ │ │ │ +
190 if (par == 0) {
│ │ │ │ +
191 typename GridGlue::template GridPatch<side>::Geometry
│ │ │ │ +
192 gridWorldGeometry = glue.template patch<side>().geometry(data.gridindices[par]);
│ │ │ │ +
193
│ │ │ │ +
194 // world coordinates of the remote intersection corners
│ │ │ │ +
195 std::array<Dune::FieldVector<ctype, GridGlue::template GridView<side>::dimensionworld>, nSimplexCorners> corners_global;
│ │ │ │ +
196
│ │ │ │ +
197 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
│ │ │ │ +
198 corners_global[i] = gridWorldGeometry.global(corners_subEntity_local[i]);
│ │ │ │ +
199 }
│ │ │ │ +
200
│ │ │ │ +
201 data.gridgeom.emplace(type, corners_global);
│ │ │ │ +
202 }
│ │ │ │ +
203 }
│ │ │ │ +
204 }
│ │ │ │ +
205 }
│ │ │ │ +
206
│ │ │ │ +
208 template<typename P0, typename P1>
│ │ │ │ +
│ │ │ │ +
209 IntersectionData<P0, P1>::IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int offset,
│ │ │ │ +
210 bool grid0local, bool grid1local)
│ │ │ │ +
211 : index_(mergeindex+offset)
│ │ │ │ +
212 {
│ │ │ │ +
213 // if an invalid index is given do not proceed!
│ │ │ │ +
214 // (happens when the parent GridGlue initializes the "end"-Intersection)
│ │ │ │ +
215 assert (0 <= mergeindex || mergeindex < glue.index__sz);
│ │ │ │ +
216
│ │ │ │ +
217 std::get<0>(sideData_).gridlocal = grid0local;
│ │ │ │ +
218 std::get<1>(sideData_).gridlocal = grid1local;
│ │ │ │ +
219
│ │ │ │ +
220 initializeGeometry<0>(glue, mergeindex);
│ │ │ │ +
221 initializeGeometry<1>(glue, mergeindex);
│ │ │ │ +
222 }
│ │ │ │ +
│ │ │ │ +
223
│ │ │ │ +
228 template<typename P0, typename P1, int inside, int outside>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
230 {
│ │ │ │ + │ │ │ │ + │ │ │ │ +
233
│ │ │ │ +
234 using InsideGridView = typename GridGlue::template GridView<inside>;
│ │ │ │ +
235 using OutsideGridView = typename GridGlue::template GridView<outside>;
│ │ │ │ +
236
│ │ │ │ +
237 using InsideLocalGeometry = typename IntersectionData::template GridLocalGeometry<inside>;
│ │ │ │ +
238 using OutsideLocalGeometry = typename IntersectionData::template GridLocalGeometry<outside>;
│ │ │ │ +
239
│ │ │ │ +
240 using Geometry = typename IntersectionData::template GridGeometry<inside>;
│ │ │ │ +
241 using OutsideGeometry = typename IntersectionData::template GridGeometry<outside>;
│ │ │ │ +
242
│ │ │ │ +
243 static constexpr auto coorddim = IntersectionData::coorddim;
│ │ │ │ +
244 static constexpr auto mydim = IntersectionData::mydim;
│ │ │ │ +
245 static constexpr int insidePatch = inside;
│ │ │ │ +
246 static constexpr int outsidePatch = outside;
│ │ │ │ +
247
│ │ │ │ +
248 using ctype = typename GridGlue::ctype;
│ │ │ │ +
249 using LocalCoordinate = Dune::FieldVector<ctype, mydim>;
│ │ │ │ +
250 using GlobalCoordinate = Dune::FieldVector<ctype, coorddim>;
│ │ │ │ +
251 };
│ │ │ │ +
│ │ │ │ +
252
│ │ │ │ +
255 template<typename P0, typename P1, int I, int O>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
257 {
│ │ │ │ +
258
│ │ │ │ +
259 public:
│ │ │ │ +
260
│ │ │ │ + │ │ │ │ +
262
│ │ │ │ +
263 typedef typename Traits::GridGlue GridGlue;
│ │ │ │ + │ │ │ │ +
265
│ │ │ │ +
266
│ │ │ │ + │ │ │ │ + │ │ │ │ +
269
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
273
│ │ │ │ +
274 typedef typename Traits::Geometry Geometry;
│ │ │ │ +
275 typedef typename Traits::ctype ctype;
│ │ │ │ +
276
│ │ │ │ +
277 typedef typename InsideGridView::Traits::template Codim<0>::Entity InsideEntity;
│ │ │ │ +
278 typedef typename OutsideGridView::Traits::template Codim<0>::Entity OutsideEntity;
│ │ │ │ +
279
│ │ │ │ + │ │ │ │ + │ │ │ │ +
282
│ │ │ │ +
284 static constexpr auto coorddim = Traits::coorddim;
│ │ │ │ +
285
│ │ │ │ +
287 static constexpr auto mydim = Traits::mydim;
│ │ │ │ +
288
│ │ │ │ +
290 static constexpr int insidePatch = Traits::insidePatch;
│ │ │ │ +
291
│ │ │ │ +
293 static constexpr int outsidePatch = Traits::outsidePatch;
│ │ │ │ +
294
│ │ │ │ +
295 // typedef unsigned int IndexType;
│ │ │ │ +
296
│ │ │ │ +
297 private:
│ │ │ │ +
301 static constexpr int codimensionWorld = coorddim - mydim;
│ │ │ │ +
302
│ │ │ │ +
303 public:
│ │ │ │ +
304 /* C O N S T R U C T O R S */
│ │ │ │ +
305
│ │ │ │ +
│ │ │ │ +
307 Intersection(const GridGlue* glue, const IntersectionData* i) :
│ │ │ │ +
308 glue_(glue), i_(i) {}
│ │ │ │ +
│ │ │ │ +
309
│ │ │ │ +
310 /* F U N C T I O N A L I T Y */
│ │ │ │ +
311
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
315 inside(unsigned int parentId = 0) const
│ │ │ │ +
316 {
│ │ │ │ +
317 assert(self());
│ │ │ │ +
318 return glue_->template patch<I>().element(i_->template index<I>(parentId));
│ │ │ │ +
319 }
│ │ │ │ +
│ │ │ │ +
320
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
324 outside(unsigned int parentId = 0) const
│ │ │ │ +
325 {
│ │ │ │ +
326 assert(neighbor());
│ │ │ │ +
327 return glue_->template patch<O>().element(i_->template index<O>(parentId));
│ │ │ │ +
328 }
│ │ │ │ +
│ │ │ │ +
329
│ │ │ │ +
│ │ │ │ +
331 bool conforming() const
│ │ │ │ +
332 {
│ │ │ │ +
333 throw Dune::NotImplemented();
│ │ │ │ +
334 }
│ │ │ │ +
│ │ │ │ +
335
│ │ │ │ +
│ │ │ │ +
338 const InsideLocalGeometry& geometryInInside(unsigned int parentId = 0) const
│ │ │ │ +
339 {
│ │ │ │ +
340 return i_->template localGeometry<I>(parentId);
│ │ │ │ +
341 }
│ │ │ │ +
│ │ │ │ +
342
│ │ │ │ +
│ │ │ │ +
345 const OutsideLocalGeometry& geometryInOutside(unsigned int parentId = 0) const
│ │ │ │ +
346 {
│ │ │ │ +
347 return i_->template localGeometry<O>(parentId);
│ │ │ │ +
348 }
│ │ │ │ +
│ │ │ │ +
349
│ │ │ │ +
│ │ │ │ +
356 const Geometry& geometry() const
│ │ │ │ +
357 {
│ │ │ │ +
358 return i_->template geometry<I>();
│ │ │ │ +
359 }
│ │ │ │ +
│ │ │ │ +
360
│ │ │ │ +
│ │ │ │ +
367 const OutsideGeometry& geometryOutside() const // DUNE_DEPRECATED
│ │ │ │ +
368 {
│ │ │ │ +
369 return i_->template geometry<O>();
│ │ │ │ +
370 }
│ │ │ │ +
│ │ │ │ +
371
│ │ │ │ +
│ │ │ │ +
373 Dune::GeometryType type() const
│ │ │ │ +
374 {
│ │ │ │ +
375 #ifdef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ +
376 return Dune::GeometryTypes::simplex(mydim);
│ │ │ │ +
377 #else
│ │ │ │ +
378 #error Not Implemented
│ │ │ │ +
379 #endif
│ │ │ │ +
380 }
│ │ │ │ +
│ │ │ │ +
381
│ │ │ │ +
382
│ │ │ │ +
│ │ │ │ +
384 bool self() const
│ │ │ │ +
385 {
│ │ │ │ +
386 return i_->template local<I>();
│ │ │ │ +
387 }
│ │ │ │ +
│ │ │ │ +
388
│ │ │ │ +
│ │ │ │ +
390 size_t neighbor(unsigned int g = 0) const
│ │ │ │ +
391 {
│ │ │ │ +
392 if (g == 0 && i_->template local<O>()) {
│ │ │ │ +
393 return i_->template parents<O>();
│ │ │ │ +
394 } else if (g == 1 && i_->template local<I>()) {
│ │ │ │ +
395 return i_->template parents<I>();
│ │ │ │ +
396 }
│ │ │ │ +
397 return 0;
│ │ │ │ +
398 }
│ │ │ │ +
│ │ │ │ +
399
│ │ │ │ +
│ │ │ │ +
401 int indexInInside(unsigned int parentId = 0) const
│ │ │ │ +
402 {
│ │ │ │ +
403 assert(self());
│ │ │ │ +
404 return glue_->template patch<I>().indexInInside(i_->template index<I>(parentId));
│ │ │ │ +
405 }
│ │ │ │ +
│ │ │ │ +
406
│ │ │ │ +
│ │ │ │ +
408 int indexInOutside(unsigned int parentId = 0) const
│ │ │ │ +
409 {
│ │ │ │ +
410 assert(neighbor());
│ │ │ │ +
411 return glue_->template patch<O>().indexInInside(i_->template index<O>(parentId));
│ │ │ │ +
412 }
│ │ │ │ +
│ │ │ │ +
413
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
419 {
│ │ │ │ +
420 GlobalCoordinate normal;
│ │ │ │ +
421
│ │ │ │ +
422 if (codimensionWorld == 0)
│ │ │ │ +
423 DUNE_THROW(Dune::Exception, "There is no normal vector to a full-dimensional intersection");
│ │ │ │ +
424 else if (codimensionWorld == 1) {
│ │ │ │ +
425 /* TODO: Implement the general n-ary cross product here */
│ │ │ │ +
426 const auto jacobianTransposed = geometry().jacobianTransposed(local);
│ │ │ │ +
427 if (mydim==1) {
│ │ │ │ +
428 normal[0] = - jacobianTransposed[0][1];
│ │ │ │ +
429 normal[1] = jacobianTransposed[0][0];
│ │ │ │ +
430 } else if (mydim==2) {
│ │ │ │ +
431 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
│ │ │ │ +
432 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
│ │ │ │ +
433 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
│ │ │ │ +
434 } else
│ │ │ │ +
435 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the 'outerNormal' method for " << mydim << "-dimensional intersections yet");
│ │ │ │ +
436 } else
│ │ │ │ +
437 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
│ │ │ │ +
438
│ │ │ │ +
439 return normal;
│ │ │ │ +
440 }
│ │ │ │ +
│ │ │ │ +
441
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
447 {
│ │ │ │ +
448 GlobalCoordinate normal = outerNormal(local);
│ │ │ │ +
449 normal /= normal.two_norm();
│ │ │ │ +
450 return normal;
│ │ │ │ +
451 }
│ │ │ │ +
│ │ │ │ +
452
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
458 {
│ │ │ │ +
459 return (unitOuterNormal(local) *= geometry().integrationElement(local));
│ │ │ │ +
460 }
│ │ │ │ +
│ │ │ │ +
461
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
467 {
│ │ │ │ +
468 return unitOuterNormal(ReferenceElements<ctype,mydim>::general(type()).position(0,0));
│ │ │ │ +
469 }
│ │ │ │ +
│ │ │ │ +
470
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
475 {
│ │ │ │ +
476 return Intersection<P0,P1,O,I>(glue_,i_);
│ │ │ │ +
477 }
│ │ │ │ +
│ │ │ │ +
478
│ │ │ │ +
479#ifdef QUICKHACK_INDEX
│ │ │ │ +
480 typedef typename GridGlue::IndexType IndexType;
│ │ │ │ +
481
│ │ │ │ +
482 IndexType index() const
│ │ │ │ +
483 {
│ │ │ │ +
484 return i_->index_;
│ │ │ │ +
485 }
│ │ │ │ +
486
│ │ │ │ +
487#endif
│ │ │ │ +
488
│ │ │ │ +
489 private:
│ │ │ │ +
490
│ │ │ │ +
491 friend class IntersectionIndexSet<P0,P1>;
│ │ │ │ +
492
│ │ │ │ +
493 /* M E M B E R V A R I A B L E S */
│ │ │ │ +
494
│ │ │ │ +
496 const GridGlue* glue_;
│ │ │ │ +
497
│ │ │ │ +
499 const IntersectionData* i_;
│ │ │ │ +
500 };
│ │ │ │
│ │ │ │ -
148
│ │ │ │ -
149} // namespace GridGlue
│ │ │ │ -
150} // namespace Dune
│ │ │ │ -
151
│ │ │ │ -
152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ +
501
│ │ │ │ +
502
│ │ │ │ +
503 } // end namespace GridGlue
│ │ │ │ +
504} // end namespace Dune
│ │ │ │ +
505
│ │ │ │ +
506#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ +
Central component of the module implementing the coupling of two grids.
│ │ │ │
Definition gridglue.hh:37
│ │ │ │ -
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
│ │ │ │ +
sequential adapter to couple two grids at specified close together boundaries
Definition gridglue.hh:67
│ │ │ │ +
unsigned int IndexType
Definition gridglue.hh:147
│ │ │ │ +
PromotionTraits< typenameGridView< 0 >::ctype, typenameGridView< 1 >::ctype >::PromotedType ctype
The type used for coordinates.
Definition gridglue.hh:171
│ │ │ │ +
static constexpr int dimworld
export the world dimension This is the maximum of the extractors' world dimensions.
Definition gridglue.hh:166
│ │ │ │ +
storage class for Dune::GridGlue::Intersection related data
Definition intersection.hh:38
│ │ │ │ +
GridGlue::IndexType IndexType
Definition intersection.hh:42
│ │ │ │ +
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimensionworld > GridGeometry
Definition intersection.hh:65
│ │ │ │ +
const GridLocalGeometry< side > & localGeometry(unsigned int parentId=0) const
Definition intersection.hh:85
│ │ │ │ +
static constexpr int coorddim
Dimension of the world space of the intersection.
Definition intersection.hh:45
│ │ │ │ +
GridGeometry< 0 > Grid0Geometry
Definition intersection.hh:67
│ │ │ │ +
typename GridGlue::template GridView< side >::IndexSet::IndexType GridIndexType
Definition intersection.hh:71
│ │ │ │ +
IndexType index(unsigned int parentId=0) const
Definition intersection.hh:97
│ │ │ │ +
IndexType parents() const
Definition intersection.hh:101
│ │ │ │ +
GridLocalGeometry< 1 > Grid1LocalGeometry
Definition intersection.hh:61
│ │ │ │ +
const GridGeometry< side > & geometry() const
Definition intersection.hh:89
│ │ │ │ +
bool local() const
Definition intersection.hh:93
│ │ │ │ +
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition intersection.hh:40
│ │ │ │ +
static constexpr int mydim
Dimension of the intersection.
Definition intersection.hh:54
│ │ │ │ +
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimension > GridLocalGeometry
Definition intersection.hh:58
│ │ │ │ +
GridLocalGeometry< 0 > Grid0LocalGeometry
Definition intersection.hh:60
│ │ │ │ +
IndexType index_
index of this intersection after GridGlue interface
Definition intersection.hh:112
│ │ │ │ +
GridIndexType< 1 > Grid1IndexType
Definition intersection.hh:74
│ │ │ │ +
GridGeometry< 1 > Grid1Geometry
Definition intersection.hh:68
│ │ │ │ +
GridIndexType< 0 > Grid0IndexType
Definition intersection.hh:73
│ │ │ │ +
IntersectionData()=default
Default Constructor.
│ │ │ │ +
The intersection of two entities of the two patches of a GridGlue.
Definition intersection.hh:257
│ │ │ │ +
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition intersection.hh:271
│ │ │ │ +
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition intersection.hh:474
│ │ │ │ +
bool conforming() const
Return true if intersection is conforming.
Definition intersection.hh:331
│ │ │ │ +
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition intersection.hh:277
│ │ │ │ +
Traits::GridGlue GridGlue
Definition intersection.hh:263
│ │ │ │ +
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in.
Definition intersection.hh:408
│ │ │ │ +
int indexInInside(unsigned int parentId=0) const
Local number of codim 1 entity in the inside() Entity where intersection is contained in.
Definition intersection.hh:401
│ │ │ │ +
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition intersection.hh:384
│ │ │ │ +
static constexpr auto mydim
dimension of the intersection
Definition intersection.hh:287
│ │ │ │ +
static constexpr int outsidePatch
outside patch
Definition intersection.hh:293
│ │ │ │ +
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition intersection.hh:373
│ │ │ │ +
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition intersection.hh:315
│ │ │ │ +
Traits::LocalCoordinate LocalCoordinate
Definition intersection.hh:280
│ │ │ │ +
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() element.
Definition intersection.hh:345
│ │ │ │ +
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return a unit outer normal.
Definition intersection.hh:446
│ │ │ │ +
Traits::ctype ctype
Definition intersection.hh:275
│ │ │ │ +
IntersectionTraits< P0, P1, I, O > Traits
Definition intersection.hh:261
│ │ │ │ +
Traits::IntersectionData IntersectionData
Definition intersection.hh:264
│ │ │ │ +
Traits::GlobalCoordinate GlobalCoordinate
Definition intersection.hh:281
│ │ │ │ +
Traits::OutsideGeometry OutsideGeometry
Definition intersection.hh:272
│ │ │ │ +
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition intersection.hh:390
│ │ │ │ +
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition intersection.hh:307
│ │ │ │ +
static constexpr int insidePatch
inside patch
Definition intersection.hh:290
│ │ │ │ +
Traits::Geometry Geometry
Definition intersection.hh:274
│ │ │ │ +
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition intersection.hh:278
│ │ │ │ +
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition intersection.hh:324
│ │ │ │ +
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition intersection.hh:356
│ │ │ │ +
Traits::InsideLocalGeometry InsideLocalGeometry
Definition intersection.hh:268
│ │ │ │ +
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition intersection.hh:418
│ │ │ │ +
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition intersection.hh:367
│ │ │ │ +
Traits::OutsideGridView OutsideGridView
Definition intersection.hh:270
│ │ │ │ +
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Return an outer normal with the length of the integration element.
Definition intersection.hh:457
│ │ │ │ +
Traits::InsideGridView InsideGridView
Definition intersection.hh:267
│ │ │ │ +
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() element.
Definition intersection.hh:338
│ │ │ │ +
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition intersection.hh:466
│ │ │ │ +
static constexpr auto coorddim
dimension of the world space of the intersection
Definition intersection.hh:284
│ │ │ │ +
Definition intersection.hh:230
│ │ │ │ +
static constexpr int insidePatch
Definition intersection.hh:245
│ │ │ │ +
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition intersection.hh:249
│ │ │ │ +
static constexpr auto coorddim
Definition intersection.hh:243
│ │ │ │ +
typename IntersectionData::template GridGeometry< outside > OutsideGeometry
Definition intersection.hh:241
│ │ │ │ +
typename GridGlue::ctype ctype
Definition intersection.hh:248
│ │ │ │ +
typename GridGlue::template GridView< outside > OutsideGridView
Definition intersection.hh:235
│ │ │ │ +
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition intersection.hh:250
│ │ │ │ +
typename IntersectionData::template GridLocalGeometry< outside > OutsideLocalGeometry
Definition intersection.hh:238
│ │ │ │ +
typename GridGlue::template GridView< inside > InsideGridView
Definition intersection.hh:234
│ │ │ │ +
typename IntersectionData::template GridGeometry< inside > Geometry
Definition intersection.hh:240
│ │ │ │ +
typename IntersectionData::template GridLocalGeometry< inside > InsideLocalGeometry
Definition intersection.hh:237
│ │ │ │ +
static constexpr int outsidePatch
Definition intersection.hh:246
│ │ │ │ +
static constexpr auto mydim
Definition intersection.hh:244
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,165 +1,743 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -gridglueamirawriter.hh │ │ │ │ │ +intersection.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-with- │ │ │ │ │ +4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with- │ │ │ │ │ dune-grid-glue-exception │ │ │ │ │ -8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ -9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ -10 │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14 │ │ │ │ │ -15namespace Dune { │ │ │ │ │ -16namespace GridGlue { │ │ │ │ │ +11#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ +12#define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ +13 │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ 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; │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ +23 │ │ │ │ │ +24#define ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ +25 │ │ │ │ │ +26namespace Dune { │ │ │ │ │ +27 namespace GridGlue { │ │ │ │ │ +28 │ │ │ │ │ +29 // forward declaration │ │ │ │ │ +30 template │ │ │ │ │ +31 class IntersectionIndexSet; │ │ │ │ │ 32 │ │ │ │ │ -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"; │ │ │ │ │ +36 template │ │ │ │ │ +37 class IntersectionData │ │ │ │ │ +38 { │ │ │ │ │ +39 public: │ │ │ │ │ +40 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ +41 │ │ │ │ │ +42 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ 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 } │ │ │ │ │ +45 static constexpr int coorddim = GridGlue::dimworld; │ │ │ │ │ +46 │ │ │ │ │ +47 private: │ │ │ │ │ +48 // intermediate quantities │ │ │ │ │ +49 template │ │ │ │ │ +50 static constexpr int dim() { return GridGlue::template GridView:: │ │ │ │ │ +Grid::dimension - GridGlue::template GridPatch::codim; } │ │ │ │ │ +51 │ │ │ │ │ +52 public: │ │ │ │ │ +54 static constexpr int mydim = dim<0>() < dim<1>() ? dim<0>() : dim<1>(); │ │ │ │ │ +55 │ │ │ │ │ +56 template │ │ │ │ │ +57 using GridLocalGeometry = AffineGeometry< │ │ │ │ │ +58 typename GridGlue::template GridView::ctype, mydim, GridGlue::template │ │ │ │ │ +GridView::dimension>; │ │ │ │ │ +59 │ │ │ │ │ +60 using Grid0LocalGeometry [[deprecated("please use GridLocalGeometry<0> │ │ │ │ │ +instead")]] = GridLocalGeometry<0>; │ │ │ │ │ +61 using Grid1LocalGeometry [[deprecated("please use GridLocalGeometry<1> │ │ │ │ │ +instead")]] = GridLocalGeometry<1>; │ │ │ │ │ +62 │ │ │ │ │ +63 template │ │ │ │ │ +64 using GridGeometry = AffineGeometry< │ │ │ │ │ +65 typename GridGlue::template GridView::ctype, mydim, GridGlue::template │ │ │ │ │ +GridView::dimensionworld>; │ │ │ │ │ +66 │ │ │ │ │ +67 using Grid0Geometry [[deprecated("please use GridGeometry<0> instead")]] = │ │ │ │ │ +GridGeometry<0>; │ │ │ │ │ +68 using Grid1Geometry [[deprecated("please use GridGeometry<1> instead")]] = │ │ │ │ │ +GridGeometry<1>; │ │ │ │ │ +69 │ │ │ │ │ +70 template │ │ │ │ │ +71 using GridIndexType = typename GridGlue::template GridView::IndexSet:: │ │ │ │ │ +IndexType; │ │ │ │ │ +72 │ │ │ │ │ +73 using Grid0IndexType [[deprecated("please use GridIndexType<0> instead")]] = │ │ │ │ │ +GridIndexType<0>; │ │ │ │ │ +74 using Grid1IndexType [[deprecated("please use GridIndexType<1> instead")]] = │ │ │ │ │ +GridIndexType<1>; │ │ │ │ │ 75 │ │ │ │ │ -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 } │ │ │ │ │ +77 IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int │ │ │ │ │ +offset, bool grid0local, bool grid1local); │ │ │ │ │ +78 │ │ │ │ │ +80 IntersectionData() = default; │ │ │ │ │ +81 │ │ │ │ │ +82 /* Accessor Functions */ │ │ │ │ │ +83 │ │ │ │ │ +84 template │ │ │ │ │ +85 const GridLocalGeometry& localGeometry(unsigned int parentId = 0) │ │ │ │ │ +const │ │ │ │ │ +86 { return *std::get(sideData_).gridlocalgeom[parentId]; } │ │ │ │ │ +87 │ │ │ │ │ +88 template │ │ │ │ │ +89 const GridGeometry& geometry() const │ │ │ │ │ +90 { return *std::get(sideData_).gridgeom; } │ │ │ │ │ +91 │ │ │ │ │ +92 template │ │ │ │ │ +93 bool local() const │ │ │ │ │ +94 { return std::get(sideData_).gridlocal; } │ │ │ │ │ +95 │ │ │ │ │ +96 template │ │ │ │ │ +97 IndexType index(unsigned int parentId = 0) const │ │ │ │ │ +98 { return std::get(sideData_).gridindices[parentId]; } │ │ │ │ │ +99 │ │ │ │ │ +100 template │ │ │ │ │ +101 IndexType parents() const │ │ │ │ │ +102 { return std::get(sideData_).gridindices.size(); } │ │ │ │ │ +103 │ │ │ │ │ +104 private: │ │ │ │ │ +105 template │ │ │ │ │ +106 void initializeGeometry(const GridGlue& glue, unsigned mergeindex); │ │ │ │ │ +107 │ │ │ │ │ +108 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ +109 │ │ │ │ │ +110 public: │ │ │ │ │ +112 IndexType index_; │ │ │ │ │ +113 │ │ │ │ │ +114 private: │ │ │ │ │ +115 template │ │ │ │ │ +116 struct SideData { │ │ │ │ │ +118 bool gridlocal = false; │ │ │ │ │ +119 │ │ │ │ │ +121 std::vector< GridIndexType > gridindices; │ │ │ │ │ +122 │ │ │ │ │ +124 std::vector< std::optional< GridLocalGeometry > > gridlocalgeom; │ │ │ │ │ 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 } │ │ │ │ │ +133 std::optional< GridGeometry > gridgeom; │ │ │ │ │ +134 }; │ │ │ │ │ +135 │ │ │ │ │ +136 std::tuple< SideData<0>, SideData<1> > sideData_; │ │ │ │ │ +137 }; │ │ │ │ │ +138 │ │ │ │ │ +139 template │ │ │ │ │ +140 template │ │ │ │ │ +141 void IntersectionData::initializeGeometry(const GridGlue& glue, │ │ │ │ │ +unsigned mergeindex) │ │ │ │ │ +142 { │ │ │ │ │ +143 auto& data = std::get(sideData_); │ │ │ │ │ +144 │ │ │ │ │ +145 const unsigned n_parents = glue.merger_->template parents │ │ │ │ │ +(mergeindex); │ │ │ │ │ 146 │ │ │ │ │ -147}; │ │ │ │ │ -148 │ │ │ │ │ -149} // namespace GridGlue │ │ │ │ │ -150} // namespace Dune │ │ │ │ │ -151 │ │ │ │ │ -152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ +147 // init containers │ │ │ │ │ +148 data.gridindices.resize(n_parents); │ │ │ │ │ +149 data.gridlocalgeom.resize(n_parents); │ │ │ │ │ +150 │ │ │ │ │ +151 // default values │ │ │ │ │ +152 data.gridindices[0] = 0; │ │ │ │ │ +153 │ │ │ │ │ +154 static constexpr int nSimplexCorners = mydim + 1; │ │ │ │ │ +155 using ctype = typename GridGlue::ctype; │ │ │ │ │ +156 │ │ │ │ │ +157 // initialize the local and the global geometries of grid `side` │ │ │ │ │ +158 │ │ │ │ │ +159 // compute the coordinates of the subface's corners in codim 0 entity local │ │ │ │ │ +coordinates │ │ │ │ │ +160 static constexpr int elementdim = GridGlue::template GridView:: │ │ │ │ │ +template Codim<0>::Geometry::mydimension; │ │ │ │ │ +161 │ │ │ │ │ +162 // coordinates within the subentity that contains the remote intersection │ │ │ │ │ +163 std::array() >, nSimplexCorners> │ │ │ │ │ +corners_subEntity_local; │ │ │ │ │ +164 │ │ │ │ │ +165 for (unsigned int par = 0; par < n_parents; ++par) { │ │ │ │ │ +166 for (int i = 0; i < nSimplexCorners; ++i) │ │ │ │ │ +167 corners_subEntity_local[i] = glue.merger_->template parentLocal │ │ │ │ │ +(mergeindex, i, par); │ │ │ │ │ +168 │ │ │ │ │ +169 // Coordinates of the remote intersection corners wrt the element │ │ │ │ │ +coordinate system │ │ │ │ │ +170 std::array, nSimplexCorners> corners_ │ │ │ │ │ +element_local; │ │ │ │ │ +171 │ │ │ │ │ +172 if (data.gridlocal) { │ │ │ │ │ +173 data.gridindices[par] = glue.merger_->template parent │ │ │ │ │ +(mergeindex,par); │ │ │ │ │ +174 │ │ │ │ │ +175 typename GridGlue::template GridPatch::LocalGeometry │ │ │ │ │ +176 gridLocalGeometry = glue.template patch().geometryLocal │ │ │ │ │ +(data.gridindices[par]); │ │ │ │ │ +177 for (std::size_t i=0; i::Geometry │ │ │ │ │ +192 gridWorldGeometry = glue.template patch().geometry(data.gridindices │ │ │ │ │ +[par]); │ │ │ │ │ +193 │ │ │ │ │ +194 // world coordinates of the remote intersection corners │ │ │ │ │ +195 std::array:: │ │ │ │ │ +dimensionworld>, nSimplexCorners> corners_global; │ │ │ │ │ +196 │ │ │ │ │ +197 for (std::size_t i=0; i │ │ │ │ │ +209 IntersectionData::IntersectionData(const GridGlue& glue, unsigned │ │ │ │ │ +int mergeindex, unsigned int offset, │ │ │ │ │ +210 bool grid0local, bool grid1local) │ │ │ │ │ +211 : index_(mergeindex+offset) │ │ │ │ │ +212 { │ │ │ │ │ +213 // if an invalid index is given do not proceed! │ │ │ │ │ +214 // (happens when the parent GridGlue initializes the "end"-Intersection) │ │ │ │ │ +215 assert (0 <= mergeindex || mergeindex < glue.index__sz); │ │ │ │ │ +216 │ │ │ │ │ +217 std::get<0>(sideData_).gridlocal = grid0local; │ │ │ │ │ +218 std::get<1>(sideData_).gridlocal = grid1local; │ │ │ │ │ +219 │ │ │ │ │ +220 initializeGeometry<0>(glue, mergeindex); │ │ │ │ │ +221 initializeGeometry<1>(glue, mergeindex); │ │ │ │ │ +222 } │ │ │ │ │ +223 │ │ │ │ │ +228 template │ │ │ │ │ +229 struct IntersectionTraits │ │ │ │ │ +230 { │ │ │ │ │ +231 using GridGlue = ::Dune::GridGlue::GridGlue; │ │ │ │ │ +232 using IntersectionData = Dune::GridGlue::IntersectionData; │ │ │ │ │ +233 │ │ │ │ │ +234 using InsideGridView = typename GridGlue::template GridView; │ │ │ │ │ +235 using OutsideGridView = typename GridGlue::template GridView; │ │ │ │ │ +236 │ │ │ │ │ +237 using InsideLocalGeometry = typename IntersectionData::template │ │ │ │ │ +GridLocalGeometry; │ │ │ │ │ +238 using OutsideLocalGeometry = typename IntersectionData::template │ │ │ │ │ +GridLocalGeometry; │ │ │ │ │ +239 │ │ │ │ │ +240 using Geometry = typename IntersectionData::template GridGeometry; │ │ │ │ │ +241 using OutsideGeometry = typename IntersectionData::template │ │ │ │ │ +GridGeometry; │ │ │ │ │ +242 │ │ │ │ │ +243 static constexpr auto coorddim = IntersectionData::coorddim; │ │ │ │ │ +244 static constexpr auto mydim = IntersectionData::mydim; │ │ │ │ │ +245 static constexpr int insidePatch = inside; │ │ │ │ │ +246 static constexpr int outsidePatch = outside; │ │ │ │ │ +247 │ │ │ │ │ +248 using ctype = typename GridGlue::ctype; │ │ │ │ │ +249 using LocalCoordinate = Dune::FieldVector; │ │ │ │ │ +250 using GlobalCoordinate = Dune::FieldVector; │ │ │ │ │ +251 }; │ │ │ │ │ +252 │ │ │ │ │ +255 template │ │ │ │ │ +256 class Intersection │ │ │ │ │ +257 { │ │ │ │ │ +258 │ │ │ │ │ +259 public: │ │ │ │ │ +260 │ │ │ │ │ +261 typedef IntersectionTraits Traits; │ │ │ │ │ +262 │ │ │ │ │ +263 typedef typename Traits::GridGlue GridGlue; │ │ │ │ │ +264 typedef typename Traits::IntersectionData IntersectionData; │ │ │ │ │ +265 │ │ │ │ │ +266 │ │ │ │ │ +267 typedef typename Traits::InsideGridView InsideGridView; │ │ │ │ │ +268 typedef typename Traits::InsideLocalGeometry InsideLocalGeometry; │ │ │ │ │ +269 │ │ │ │ │ +270 typedef typename Traits::OutsideGridView OutsideGridView; │ │ │ │ │ +271 typedef typename Traits::OutsideLocalGeometry OutsideLocalGeometry; │ │ │ │ │ +272 typedef typename Traits::OutsideGeometry OutsideGeometry; │ │ │ │ │ +273 │ │ │ │ │ +274 typedef typename Traits::Geometry Geometry; │ │ │ │ │ +275 typedef typename Traits::ctype ctype; │ │ │ │ │ +276 │ │ │ │ │ +277 typedef typename InsideGridView::Traits::template Codim<0>::Entity │ │ │ │ │ +InsideEntity; │ │ │ │ │ +278 typedef typename OutsideGridView::Traits::template Codim<0>::Entity │ │ │ │ │ +OutsideEntity; │ │ │ │ │ +279 │ │ │ │ │ +280 typedef typename Traits::LocalCoordinate LocalCoordinate; │ │ │ │ │ +281 typedef typename Traits::GlobalCoordinate GlobalCoordinate; │ │ │ │ │ +282 │ │ │ │ │ +284 static constexpr auto coorddim = Traits::coorddim; │ │ │ │ │ +285 │ │ │ │ │ +287 static constexpr auto mydim = Traits::mydim; │ │ │ │ │ +288 │ │ │ │ │ +290 static constexpr int insidePatch = Traits::insidePatch; │ │ │ │ │ +291 │ │ │ │ │ +293 static constexpr int outsidePatch = Traits::outsidePatch; │ │ │ │ │ +294 │ │ │ │ │ +295 // typedef unsigned int IndexType; │ │ │ │ │ +296 │ │ │ │ │ +297 private: │ │ │ │ │ +301 static constexpr int codimensionWorld = coorddim - mydim; │ │ │ │ │ +302 │ │ │ │ │ +303 public: │ │ │ │ │ +304 /* C O N S T R U C T O R S */ │ │ │ │ │ +305 │ │ │ │ │ +307 Intersection(const GridGlue* glue, const IntersectionData* i) : │ │ │ │ │ +308 glue_(glue), i_(i) {} │ │ │ │ │ +309 │ │ │ │ │ +310 /* F U N C T I O N A L I T Y */ │ │ │ │ │ +311 │ │ │ │ │ +314 InsideEntity │ │ │ │ │ +315 inside(unsigned int parentId = 0) const │ │ │ │ │ +316 { │ │ │ │ │ +317 assert(self()); │ │ │ │ │ +318 return glue_->template patch().element(i_->template index(parentId)); │ │ │ │ │ +319 } │ │ │ │ │ +320 │ │ │ │ │ +323 OutsideEntity │ │ │ │ │ +324 outside(unsigned int parentId = 0) const │ │ │ │ │ +325 { │ │ │ │ │ +326 assert(neighbor()); │ │ │ │ │ +327 return glue_->template patch().element(i_->template index(parentId)); │ │ │ │ │ +328 } │ │ │ │ │ +329 │ │ │ │ │ +331 bool conforming() const │ │ │ │ │ +332 { │ │ │ │ │ +333 throw Dune::NotImplemented(); │ │ │ │ │ +334 } │ │ │ │ │ +335 │ │ │ │ │ +338 const InsideLocalGeometry& geometryInInside(unsigned int parentId = 0) │ │ │ │ │ +const │ │ │ │ │ +339 { │ │ │ │ │ +340 return i_->template localGeometry(parentId); │ │ │ │ │ +341 } │ │ │ │ │ +342 │ │ │ │ │ +345 const OutsideLocalGeometry& geometryInOutside(unsigned int parentId = 0) │ │ │ │ │ +const │ │ │ │ │ +346 { │ │ │ │ │ +347 return i_->template localGeometry(parentId); │ │ │ │ │ +348 } │ │ │ │ │ +349 │ │ │ │ │ +356 const Geometry& geometry() const │ │ │ │ │ +357 { │ │ │ │ │ +358 return i_->template geometry(); │ │ │ │ │ +359 } │ │ │ │ │ +360 │ │ │ │ │ +367 const OutsideGeometry& geometryOutside() const // DUNE_DEPRECATED │ │ │ │ │ +368 { │ │ │ │ │ +369 return i_->template geometry(); │ │ │ │ │ +370 } │ │ │ │ │ +371 │ │ │ │ │ +373 Dune::GeometryType type() const │ │ │ │ │ +374 { │ │ │ │ │ +375 #ifdef ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ +376 return Dune::GeometryTypes::simplex(mydim); │ │ │ │ │ +377 #else │ │ │ │ │ +378 #error Not Implemented │ │ │ │ │ +379 #endif │ │ │ │ │ +380 } │ │ │ │ │ +381 │ │ │ │ │ +382 │ │ │ │ │ +384 bool self() const │ │ │ │ │ +385 { │ │ │ │ │ +386 return i_->template local(); │ │ │ │ │ +387 } │ │ │ │ │ +388 │ │ │ │ │ +390 size_t neighbor(unsigned int g = 0) const │ │ │ │ │ +391 { │ │ │ │ │ +392 if (g == 0 && i_->template local()) { │ │ │ │ │ +393 return i_->template parents(); │ │ │ │ │ +394 } else if (g == 1 && i_->template local()) { │ │ │ │ │ +395 return i_->template parents(); │ │ │ │ │ +396 } │ │ │ │ │ +397 return 0; │ │ │ │ │ +398 } │ │ │ │ │ +399 │ │ │ │ │ +401 int indexInInside(unsigned int parentId = 0) const │ │ │ │ │ +402 { │ │ │ │ │ +403 assert(self()); │ │ │ │ │ +404 return glue_->template patch().indexInInside(i_->template index │ │ │ │ │ +(parentId)); │ │ │ │ │ +405 } │ │ │ │ │ +406 │ │ │ │ │ +408 int indexInOutside(unsigned int parentId = 0) const │ │ │ │ │ +409 { │ │ │ │ │ +410 assert(neighbor()); │ │ │ │ │ +411 return glue_->template patch().indexInInside(i_->template index │ │ │ │ │ +(parentId)); │ │ │ │ │ +412 } │ │ │ │ │ +413 │ │ │ │ │ +418 GlobalCoordinate outerNormal(const LocalCoordinate &local) const │ │ │ │ │ +419 { │ │ │ │ │ +420 GlobalCoordinate normal; │ │ │ │ │ +421 │ │ │ │ │ +422 if (codimensionWorld == 0) │ │ │ │ │ +423 DUNE_THROW(Dune::Exception, "There is no normal vector to a full- │ │ │ │ │ +dimensional intersection"); │ │ │ │ │ +424 else if (codimensionWorld == 1) { │ │ │ │ │ +425 /* TODO: Implement the general n-ary cross product here */ │ │ │ │ │ +426 const auto jacobianTransposed = geometry().jacobianTransposed(local); │ │ │ │ │ +427 if (mydim==1) { │ │ │ │ │ +428 normal[0] = - jacobianTransposed[0][1]; │ │ │ │ │ +429 normal[1] = jacobianTransposed[0][0]; │ │ │ │ │ +430 } else if (mydim==2) { │ │ │ │ │ +431 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - │ │ │ │ │ +jacobianTransposed[0][2] * jacobianTransposed[1][1]); │ │ │ │ │ +432 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - │ │ │ │ │ +jacobianTransposed[0][2] * jacobianTransposed[1][0]); │ │ │ │ │ +433 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - │ │ │ │ │ +jacobianTransposed[0][1] * jacobianTransposed[1][0]); │ │ │ │ │ +434 } else │ │ │ │ │ +435 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the │ │ │ │ │ +'outerNormal' method for " << mydim << "-dimensional intersections yet"); │ │ │ │ │ +436 } else │ │ │ │ │ +437 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the │ │ │ │ │ +'outerNormal' method for intersections with codim >= 2 yet"); │ │ │ │ │ +438 │ │ │ │ │ +439 return normal; │ │ │ │ │ +440 } │ │ │ │ │ +441 │ │ │ │ │ +446 GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ +447 { │ │ │ │ │ +448 GlobalCoordinate normal = outerNormal(local); │ │ │ │ │ +449 normal /= normal.two_norm(); │ │ │ │ │ +450 return normal; │ │ │ │ │ +451 } │ │ │ │ │ +452 │ │ │ │ │ +457 GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ +458 { │ │ │ │ │ +459 return (unitOuterNormal(local) *= geometry().integrationElement(local)); │ │ │ │ │ +460 } │ │ │ │ │ +461 │ │ │ │ │ +466 GlobalCoordinate centerUnitOuterNormal () const │ │ │ │ │ +467 { │ │ │ │ │ +468 return unitOuterNormal(ReferenceElements::general(type │ │ │ │ │ +()).position(0,0)); │ │ │ │ │ +469 } │ │ │ │ │ +470 │ │ │ │ │ +474 Intersection flip() const │ │ │ │ │ +475 { │ │ │ │ │ +476 return Intersection(glue_,i_); │ │ │ │ │ +477 } │ │ │ │ │ +478 │ │ │ │ │ +479#ifdef QUICKHACK_INDEX │ │ │ │ │ +480 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ +481 │ │ │ │ │ +482 IndexType index() const │ │ │ │ │ +483 { │ │ │ │ │ +484 return i_->index_; │ │ │ │ │ +485 } │ │ │ │ │ +486 │ │ │ │ │ +487#endif │ │ │ │ │ +488 │ │ │ │ │ +489 private: │ │ │ │ │ +490 │ │ │ │ │ +491 friend class IntersectionIndexSet; │ │ │ │ │ +492 │ │ │ │ │ +493 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ +494 │ │ │ │ │ +496 const GridGlue* glue_; │ │ │ │ │ +497 │ │ │ │ │ +499 const IntersectionData* i_; │ │ │ │ │ +500 }; │ │ │ │ │ +501 │ │ │ │ │ +502 │ │ │ │ │ +503 } // end namespace GridGlue │ │ │ │ │ +504} // end namespace Dune │ │ │ │ │ +505 │ │ │ │ │ +506#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ +gridglue.hh │ │ │ │ │ +Central component of the module implementing the coupling of two grids. │ │ │ │ │ Dune │ │ │ │ │ Definition gridglue.hh:37 │ │ │ │ │ -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 │ │ │ │ │ +Dune::GridGlue::GridGlue │ │ │ │ │ +sequential adapter to couple two grids at specified close together boundaries │ │ │ │ │ +Definition gridglue.hh:67 │ │ │ │ │ +Dune::GridGlue::GridGlue::IndexType │ │ │ │ │ +unsigned int IndexType │ │ │ │ │ +Definition gridglue.hh:147 │ │ │ │ │ +Dune::GridGlue::GridGlue::ctype │ │ │ │ │ +PromotionTraits< typenameGridView< 0 >::ctype, typenameGridView< 1 >::ctype >:: │ │ │ │ │ +PromotedType ctype │ │ │ │ │ +The type used for coordinates. │ │ │ │ │ +Definition gridglue.hh:171 │ │ │ │ │ +Dune::GridGlue::GridGlue::dimworld │ │ │ │ │ +static constexpr int dimworld │ │ │ │ │ +export the world dimension This is the maximum of the extractors' world │ │ │ │ │ +dimensions. │ │ │ │ │ +Definition gridglue.hh:166 │ │ │ │ │ +Dune::GridGlue::IntersectionData │ │ │ │ │ +storage class for Dune::GridGlue::Intersection related data │ │ │ │ │ +Definition intersection.hh:38 │ │ │ │ │ +Dune::GridGlue::IntersectionData::IndexType │ │ │ │ │ +GridGlue::IndexType IndexType │ │ │ │ │ +Definition intersection.hh:42 │ │ │ │ │ +Dune::GridGlue::IntersectionData::GridGeometry │ │ │ │ │ +AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, │ │ │ │ │ +GridGlue::template GridView< side >::dimensionworld > GridGeometry │ │ │ │ │ +Definition intersection.hh:65 │ │ │ │ │ +Dune::GridGlue::IntersectionData::localGeometry │ │ │ │ │ +const GridLocalGeometry< side > & localGeometry(unsigned int parentId=0) const │ │ │ │ │ +Definition intersection.hh:85 │ │ │ │ │ +Dune::GridGlue::IntersectionData::coorddim │ │ │ │ │ +static constexpr int coorddim │ │ │ │ │ +Dimension of the world space of the intersection. │ │ │ │ │ +Definition intersection.hh:45 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid0Geometry │ │ │ │ │ +GridGeometry< 0 > Grid0Geometry │ │ │ │ │ +Definition intersection.hh:67 │ │ │ │ │ +Dune::GridGlue::IntersectionData::GridIndexType │ │ │ │ │ +typename GridGlue::template GridView< side >::IndexSet::IndexType GridIndexType │ │ │ │ │ +Definition intersection.hh:71 │ │ │ │ │ +Dune::GridGlue::IntersectionData::index │ │ │ │ │ +IndexType index(unsigned int parentId=0) const │ │ │ │ │ +Definition intersection.hh:97 │ │ │ │ │ +Dune::GridGlue::IntersectionData::parents │ │ │ │ │ +IndexType parents() const │ │ │ │ │ +Definition intersection.hh:101 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid1LocalGeometry │ │ │ │ │ +GridLocalGeometry< 1 > Grid1LocalGeometry │ │ │ │ │ +Definition intersection.hh:61 │ │ │ │ │ +Dune::GridGlue::IntersectionData::geometry │ │ │ │ │ +const GridGeometry< side > & geometry() const │ │ │ │ │ +Definition intersection.hh:89 │ │ │ │ │ +Dune::GridGlue::IntersectionData::local │ │ │ │ │ +bool local() const │ │ │ │ │ +Definition intersection.hh:93 │ │ │ │ │ +Dune::GridGlue::IntersectionData::GridGlue │ │ │ │ │ +::Dune::GridGlue::GridGlue< P0, P1 > GridGlue │ │ │ │ │ +Definition intersection.hh:40 │ │ │ │ │ +Dune::GridGlue::IntersectionData::mydim │ │ │ │ │ +static constexpr int mydim │ │ │ │ │ +Dimension of the intersection. │ │ │ │ │ +Definition intersection.hh:54 │ │ │ │ │ +Dune::GridGlue::IntersectionData::GridLocalGeometry │ │ │ │ │ +AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, │ │ │ │ │ +GridGlue::template GridView< side >::dimension > GridLocalGeometry │ │ │ │ │ +Definition intersection.hh:58 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid0LocalGeometry │ │ │ │ │ +GridLocalGeometry< 0 > Grid0LocalGeometry │ │ │ │ │ +Definition intersection.hh:60 │ │ │ │ │ +Dune::GridGlue::IntersectionData::index_ │ │ │ │ │ +IndexType index_ │ │ │ │ │ +index of this intersection after GridGlue interface │ │ │ │ │ +Definition intersection.hh:112 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid1IndexType │ │ │ │ │ +GridIndexType< 1 > Grid1IndexType │ │ │ │ │ +Definition intersection.hh:74 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid1Geometry │ │ │ │ │ +GridGeometry< 1 > Grid1Geometry │ │ │ │ │ +Definition intersection.hh:68 │ │ │ │ │ +Dune::GridGlue::IntersectionData::Grid0IndexType │ │ │ │ │ +GridIndexType< 0 > Grid0IndexType │ │ │ │ │ +Definition intersection.hh:73 │ │ │ │ │ +Dune::GridGlue::IntersectionData::IntersectionData │ │ │ │ │ +IntersectionData()=default │ │ │ │ │ +Default Constructor. │ │ │ │ │ +Dune::GridGlue::Intersection │ │ │ │ │ +The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ +Definition intersection.hh:257 │ │ │ │ │ +Dune::GridGlue::Intersection::OutsideLocalGeometry │ │ │ │ │ +Traits::OutsideLocalGeometry OutsideLocalGeometry │ │ │ │ │ +Definition intersection.hh:271 │ │ │ │ │ +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:474 │ │ │ │ │ +Dune::GridGlue::Intersection::conforming │ │ │ │ │ +bool conforming() const │ │ │ │ │ +Return true if intersection is conforming. │ │ │ │ │ +Definition intersection.hh:331 │ │ │ │ │ +Dune::GridGlue::Intersection::InsideEntity │ │ │ │ │ +InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity │ │ │ │ │ +Definition intersection.hh:277 │ │ │ │ │ +Dune::GridGlue::Intersection::GridGlue │ │ │ │ │ +Traits::GridGlue GridGlue │ │ │ │ │ +Definition intersection.hh:263 │ │ │ │ │ +Dune::GridGlue::Intersection::indexInOutside │ │ │ │ │ +int indexInOutside(unsigned int parentId=0) const │ │ │ │ │ +Local number of codim 1 entity in outside() Entity where intersection is │ │ │ │ │ +contained in. │ │ │ │ │ +Definition intersection.hh:408 │ │ │ │ │ +Dune::GridGlue::Intersection::indexInInside │ │ │ │ │ +int indexInInside(unsigned int parentId=0) const │ │ │ │ │ +Local number of codim 1 entity in the inside() Entity where intersection is │ │ │ │ │ +contained in. │ │ │ │ │ +Definition intersection.hh:401 │ │ │ │ │ +Dune::GridGlue::Intersection::self │ │ │ │ │ +bool self() const │ │ │ │ │ +For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ +Definition intersection.hh:384 │ │ │ │ │ +Dune::GridGlue::Intersection::mydim │ │ │ │ │ +static constexpr auto mydim │ │ │ │ │ +dimension of the intersection │ │ │ │ │ +Definition intersection.hh:287 │ │ │ │ │ +Dune::GridGlue::Intersection::outsidePatch │ │ │ │ │ +static constexpr int outsidePatch │ │ │ │ │ +outside patch │ │ │ │ │ +Definition intersection.hh:293 │ │ │ │ │ +Dune::GridGlue::Intersection::type │ │ │ │ │ +Dune::GeometryType type() const │ │ │ │ │ +Type of reference element for this intersection. │ │ │ │ │ +Definition intersection.hh:373 │ │ │ │ │ +Dune::GridGlue::Intersection::inside │ │ │ │ │ +InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the inside of this intersection. │ │ │ │ │ +Definition intersection.hh:315 │ │ │ │ │ +Dune::GridGlue::Intersection::LocalCoordinate │ │ │ │ │ +Traits::LocalCoordinate LocalCoordinate │ │ │ │ │ +Definition intersection.hh:280 │ │ │ │ │ +Dune::GridGlue::Intersection::geometryInOutside │ │ │ │ │ +const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const │ │ │ │ │ +Geometric information about this intersection in local coordinates of the │ │ │ │ │ +outside() element. │ │ │ │ │ +Definition intersection.hh:345 │ │ │ │ │ +Dune::GridGlue::Intersection::unitOuterNormal │ │ │ │ │ +GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ +Return a unit outer normal. │ │ │ │ │ +Definition intersection.hh:446 │ │ │ │ │ +Dune::GridGlue::Intersection::ctype │ │ │ │ │ +Traits::ctype ctype │ │ │ │ │ +Definition intersection.hh:275 │ │ │ │ │ +Dune::GridGlue::Intersection::Traits │ │ │ │ │ +IntersectionTraits< P0, P1, I, O > Traits │ │ │ │ │ +Definition intersection.hh:261 │ │ │ │ │ +Dune::GridGlue::Intersection::IntersectionData │ │ │ │ │ +Traits::IntersectionData IntersectionData │ │ │ │ │ +Definition intersection.hh:264 │ │ │ │ │ +Dune::GridGlue::Intersection::GlobalCoordinate │ │ │ │ │ +Traits::GlobalCoordinate GlobalCoordinate │ │ │ │ │ +Definition intersection.hh:281 │ │ │ │ │ +Dune::GridGlue::Intersection::OutsideGeometry │ │ │ │ │ +Traits::OutsideGeometry OutsideGeometry │ │ │ │ │ +Definition intersection.hh:272 │ │ │ │ │ +Dune::GridGlue::Intersection::neighbor │ │ │ │ │ +size_t neighbor(unsigned int g=0) const │ │ │ │ │ +Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ +Definition intersection.hh:390 │ │ │ │ │ +Dune::GridGlue::Intersection::Intersection │ │ │ │ │ +Intersection(const GridGlue *glue, const IntersectionData *i) │ │ │ │ │ +Constructor for a given Dataset. │ │ │ │ │ +Definition intersection.hh:307 │ │ │ │ │ +Dune::GridGlue::Intersection::insidePatch │ │ │ │ │ +static constexpr int insidePatch │ │ │ │ │ +inside patch │ │ │ │ │ +Definition intersection.hh:290 │ │ │ │ │ +Dune::GridGlue::Intersection::Geometry │ │ │ │ │ +Traits::Geometry Geometry │ │ │ │ │ +Definition intersection.hh:274 │ │ │ │ │ +Dune::GridGlue::Intersection::OutsideEntity │ │ │ │ │ +OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity │ │ │ │ │ +Definition intersection.hh:278 │ │ │ │ │ +Dune::GridGlue::Intersection::outside │ │ │ │ │ +OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the outside of this intersection. │ │ │ │ │ +Definition intersection.hh:324 │ │ │ │ │ +Dune::GridGlue::Intersection::geometry │ │ │ │ │ +const Geometry & geometry() const │ │ │ │ │ +Geometric information about this intersection as part of the inside grid. │ │ │ │ │ +Definition intersection.hh:356 │ │ │ │ │ +Dune::GridGlue::Intersection::InsideLocalGeometry │ │ │ │ │ +Traits::InsideLocalGeometry InsideLocalGeometry │ │ │ │ │ +Definition intersection.hh:268 │ │ │ │ │ +Dune::GridGlue::Intersection::outerNormal │ │ │ │ │ +GlobalCoordinate outerNormal(const LocalCoordinate &local) const │ │ │ │ │ +Return an outer normal (length not necessarily 1) │ │ │ │ │ +Definition intersection.hh:418 │ │ │ │ │ +Dune::GridGlue::Intersection::geometryOutside │ │ │ │ │ +const OutsideGeometry & geometryOutside() const │ │ │ │ │ +Geometric information about this intersection as part of the outside grid. │ │ │ │ │ +Definition intersection.hh:367 │ │ │ │ │ +Dune::GridGlue::Intersection::OutsideGridView │ │ │ │ │ +Traits::OutsideGridView OutsideGridView │ │ │ │ │ +Definition intersection.hh:270 │ │ │ │ │ +Dune::GridGlue::Intersection::integrationOuterNormal │ │ │ │ │ +GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ +Return an outer normal with the length of the integration element. │ │ │ │ │ +Definition intersection.hh:457 │ │ │ │ │ +Dune::GridGlue::Intersection::InsideGridView │ │ │ │ │ +Traits::InsideGridView InsideGridView │ │ │ │ │ +Definition intersection.hh:267 │ │ │ │ │ +Dune::GridGlue::Intersection::geometryInInside │ │ │ │ │ +const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const │ │ │ │ │ +Geometric information about this intersection in local coordinates of the │ │ │ │ │ +inside() element. │ │ │ │ │ +Definition intersection.hh:338 │ │ │ │ │ +Dune::GridGlue::Intersection::centerUnitOuterNormal │ │ │ │ │ +GlobalCoordinate centerUnitOuterNormal() const │ │ │ │ │ +Unit outer normal at the center of the intersection. │ │ │ │ │ +Definition intersection.hh:466 │ │ │ │ │ +Dune::GridGlue::Intersection::coorddim │ │ │ │ │ +static constexpr auto coorddim │ │ │ │ │ +dimension of the world space of the intersection │ │ │ │ │ +Definition intersection.hh:284 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits │ │ │ │ │ +Definition intersection.hh:230 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::insidePatch │ │ │ │ │ +static constexpr int insidePatch │ │ │ │ │ +Definition intersection.hh:245 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::LocalCoordinate │ │ │ │ │ +Dune::FieldVector< ctype, mydim > LocalCoordinate │ │ │ │ │ +Definition intersection.hh:249 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::coorddim │ │ │ │ │ +static constexpr auto coorddim │ │ │ │ │ +Definition intersection.hh:243 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::OutsideGeometry │ │ │ │ │ +typename IntersectionData::template GridGeometry< outside > OutsideGeometry │ │ │ │ │ +Definition intersection.hh:241 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::ctype │ │ │ │ │ +typename GridGlue::ctype ctype │ │ │ │ │ +Definition intersection.hh:248 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::OutsideGridView │ │ │ │ │ +typename GridGlue::template GridView< outside > OutsideGridView │ │ │ │ │ +Definition intersection.hh:235 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::GlobalCoordinate │ │ │ │ │ +Dune::FieldVector< ctype, coorddim > GlobalCoordinate │ │ │ │ │ +Definition intersection.hh:250 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::OutsideLocalGeometry │ │ │ │ │ +typename IntersectionData::template GridLocalGeometry< outside > │ │ │ │ │ +OutsideLocalGeometry │ │ │ │ │ +Definition intersection.hh:238 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::InsideGridView │ │ │ │ │ +typename GridGlue::template GridView< inside > InsideGridView │ │ │ │ │ +Definition intersection.hh:234 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::Geometry │ │ │ │ │ +typename IntersectionData::template GridGeometry< inside > Geometry │ │ │ │ │ +Definition intersection.hh:240 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::InsideLocalGeometry │ │ │ │ │ +typename IntersectionData::template GridLocalGeometry< inside > │ │ │ │ │ +InsideLocalGeometry │ │ │ │ │ +Definition intersection.hh:237 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::outsidePatch │ │ │ │ │ +static constexpr int outsidePatch │ │ │ │ │ +Definition intersection.hh:246 │ │ │ │ │ +Dune::GridGlue::IntersectionTraits::mydim │ │ │ │ │ +static constexpr auto mydim │ │ │ │ │ +Definition intersection.hh:244 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: rangegenerators.hh File Reference │ │ │ │ +dune-grid-glue: intersectionindexset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,41 +71,34 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
rangegenerators.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
intersectionindexset.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <dune/common/iteratorrange.hh>
│ │ │ │ +
#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +#include <dune/grid-glue/adapter/intersection.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

struct  Dune::GridGlue::Reverse< reverse >
class  Dune::GridGlue::IntersectionIndexSet< P0, P1 >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ 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.
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,27 +1,22 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -rangegenerators.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +intersectionindexset.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::GridGlue::Reverse<_reverse_> │ │ │ │ │ +class   Dune::GridGlue::IntersectionIndexSet<_P0,_P1_> │ │ │ │ │   │ │ │ │ │ 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. │ │ │ │ │ -  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00008_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: rangegenerators.hh Source File │ │ │ │ +dune-grid-glue: intersectionindexset.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,78 +74,87 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
rangegenerators.hh
│ │ │ │ +
intersectionindexset.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +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
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH
│ │ │ │
5
│ │ │ │ -
6#include <dune/common/iteratorrange.hh>
│ │ │ │ -
7
│ │ │ │ -
8namespace Dune {
│ │ │ │ -
9namespace GridGlue {
│ │ │ │ -
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
│ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
66template<...>
│ │ │ │ -
67IteratorRange<...>
│ │ │ │ -
68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = !reversed);
│ │ │ │ -
69
│ │ │ │ -
70#else
│ │ │ │ -
71
│ │ │ │ -
72namespace {
│ │ │ │ -
73const Reverse<true> reversed = {};
│ │ │ │ -
74} /* namespace */
│ │ │ │ -
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
│ │ │ │ + │ │ │ │ + │ │ │ │ +
8
│ │ │ │ +
9#ifndef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ +
10// we currently support only one intersection type. If we want to support more,
│ │ │ │ +
11// we have to think about the semantics of our IndexSet
│ │ │ │ +
12#error Not Implemented
│ │ │ │ +
13#endif
│ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16 namespace GridGlue {
│ │ │ │ +
17
│ │ │ │ +
18 template<typename P0, typename P1>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
20 {
│ │ │ │ +
21 friend class ::Dune::GridGlue::GridGlue<P0,P1>;
│ │ │ │ +
22 typedef ::Dune::GridGlue::GridGlue<P0,P1> GridGlue;
│ │ │ │ +
23
│ │ │ │ +
24 public:
│ │ │ │ +
25
│ │ │ │ + │ │ │ │ +
29 typedef size_t SizeType;
│ │ │ │ +
30
│ │ │ │ +
33 template<int I, int O>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
35 {
│ │ │ │ +
36 return i.i_->index_;
│ │ │ │ +
37 }
│ │ │ │ +
│ │ │ │ +
38
│ │ │ │ +
│ │ │ │ +
41 SizeType size () const
│ │ │ │ +
42 {
│ │ │ │ +
43 return glue_->size();
│ │ │ │ +
44 }
│ │ │ │ +
│ │ │ │ +
45
│ │ │ │ +
46 private:
│ │ │ │ +
47
│ │ │ │ + │ │ │ │ +
50 glue_(g) {}
│ │ │ │ +
51
│ │ │ │ +
52 const GridGlue * glue_;
│ │ │ │ +
53 };
│ │ │ │ +
│ │ │ │ +
54
│ │ │ │ +
55 } // end namespace GridGlue
│ │ │ │ +
56} // end namespace Dune
│ │ │ │ +
57
│ │ │ │ +
58#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH
│ │ │ │ +
Central component of the module implementing the coupling of two grids.
│ │ │ │ +
Model of the Intersection concept provided by GridGlue.
│ │ │ │
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
│ │ │ │ +
unsigned int IndexType
Definition gridglue.hh:147
│ │ │ │ +
size_t size() const
Definition gridglue.hh:393
│ │ │ │ +
IndexType index_
index of this intersection after GridGlue interface
Definition intersection.hh:112
│ │ │ │ +
The intersection of two entities of the two patches of a GridGlue.
Definition intersection.hh:257
│ │ │ │ +
Definition intersectionindexset.hh:20
│ │ │ │ +
SizeType size() const
Return total number of intersections.
Definition intersectionindexset.hh:41
│ │ │ │ +
GridGlue::IndexType IndexType
The type used for the indices.
Definition intersectionindexset.hh:27
│ │ │ │ +
IndexType index(const Intersection< P0, P1, I, O > &i) const
Map Dune::GridGlue::Intersection to index.
Definition intersectionindexset.hh:34
│ │ │ │ +
size_t SizeType
The type used for the size.
Definition intersectionindexset.hh:29
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,88 +1,105 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -rangegenerators.hh │ │ │ │ │ +intersectionindexset.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 │ │ │ │ │ +3#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ 5 │ │ │ │ │ -6#include │ │ │ │ │ -7 │ │ │ │ │ -8namespace Dune { │ │ │ │ │ -9namespace GridGlue { │ │ │ │ │ -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; │ │ │ │ │ -32 │ │ │ │ │ -66template<...> │ │ │ │ │ -67IteratorRange<...> │ │ │ │ │ -68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = │ │ │ │ │ -!reversed); │ │ │ │ │ -69 │ │ │ │ │ -70#else │ │ │ │ │ -71 │ │ │ │ │ -72namespace { │ │ │ │ │ -73const Reverse reversed = {}; │ │ │ │ │ -74} /* namespace */ │ │ │ │ │ -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 │ │ │ │ │ +6#include │ │ │ │ │ +7#include │ │ │ │ │ +8 │ │ │ │ │ +9#ifndef ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ +10// we currently support only one intersection type. If we want to support │ │ │ │ │ +more, │ │ │ │ │ +11// we have to think about the semantics of our IndexSet │ │ │ │ │ +12#error Not Implemented │ │ │ │ │ +13#endif │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune { │ │ │ │ │ +16 namespace GridGlue { │ │ │ │ │ +17 │ │ │ │ │ +18 template │ │ │ │ │ +19 class IntersectionIndexSet │ │ │ │ │ +20 { │ │ │ │ │ +21 friend class ::Dune::GridGlue::GridGlue; │ │ │ │ │ +22 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ +23 │ │ │ │ │ +24 public: │ │ │ │ │ +25 │ │ │ │ │ +27 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ +29 typedef size_t SizeType; │ │ │ │ │ +30 │ │ │ │ │ +33 template │ │ │ │ │ +34 IndexType index (const Intersection & i) const │ │ │ │ │ +35 { │ │ │ │ │ +36 return i.i_->index_; │ │ │ │ │ +37 } │ │ │ │ │ +38 │ │ │ │ │ +41 SizeType size () const │ │ │ │ │ +42 { │ │ │ │ │ +43 return glue_->size(); │ │ │ │ │ +44 } │ │ │ │ │ +45 │ │ │ │ │ +46 private: │ │ │ │ │ +47 │ │ │ │ │ +49 IntersectionIndexSet(const GridGlue * g) : │ │ │ │ │ +50 glue_(g) {} │ │ │ │ │ +51 │ │ │ │ │ +52 const GridGlue * glue_; │ │ │ │ │ +53 }; │ │ │ │ │ +54 │ │ │ │ │ +55 } // end namespace GridGlue │ │ │ │ │ +56} // end namespace Dune │ │ │ │ │ +57 │ │ │ │ │ +58#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ +gridglue.hh │ │ │ │ │ +Central component of the module implementing the coupling of two grids. │ │ │ │ │ +intersection.hh │ │ │ │ │ +Model of the Intersection concept provided by GridGlue. │ │ │ │ │ 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::GridGlue::IndexType │ │ │ │ │ +unsigned int IndexType │ │ │ │ │ +Definition gridglue.hh:147 │ │ │ │ │ +Dune::GridGlue::GridGlue::size │ │ │ │ │ +size_t size() const │ │ │ │ │ +Definition gridglue.hh:393 │ │ │ │ │ +Dune::GridGlue::IntersectionData::index_ │ │ │ │ │ +IndexType index_ │ │ │ │ │ +index of this intersection after GridGlue interface │ │ │ │ │ +Definition intersection.hh:112 │ │ │ │ │ +Dune::GridGlue::Intersection │ │ │ │ │ +The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ +Definition intersection.hh:257 │ │ │ │ │ +Dune::GridGlue::IntersectionIndexSet │ │ │ │ │ +Definition intersectionindexset.hh:20 │ │ │ │ │ +Dune::GridGlue::IntersectionIndexSet::size │ │ │ │ │ +SizeType size() const │ │ │ │ │ +Return total number of intersections. │ │ │ │ │ +Definition intersectionindexset.hh:41 │ │ │ │ │ +Dune::GridGlue::IntersectionIndexSet::IndexType │ │ │ │ │ +GridGlue::IndexType IndexType │ │ │ │ │ +The type used for the indices. │ │ │ │ │ +Definition intersectionindexset.hh:27 │ │ │ │ │ +Dune::GridGlue::IntersectionIndexSet::index │ │ │ │ │ +IndexType index(const Intersection< P0, P1, I, O > &i) const │ │ │ │ │ +Map Dune::GridGlue::Intersection to index. │ │ │ │ │ +Definition intersectionindexset.hh:34 │ │ │ │ │ +Dune::GridGlue::IntersectionIndexSet::SizeType │ │ │ │ │ +size_t SizeType │ │ │ │ │ +The type used for the size. │ │ │ │ │ +Definition intersectionindexset.hh:29 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectioniterator.hh File Reference │ │ │ │ +dune-grid-glue: rangegenerators.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,40 +71,42 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
intersectioniterator.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
rangegenerators.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

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

│ │ │ │ -
#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +
#include <dune/common/iteratorrange.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside >
struct  Dune::GridGlue::Reverse< reverse >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ 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.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Implement iterators over GridGlue intersections.

│ │ │ │ -
Author
Christian Engwer
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,26 +1,27 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -intersectioniterator.hh File Reference │ │ │ │ │ -Implement iterators over GridGlue intersections. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +rangegenerators.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::GridGlue::IntersectionIterator<_P0,_P1,_inside,_outside_> │ │ │ │ │ +struct   Dune::GridGlue::Reverse<_reverse_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Implement iterators over GridGlue intersections. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ +Functions │ │ │ │ │ +template<... > │ │ │ │ │ +IteratorRange<... >  Dune::GridGlue::intersections (const GridGlue<... > &glue, │ │ │ │ │ + const Reverse<... > &reverse=!reversed) │ │ │ │ │ +  Iterate over all intersections of a GridGlue. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00011_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectioniterator.hh Source File │ │ │ │ +dune-grid-glue: rangegenerators.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,95 +74,78 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
intersectioniterator.hh
│ │ │ │ +
rangegenerators.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
│ │ │ │ -
14
│ │ │ │ - │ │ │ │ -
16
│ │ │ │ -
17namespace Dune {
│ │ │ │ -
18 namespace GridGlue {
│ │ │ │ +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 {
│ │ │ │ +
10
│ │ │ │ +
14template<bool reverse>
│ │ │ │ +
│ │ │ │ +
15struct Reverse
│ │ │ │ +
16 : std::integral_constant<bool, reverse>
│ │ │ │ +
17{
│ │ │ │ +
18 typedef Reverse type;
│ │ │ │
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_;
│ │ │ │ -
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_;
│ │ │ │ -
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.
│ │ │ │ +
20 constexpr
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
22 { return {}; }
│ │ │ │ +
│ │ │ │ +
23};
│ │ │ │ +
│ │ │ │ +
24
│ │ │ │ +
25#ifdef DOXYGEN
│ │ │ │ +
26
│ │ │ │ + │ │ │ │ +
32
│ │ │ │ +
66template<...>
│ │ │ │ +
67IteratorRange<...>
│ │ │ │ +
68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = !reversed);
│ │ │ │ +
69
│ │ │ │ +
70#else
│ │ │ │ +
71
│ │ │ │ +
72namespace {
│ │ │ │ +
73const Reverse<true> reversed = {};
│ │ │ │ +
74} /* namespace */
│ │ │ │ +
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
│ │ │ │
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
│ │ │ │ - │ │ │ │ -
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
│ │ │ │ +
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
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,99 +1,88 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -intersectioniterator.hh │ │ │ │ │ +rangegenerators.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-with- │ │ │ │ │ +2// 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 │ │ │ │ │ -14 │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17namespace Dune { │ │ │ │ │ -18 namespace GridGlue { │ │ │ │ │ +3#ifndef DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_ADAPTER_RANGEGENERATORS_HH │ │ │ │ │ +5 │ │ │ │ │ +6#include │ │ │ │ │ +7 │ │ │ │ │ +8namespace Dune { │ │ │ │ │ +9namespace GridGlue { │ │ │ │ │ +10 │ │ │ │ │ +14template │ │ │ │ │ +15struct Reverse │ │ │ │ │ +16 : std::integral_constant │ │ │ │ │ +17{ │ │ │ │ │ +18 typedef Reverse type; │ │ │ │ │ 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_; │ │ │ │ │ -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_; │ │ │ │ │ -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. │ │ │ │ │ +20 constexpr │ │ │ │ │ +21 Reverse operator!() const │ │ │ │ │ +22 { return {}; } │ │ │ │ │ +23}; │ │ │ │ │ +24 │ │ │ │ │ +25#ifdef DOXYGEN │ │ │ │ │ +26 │ │ │ │ │ +31const Reverse reversed; │ │ │ │ │ +32 │ │ │ │ │ +66template<...> │ │ │ │ │ +67IteratorRange<...> │ │ │ │ │ +68intersections(const GridGlue<...>& glue, const Reverse<...>& reverse = │ │ │ │ │ +!reversed); │ │ │ │ │ +69 │ │ │ │ │ +70#else │ │ │ │ │ +71 │ │ │ │ │ +72namespace { │ │ │ │ │ +73const Reverse reversed = {}; │ │ │ │ │ +74} /* namespace */ │ │ │ │ │ +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 │ │ │ │ │ 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::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::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 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluecommunicate.hh File Reference │ │ │ │ +dune-grid-glue: gridgluevtkwriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,74 +71,47 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
│ │ │ │ -
gridgluecommunicate.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
gridgluevtkwriter.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

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

Write all remote intersections to a vtk file for debugging. │ │ │ │ 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 <fstream>
│ │ │ │ +#include <iomanip>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <dune/common/classname.hh>
│ │ │ │ +#include <dune/geometry/type.hh>
│ │ │ │ +#include <dune/geometry/referenceelements.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 required 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::GridGlueVtkWriter
 Write remote intersections to a vtk file for debugging purposes. 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

│ │ │ │ -

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

│ │ │ │ -
Author
Christian Engwer
│ │ │ │ +

Write all remote intersections to a vtk file for debugging.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,61 +1,33 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -gridgluecommunicate.hh File Reference │ │ │ │ │ -Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ -More... │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +gridgluevtkwriter.hh File Reference │ │ │ │ │ +Write all remote intersections to a vtk file for debugging. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#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 required 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::GridGlueVtkWriter │ │ │ │ │ +  Write remote intersections to a vtk file for debugging purposes. │ │ │ │ │ + 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 ***** │ │ │ │ │ -Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ +Write all remote intersections to a vtk file for debugging. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00014_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluecommunicate.hh Source File │ │ │ │ +dune-grid-glue: gridgluevtkwriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,365 +74,318 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
gridgluecommunicate.hh
│ │ │ │ +
gridgluevtkwriter.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>
│ │ │ │ -
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>
│ │ │ │ -
19
│ │ │ │ -
20
│ │ │ │ -
21namespace Dune {
│ │ │ │ -
22 namespace GridGlue {
│ │ │ │ +
5/*
│ │ │ │ +
6 * Filename: GridGlueVtkWriter.hh
│ │ │ │ +
7 * Version: 1.0
│ │ │ │ +
8 * Created on: Mar 5, 2009
│ │ │ │ +
9 * Author: Gerrit Buse
│ │ │ │ +
10 * ---------------------------------
│ │ │ │ +
11 * Project: dune-grid-glue
│ │ │ │ +
12 * Description: Class thought to make graphical debugging of couplings easier.
│ │ │ │ +
13 *
│ │ │ │ +
14 */
│ │ │ │ +
20#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH
│ │ │ │ +
21#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH
│ │ │ │ +
22
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
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 };
│ │ │ │ -
│ │ │ │ +
24#include <fstream>
│ │ │ │ +
25#include <iomanip>
│ │ │ │ +
26#include <type_traits>
│ │ │ │ +
27#include <vector>
│ │ │ │ +
28
│ │ │ │ +
29#include <dune/common/classname.hh>
│ │ │ │ +
30#include <dune/geometry/type.hh>
│ │ │ │ +
31#include <dune/geometry/referenceelements.hh>
│ │ │ │ +
32
│ │ │ │ + │ │ │ │ +
34
│ │ │ │ +
35namespace Dune {
│ │ │ │ +
36namespace GridGlue {
│ │ │ │ +
37
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
41{
│ │ │ │ +
42
│ │ │ │ +
46 template <class Glue, int side>
│ │ │ │ +
47 static void writeExtractedPart(const Glue& glue, const std::string& filename)
│ │ │ │ +
48 {
│ │ │ │ +
49 static_assert((side==0 || side==1), "'side' can only be 0 or 1");
│ │ │ │ +
50
│ │ │ │ +
51 std::ofstream fgrid;
│ │ │ │ +
52
│ │ │ │ +
53 fgrid.open(filename.c_str());
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
55 using GridView = typename Glue::template GridView<side>;
│ │ │ │ +
56 using Extractor = typename Glue::template GridPatch<side>;
│ │ │ │ +
57
│ │ │ │ +
58 typedef typename GridView::ctype ctype;
│ │ │ │ +
59
│ │ │ │ +
60 const int domdimw = GridView::dimensionworld;
│ │ │ │ +
61 const int patchDim = Extractor::dim - Extractor::codim;
│ │ │ │
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 interface object
│ │ │ │ - │ │ │ │ +
63 // coordinates have to be in R^3 in the VTK format
│ │ │ │ +
64 std::string coordinatePadding;
│ │ │ │ +
65 for (int i=domdimw; i<3; i++)
│ │ │ │ +
66 coordinatePadding += " 0";
│ │ │ │ +
67
│ │ │ │ +
68 fgrid << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" << std::endl;
│ │ │ │ +
69
│ │ │ │ +
70 // WRITE POINTS
│ │ │ │ +
71 // ----------------
│ │ │ │ +
72 std::vector<typename Extractor::Coords> coords;
│ │ │ │ +
73 glue.template patch<side>().getCoords(coords);
│ │ │ │ +
74
│ │ │ │ +
75 fgrid << ((patchDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") << std::endl;
│ │ │ │ +
76 fgrid << "POINTS " << coords.size() << " " << Dune::className<ctype>() << std::endl;
│ │ │ │ +
77
│ │ │ │ +
78 for (size_t i=0; i<coords.size(); i++)
│ │ │ │ +
79 fgrid << coords[i] << coordinatePadding << std::endl;
│ │ │ │ +
80
│ │ │ │ +
81 fgrid << std::endl;
│ │ │ │ +
82
│ │ │ │ +
83 // WRITE POLYGONS
│ │ │ │ +
84 // ----------------
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
86 std::vector<typename Extractor::VertexVector> faces;
│ │ │ │ +
87 std::vector<Dune::GeometryType> geometryTypes;
│ │ │ │ +
88 glue.template patch<side>().getFaces(faces);
│ │ │ │ +
89 glue.template patch<side>().getGeometryTypes(geometryTypes);
│ │ │ │ +
90
│ │ │ │ +
91 unsigned int faceCornerCount = 0;
│ │ │ │ +
92 for (size_t i=0; i<faces.size(); i++)
│ │ │ │ +
93 faceCornerCount += faces[i].size();
│ │ │ │ +
94
│ │ │ │ +
95 fgrid << ((patchDim==3) ? "CELLS " : "POLYGONS ")
│ │ │ │ +
96 << geometryTypes.size() << " " << geometryTypes.size() + faceCornerCount << std::endl;
│ │ │ │
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);
│ │ │ │ +
98 for (size_t i=0; i<faces.size(); i++) {
│ │ │ │ +
99
│ │ │ │ +
100 fgrid << faces[i].size();
│ │ │ │ +
101
│ │ │ │ +
102 // vtk expects the vertices to by cyclically ordered
│ │ │ │ +
103 // therefore unfortunately we have to deal with several element types on a case-by-case basis
│ │ │ │ +
104 if (geometryTypes[i].isSimplex()) {
│ │ │ │ +
105 for (int j=0; j<patchDim+1; j++)
│ │ │ │ +
106 fgrid << " " << faces[i][j];
│ │ │ │ +
107
│ │ │ │ +
108 } else if (geometryTypes[i].isQuadrilateral()) {
│ │ │ │ +
109 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ +
110 << " " << faces[i][3] << " " << faces[i][2];
│ │ │ │ +
111
│ │ │ │ +
112 } else if (geometryTypes[i].isPyramid()) {
│ │ │ │ +
113 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ +
114 << " " << faces[i][3] << " " << faces[i][2] << " " << faces[i][4];
│ │ │ │ +
115
│ │ │ │ +
116 } else if (geometryTypes[i].isPrism()) {
│ │ │ │ +
117 fgrid << " " << faces[i][0] << " " << faces[i][2] << " " << faces[i][1]
│ │ │ │ +
118 << " " << faces[i][3] << " " << faces[i][5] << " " << faces[i][4];
│ │ │ │ +
119
│ │ │ │ +
120 } else if (geometryTypes[i].isHexahedron()) {
│ │ │ │ +
121 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ +
122 << " " << faces[i][3] << " " << faces[i][2]
│ │ │ │ +
123 << " " << faces[i][4] << " " << faces[i][5]
│ │ │ │ +
124 << " " << faces[i][7] << " " << faces[i][6];
│ │ │ │ +
125
│ │ │ │ +
126 } else {
│ │ │ │ +
127 DUNE_THROW(Dune::NotImplemented, "Geometry type " << geometryTypes[i] << " not supported yet");
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
129
│ │ │ │ +
130 fgrid << std::endl;
│ │ │ │ +
131 }
│ │ │ │ +
132
│ │ │ │ +
133 fgrid << std::endl;
│ │ │ │ +
134
│ │ │ │ +
135 // 3d VTK files need an extra section specifying the CELL_TYPES aka GeometryTypes
│ │ │ │ +
136 if (patchDim==3) {
│ │ │ │ +
137
│ │ │ │ +
138 fgrid << "CELL_TYPES " << geometryTypes.size() << std::endl;
│ │ │ │ +
139
│ │ │ │ +
140 for (size_t i=0; i<geometryTypes.size(); i++) {
│ │ │ │ +
141 if (geometryTypes[i].isSimplex())
│ │ │ │ +
142 fgrid << "10" << std::endl;
│ │ │ │ +
143 else if (geometryTypes[i].isHexahedron())
│ │ │ │ +
144 fgrid << "12" << std::endl;
│ │ │ │ +
145 else if (geometryTypes[i].isPrism())
│ │ │ │ +
146 fgrid << "13" << std::endl;
│ │ │ │ +
147 else if (geometryTypes[i].isPyramid())
│ │ │ │ +
148 fgrid << "14" << std::endl;
│ │ │ │ +
149 else
│ │ │ │ +
150 DUNE_THROW(Dune::NotImplemented, "Geometry type " << geometryTypes[i] << " not supported yet");
│ │ │ │ +
151
│ │ │ │ +
152 }
│ │ │ │ +
153
│ │ │ │ +
154 }
│ │ │ │ +
155
│ │ │ │ +
156#if 0
│ │ │ │ +
157 // WRITE CELL DATA
│ │ │ │ +
158 // ---------------
│ │ │ │ +
159 ctype accum = 0.0, delta = 1.0 / (ctype) (gridSubEntityData.size()-1);
│ │ │ │
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 }
│ │ │ │ -
│ │ │ │ +
161 fgrid << "CELL_DATA " << gridSubEntityData.size() << std::endl;
│ │ │ │ +
162 fgrid << "SCALARS property_coding " << Dune::className<ctype>() << " 1" << std::endl;
│ │ │ │ +
163 fgrid << "LOOKUP_TABLE default" << std::endl;
│ │ │ │ +
164
│ │ │ │ +
165 for (typename GridSubEntityData::const_iterator sEIt = gridSubEntityData.begin();
│ │ │ │ +
166 sEIt != gridSubEntityData.end();
│ │ │ │ +
167 ++sEIt, accum += delta)
│ │ │ │ +
168 {
│ │ │ │ +
169 // "encode" the parent with one color...
│ │ │ │ +
170 fgrid << accum << std::endl;
│ │ │ │ +
171 }
│ │ │ │ +
172#endif
│ │ │ │ +
173 fgrid.close();
│ │ │ │ +
174 }
│ │ │ │ +
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;
│ │ │ │ +
180 template <class Glue, int side>
│ │ │ │ +
181 static void writeIntersections(const Glue& glue, const std::string& filename)
│ │ │ │ +
182 {
│ │ │ │ +
183 static_assert((side==0 || side==1), "'side' can only be 0 or 1");
│ │ │ │ +
184
│ │ │ │ +
185 std::ofstream fmerged;
│ │ │ │ +
186
│ │ │ │ +
187 fmerged.open(filename.c_str());
│ │ │ │ +
188
│ │ │ │ +
189 using GridView = typename Glue::template GridView<side>;
│ │ │ │ +
190 typedef typename GridView::ctype ctype;
│ │ │ │ +
191
│ │ │ │ +
192 const int domdimw = GridView::dimensionworld;
│ │ │ │ +
193 const int intersectionDim = Glue::Intersection::mydim;
│ │ │ │ +
194
│ │ │ │ +
195 // coordinates have to be in R^3 in the VTK format
│ │ │ │ +
196 std::string coordinatePadding;
│ │ │ │ +
197 for (int i=domdimw; i<3; i++)
│ │ │ │ +
198 coordinatePadding += " 0";
│ │ │ │ +
199
│ │ │ │ +
200 int overlaps = glue.size();
│ │ │ │ +
201
│ │ │ │ +
202 // WRITE POINTS
│ │ │ │ +
203 // ----------------
│ │ │ │ +
204 using Extractor = typename Glue::template GridPatch<0>;
│ │ │ │ +
205 std::vector<typename Extractor::Coords> coords;
│ │ │ │ +
206 glue.template patch<side>().getCoords(coords);
│ │ │ │ +
207
│ │ │ │ +
208 // the merged grid (i.e. the set of remote intersections
│ │ │ │ +
209 fmerged << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" << std::endl;
│ │ │ │ +
210 fmerged << ((intersectionDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") << std::endl;
│ │ │ │ +
211 fmerged << "POINTS " << overlaps*(intersectionDim+1) << " " << Dune::className<ctype>() << std::endl;
│ │ │ │ +
212
│ │ │ │ +
213 for (const auto& intersection : intersections(glue, Reverse<side == 1>{}))
│ │ │ │ +
214 {
│ │ │ │ +
215 const auto& geometry = intersection.geometry();
│ │ │ │ +
216 for (int i = 0; i < geometry.corners(); ++i)
│ │ │ │ +
217 fmerged << geometry.corner(i) << coordinatePadding << std::endl;
│ │ │ │ +
218 }
│ │ │ │ +
219
│ │ │ │ +
220 // WRITE POLYGONS
│ │ │ │ +
221 // ----------------
│ │ │ │ +
222
│ │ │ │ +
223 std::vector<typename Extractor::VertexVector> faces;
│ │ │ │ +
224 std::vector<Dune::GeometryType> geometryTypes;
│ │ │ │ +
225 glue.template patch<side>().getFaces(faces);
│ │ │ │ +
226 glue.template patch<side>().getGeometryTypes(geometryTypes);
│ │ │ │ +
227
│ │ │ │ +
228 unsigned int faceCornerCount = 0;
│ │ │ │ +
229 for (size_t i=0; i<faces.size(); i++)
│ │ │ │ +
230 faceCornerCount += faces[i].size();
│ │ │ │ +
231
│ │ │ │ +
232 int grid0SimplexCorners = intersectionDim+1;
│ │ │ │ +
233 fmerged << ((intersectionDim==3) ? "CELLS " : "POLYGONS ")
│ │ │ │ +
234 << overlaps << " " << (grid0SimplexCorners+1)*overlaps << std::endl;
│ │ │ │ +
235
│ │ │ │ +
236 for (int i = 0; i < overlaps; ++i) {
│ │ │ │ +
237 fmerged << grid0SimplexCorners;
│ │ │ │ +
238 for (int j=0; j<grid0SimplexCorners; j++)
│ │ │ │ +
239 fmerged << " " << grid0SimplexCorners*i+j;
│ │ │ │ +
240 fmerged << std::endl;
│ │ │ │ +
241 }
│ │ │ │
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
│ │ │ │ +
243 // 3d VTK files need an extra section specifying the CELL_TYPES aka GeometryTypes
│ │ │ │ +
244 if (intersectionDim==3) {
│ │ │ │ +
245
│ │ │ │ +
246 fmerged << "CELL_TYPES " << overlaps << std::endl;
│ │ │ │ +
247
│ │ │ │ +
248 for (int i = 0; i < overlaps; i++)
│ │ │ │ +
249 fmerged << "10" << std::endl;
│ │ │ │ +
250
│ │ │ │ +
251 }
│ │ │ │ +
252
│ │ │ │ +
253#if 0
│ │ │ │ +
254 // WRITE CELL DATA
│ │ │ │ +
255 // ---------------
│ │ │ │ +
256 ctype accum = 0.0, delta = 1.0 / (ctype) (gridSubEntityData.size()-1);
│ │ │ │ +
257
│ │ │ │ +
258 fmerged << "CELL_DATA " << overlaps << std::endl;
│ │ │ │ +
259 fmerged << "SCALARS property_coding " << Dune::className<ctype>() << " 1" << std::endl;
│ │ │ │ +
260 fmerged << "LOOKUP_TABLE default" << std::endl;
│ │ │ │ +
261
│ │ │ │ +
262 for (typename GridSubEntityData::const_iterator sEIt = gridSubEntityData.begin();
│ │ │ │ +
263 sEIt != gridSubEntityData.end();
│ │ │ │ +
264 ++sEIt, accum += delta)
│ │ │ │ +
265 {
│ │ │ │ +
266 // ...and mark all of its merged grid parts with the same color
│ │ │ │ +
267 for (int j = 0; j < sEIt->first.second; ++j)
│ │ │ │ +
268 fmerged << accum << std::endl;
│ │ │ │ +
269 }
│ │ │ │ +
270#endif
│ │ │ │ +
271 fmerged.close();
│ │ │ │ +
272 }
│ │ │ │ +
273
│ │ │ │ +
274public:
│ │ │ │ +
275 template<typename Glue>
│ │ │ │ +
│ │ │ │ +
276 static void write(const Glue& glue, const std::string& filenameTrunk)
│ │ │ │ +
277 {
│ │ │ │ +
278
│ │ │ │ +
279 // Write extracted grid and remote intersection on the grid0-side
│ │ │ │ +
280 writeExtractedPart<Glue,0>(glue,
│ │ │ │ +
281 filenameTrunk + "-grid0.vtk");
│ │ │ │ +
282
│ │ │ │ +
283 writeIntersections<Glue,0>(glue,
│ │ │ │ +
284 filenameTrunk + "-intersections-grid0.vtk");
│ │ │ │ +
285
│ │ │ │ +
286 // Write extracted grid and remote intersection on the grid1-side
│ │ │ │ +
287 writeExtractedPart<Glue,1>(glue,
│ │ │ │ +
288 filenameTrunk + "-grid1.vtk");
│ │ │ │ +
289
│ │ │ │ +
290 writeIntersections<Glue,1>(glue,
│ │ │ │ +
291 filenameTrunk + "-intersections-grid1.vtk");
│ │ │ │
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 }
│ │ │ │ +
293 }
│ │ │ │
│ │ │ │ -
329 };
│ │ │ │ +
294
│ │ │ │ +
295};
│ │ │ │
│ │ │ │ -
330#endif
│ │ │ │ -
331
│ │ │ │ -
332} // end namespace Dune
│ │ │ │ -
333#endif
│ │ │ │ +
296
│ │ │ │ +
297} /* namespace GridGlue */
│ │ │ │ +
298} /* namespace Dune */
│ │ │ │ +
299
│ │ │ │ +
300#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_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:257
│ │ │ │ -
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition intersection.hh:474
│ │ │ │ -
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition intersection.hh:384
│ │ │ │ -
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition intersection.hh:315
│ │ │ │ -
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition intersection.hh:390
│ │ │ │ -
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition intersection.hh:324
│ │ │ │ -
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 required 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
│ │ │ │ +
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ +
Write remote intersections to a vtk file for debugging purposes.
Definition gridgluevtkwriter.hh:41
│ │ │ │ +
static void write(const Glue &glue, const std::string &filenameTrunk)
Definition gridgluevtkwriter.hh:276
│ │ │ │ +
Definition rangegenerators.hh:17
│ │ │ │ +
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
│ │ │ │ +
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │ +
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition extractor.hh:256
│ │ │ │ +
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,442 +1,349 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -gridgluecommunicate.hh │ │ │ │ │ +gridgluevtkwriter.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 │ │ │ │ │ -14 │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20 │ │ │ │ │ -21namespace Dune { │ │ │ │ │ -22 namespace GridGlue { │ │ │ │ │ +5/* │ │ │ │ │ +6 * Filename: GridGlueVtkWriter.hh │ │ │ │ │ +7 * Version: 1.0 │ │ │ │ │ +8 * Created on: Mar 5, 2009 │ │ │ │ │ +9 * Author: Gerrit Buse │ │ │ │ │ +10 * --------------------------------- │ │ │ │ │ +11 * Project: dune-grid-glue │ │ │ │ │ +12 * Description: Class thought to make graphical debugging of couplings │ │ │ │ │ +easier. │ │ │ │ │ +13 * │ │ │ │ │ +14 */ │ │ │ │ │ +20#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH │ │ │ │ │ +21#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH │ │ │ │ │ +22 │ │ │ │ │ 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 } │ │ │ │ │ -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 }; │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28 │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32 │ │ │ │ │ +33#include │ │ │ │ │ +34 │ │ │ │ │ +35namespace Dune { │ │ │ │ │ +36namespace GridGlue { │ │ │ │ │ +37 │ │ │ │ │ +40class GridGlueVtkWriter │ │ │ │ │ +41{ │ │ │ │ │ +42 │ │ │ │ │ +46 template │ │ │ │ │ +47 static void writeExtractedPart(const Glue& glue, const std::string& │ │ │ │ │ +filename) │ │ │ │ │ +48 { │ │ │ │ │ +49 static_assert((side==0 || side==1), "'side' can only be 0 or 1"); │ │ │ │ │ +50 │ │ │ │ │ +51 std::ofstream fgrid; │ │ │ │ │ +52 │ │ │ │ │ +53 fgrid.open(filename.c_str()); │ │ │ │ │ 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 } │ │ │ │ │ +55 using GridView = typename Glue::template GridView; │ │ │ │ │ +56 using Extractor = typename Glue::template GridPatch; │ │ │ │ │ +57 │ │ │ │ │ +58 typedef typename GridView::ctype ctype; │ │ │ │ │ +59 │ │ │ │ │ +60 const int domdimw = GridView::dimensionworld; │ │ │ │ │ +61 const int patchDim = Extractor::dim - Extractor::codim; │ │ │ │ │ 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 interface object │ │ │ │ │ -84 CommDataHandle() {} │ │ │ │ │ +63 // coordinates have to be in R^3 in the VTK format │ │ │ │ │ +64 std::string coordinatePadding; │ │ │ │ │ +65 for (int i=domdimw; i<3; i++) │ │ │ │ │ +66 coordinatePadding += " 0"; │ │ │ │ │ +67 │ │ │ │ │ +68 fgrid << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" │ │ │ │ │ +<< std::endl; │ │ │ │ │ +69 │ │ │ │ │ +70 // WRITE POINTS │ │ │ │ │ +71 // ---------------- │ │ │ │ │ +72 std::vector coords; │ │ │ │ │ +73 glue.template patch().getCoords(coords); │ │ │ │ │ +74 │ │ │ │ │ +75 fgrid << ((patchDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") │ │ │ │ │ +<< std::endl; │ │ │ │ │ +76 fgrid << "POINTS " << coords.size() << " " << Dune::className() << │ │ │ │ │ +std::endl; │ │ │ │ │ +77 │ │ │ │ │ +78 for (size_t i=0; i │ │ │ │ │ -92 size_t size (RISType& i) const │ │ │ │ │ -93 { │ │ │ │ │ -94 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(i))); │ │ │ │ │ -95 return asImp().size(i); │ │ │ │ │ -96 } │ │ │ │ │ +86 std::vector faces; │ │ │ │ │ +87 std::vector geometryTypes; │ │ │ │ │ +88 glue.template patch().getFaces(faces); │ │ │ │ │ +89 glue.template patch().getGeometryTypes(geometryTypes); │ │ │ │ │ +90 │ │ │ │ │ +91 unsigned int faceCornerCount = 0; │ │ │ │ │ +92 for (size_t i=0; i │ │ │ │ │ -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); │ │ │ │ │ +98 for (size_t i=0; i(*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 } │ │ │ │ │ +129 │ │ │ │ │ +130 fgrid << std::endl; │ │ │ │ │ +131 } │ │ │ │ │ +132 │ │ │ │ │ +133 fgrid << std::endl; │ │ │ │ │ +134 │ │ │ │ │ +135 // 3d VTK files need an extra section specifying the CELL_TYPES aka │ │ │ │ │ +GeometryTypes │ │ │ │ │ +136 if (patchDim==3) { │ │ │ │ │ +137 │ │ │ │ │ +138 fgrid << "CELL_TYPES " << geometryTypes.size() << std::endl; │ │ │ │ │ +139 │ │ │ │ │ +140 for (size_t i=0; i │ │ │ │ │ -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 } │ │ │ │ │ +161 fgrid << "CELL_DATA " << gridSubEntityData.size() << std::endl; │ │ │ │ │ +162 fgrid << "SCALARS property_coding " << Dune::className() << " 1" << │ │ │ │ │ +std::endl; │ │ │ │ │ +163 fgrid << "LOOKUP_TABLE default" << std::endl; │ │ │ │ │ +164 │ │ │ │ │ +165 for (typename GridSubEntityData::const_iterator sEIt = │ │ │ │ │ +gridSubEntityData.begin(); │ │ │ │ │ +166 sEIt != gridSubEntityData.end(); │ │ │ │ │ +167 ++sEIt, accum += delta) │ │ │ │ │ +168 { │ │ │ │ │ +169 // "encode" the parent with one color... │ │ │ │ │ +170 fgrid << accum << std::endl; │ │ │ │ │ +171 } │ │ │ │ │ +172#endif │ │ │ │ │ +173 fgrid.close(); │ │ │ │ │ +174 } │ │ │ │ │ +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) │ │ │ │ │ +180 template │ │ │ │ │ +181 static void writeIntersections(const Glue& glue, const std::string& │ │ │ │ │ +filename) │ │ │ │ │ +182 { │ │ │ │ │ +183 static_assert((side==0 || side==1), "'side' can only be 0 or 1"); │ │ │ │ │ +184 │ │ │ │ │ +185 std::ofstream fmerged; │ │ │ │ │ +186 │ │ │ │ │ +187 fmerged.open(filename.c_str()); │ │ │ │ │ +188 │ │ │ │ │ +189 using GridView = typename Glue::template GridView; │ │ │ │ │ +190 typedef typename GridView::ctype ctype; │ │ │ │ │ +191 │ │ │ │ │ +192 const int domdimw = GridView::dimensionworld; │ │ │ │ │ +193 const int intersectionDim = Glue::Intersection::mydim; │ │ │ │ │ +194 │ │ │ │ │ +195 // coordinates have to be in R^3 in the VTK format │ │ │ │ │ +196 std::string coordinatePadding; │ │ │ │ │ +197 for (int i=domdimw; i<3; i++) │ │ │ │ │ +198 coordinatePadding += " 0"; │ │ │ │ │ +199 │ │ │ │ │ +200 int overlaps = glue.size(); │ │ │ │ │ +201 │ │ │ │ │ +202 // WRITE POINTS │ │ │ │ │ +203 // ---------------- │ │ │ │ │ +204 using Extractor = typename Glue::template GridPatch<0>; │ │ │ │ │ +205 std::vector coords; │ │ │ │ │ +206 glue.template patch().getCoords(coords); │ │ │ │ │ +207 │ │ │ │ │ +208 // the merged grid (i.e. the set of remote intersections │ │ │ │ │ +209 fmerged << "# vtk DataFile Version 2.0\nFilename: " << filename << │ │ │ │ │ +"\nASCII" << std::endl; │ │ │ │ │ +210 fmerged << ((intersectionDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET │ │ │ │ │ +POLYDATA") << std::endl; │ │ │ │ │ +211 fmerged << "POINTS " << overlaps*(intersectionDim+1) << " " << Dune:: │ │ │ │ │ +className() << std::endl; │ │ │ │ │ +212 │ │ │ │ │ +213 for (const auto& intersection : intersections(glue, Reverse{})) │ │ │ │ │ 214 { │ │ │ │ │ -215 // read from grid1 │ │ │ │ │ -216 if(ris.neighbor()) │ │ │ │ │ -217 commInfo.data->gather(commInfo.mbuffer, ris.outside(), ris.flip()); │ │ │ │ │ +215 const auto& geometry = intersection.geometry(); │ │ │ │ │ +216 for (int i = 0; i < geometry.corners(); ++i) │ │ │ │ │ +217 fmerged << geometry.corner(i) << coordinatePadding << std::endl; │ │ │ │ │ 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; │ │ │ │ │ +219 │ │ │ │ │ +220 // WRITE POLYGONS │ │ │ │ │ +221 // ---------------- │ │ │ │ │ +222 │ │ │ │ │ +223 std::vector faces; │ │ │ │ │ +224 std::vector geometryTypes; │ │ │ │ │ +225 glue.template patch().getFaces(faces); │ │ │ │ │ +226 glue.template patch().getGeometryTypes(geometryTypes); │ │ │ │ │ +227 │ │ │ │ │ +228 unsigned int faceCornerCount = 0; │ │ │ │ │ +229 for (size_t i=0; iscatter(commInfo.mbuffer, ris.outside(), ris.flip(), │ │ │ │ │ -commInfo.currentsize); │ │ │ │ │ +243 // 3d VTK files need an extra section specifying the CELL_TYPES aka │ │ │ │ │ +GeometryTypes │ │ │ │ │ +244 if (intersectionDim==3) { │ │ │ │ │ +245 │ │ │ │ │ +246 fmerged << "CELL_TYPES " << overlaps << std::endl; │ │ │ │ │ +247 │ │ │ │ │ +248 for (int i = 0; i < overlaps; i++) │ │ │ │ │ +249 fmerged << "10" << std::endl; │ │ │ │ │ +250 │ │ │ │ │ 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 │ │ │ │ │ +252 │ │ │ │ │ +253#if 0 │ │ │ │ │ +254 // WRITE CELL DATA │ │ │ │ │ +255 // --------------- │ │ │ │ │ +256 ctype accum = 0.0, delta = 1.0 / (ctype) (gridSubEntityData.size()-1); │ │ │ │ │ +257 │ │ │ │ │ +258 fmerged << "CELL_DATA " << overlaps << std::endl; │ │ │ │ │ +259 fmerged << "SCALARS property_coding " << Dune::className() << " 1" │ │ │ │ │ +<< std::endl; │ │ │ │ │ +260 fmerged << "LOOKUP_TABLE default" << std::endl; │ │ │ │ │ +261 │ │ │ │ │ +262 for (typename GridSubEntityData::const_iterator sEIt = │ │ │ │ │ +gridSubEntityData.begin(); │ │ │ │ │ +263 sEIt != gridSubEntityData.end(); │ │ │ │ │ +264 ++sEIt, accum += delta) │ │ │ │ │ +265 { │ │ │ │ │ +266 // ...and mark all of its merged grid parts with the same color │ │ │ │ │ +267 for (int j = 0; j < sEIt->first.second; ++j) │ │ │ │ │ +268 fmerged << accum << std::endl; │ │ │ │ │ +269 } │ │ │ │ │ +270#endif │ │ │ │ │ +271 fmerged.close(); │ │ │ │ │ +272 } │ │ │ │ │ +273 │ │ │ │ │ +274public: │ │ │ │ │ +275 template │ │ │ │ │ +276 static void write(const Glue& glue, const std::string& filenameTrunk) │ │ │ │ │ +277 { │ │ │ │ │ +278 │ │ │ │ │ +279 // Write extracted grid and remote intersection on the grid0-side │ │ │ │ │ +280 writeExtractedPart(glue, │ │ │ │ │ +281 filenameTrunk + "-grid0.vtk"); │ │ │ │ │ +282 │ │ │ │ │ +283 writeIntersections(glue, │ │ │ │ │ +284 filenameTrunk + "-intersections-grid0.vtk"); │ │ │ │ │ +285 │ │ │ │ │ +286 // Write extracted grid and remote intersection on the grid1-side │ │ │ │ │ +287 writeExtractedPart(glue, │ │ │ │ │ +288 filenameTrunk + "-grid1.vtk"); │ │ │ │ │ +289 │ │ │ │ │ +290 writeIntersections(glue, │ │ │ │ │ +291 filenameTrunk + "-intersections-grid1.vtk"); │ │ │ │ │ 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 │ │ │ │ │ +293 } │ │ │ │ │ +294 │ │ │ │ │ +295}; │ │ │ │ │ +296 │ │ │ │ │ +297} /* namespace GridGlue */ │ │ │ │ │ +298} /* namespace Dune */ │ │ │ │ │ +299 │ │ │ │ │ +300#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_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:257 │ │ │ │ │ -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:474 │ │ │ │ │ -Dune::GridGlue::Intersection::self │ │ │ │ │ -bool self() const │ │ │ │ │ -For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ -Definition intersection.hh:384 │ │ │ │ │ -Dune::GridGlue::Intersection::inside │ │ │ │ │ -InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the inside of this intersection. │ │ │ │ │ -Definition intersection.hh:315 │ │ │ │ │ -Dune::GridGlue::Intersection::neighbor │ │ │ │ │ -size_t neighbor(unsigned int g=0) const │ │ │ │ │ -Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ -Definition intersection.hh:390 │ │ │ │ │ -Dune::GridGlue::Intersection::outside │ │ │ │ │ -OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the outside of this intersection. │ │ │ │ │ -Definition intersection.hh:324 │ │ │ │ │ -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) │ │ │ │ │ +Dune::GridGlue::intersections │ │ │ │ │ +IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ +> &reverse=!reversed) │ │ │ │ │ +Iterate over all intersections of a GridGlue. │ │ │ │ │ +Dune::GridGlue::GridGlueVtkWriter │ │ │ │ │ +Write remote intersections to a vtk file for debugging purposes. │ │ │ │ │ +Definition gridgluevtkwriter.hh:41 │ │ │ │ │ +Dune::GridGlue::GridGlueVtkWriter::write │ │ │ │ │ +static void write(const Glue &glue, const std::string &filenameTrunk) │ │ │ │ │ +Definition gridgluevtkwriter.hh:276 │ │ │ │ │ +Dune::GridGlue::Reverse │ │ │ │ │ +Definition rangegenerators.hh:17 │ │ │ │ │ +Dune::GridGlue::Extractor │ │ │ │ │ +Provides codimension-independent methods for grid extraction. │ │ │ │ │ +Definition extractor.hh:46 │ │ │ │ │ +Dune::GridGlue::Extractor::codim │ │ │ │ │ +static constexpr auto codim │ │ │ │ │ +Definition extractor.hh:52 │ │ │ │ │ +Dune::GridGlue::Extractor::getCoords │ │ │ │ │ +void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) │ │ │ │ │ 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 required 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 │ │ │ │ │ +getter for the coordinates array │ │ │ │ │ +Definition extractor.hh:256 │ │ │ │ │ +Dune::GridGlue::Extractor::dim │ │ │ │ │ +static constexpr auto dim │ │ │ │ │ +Definition extractor.hh:51 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersection.hh File Reference │ │ │ │ +dune-grid-glue: gridglueamirawriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,74 +71,42 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros
│ │ │ │ -
intersection.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
gridglueamirawriter.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Model of the Intersection concept provided by GridGlue. │ │ │ │ +

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

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <optional>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include <dune/common/deprecated.hh>
│ │ │ │ -#include <dune/common/version.hh>
│ │ │ │ -#include <dune/geometry/affinegeometry.hh>
│ │ │ │ -#include <dune/geometry/referenceelements.hh>
│ │ │ │ -#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +
#include <fstream>
│ │ │ │ +#include <sstream>
│ │ │ │ +#include <type_traits>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::GridGlue::IntersectionData< P0, P1 >
 storage class for Dune::GridGlue::Intersection related data More...
 
struct  Dune::GridGlue::IntersectionTraits< P0, P1, inside, outside >
 
class  Dune::GridGlue::Intersection< P0, P1, I, O >
 The intersection of two entities of the two patches of a GridGlue. More...
class  Dune::GridGlue::GridGlueAmiraWriter
 Write remote intersections to a AmiraMesh file for debugging purposes. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

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

│ │ │ │ -Macros

#define ONLY_SIMPLEX_INTERSECTIONS
 
│ │ │ │

Detailed Description

│ │ │ │ -

Model of the Intersection concept provided by GridGlue.

│ │ │ │ -
Author
Christian Engwer
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ ONLY_SIMPLEX_INTERSECTIONS

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Write all remote intersections to a AmiraMesh file.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,46 +1,28 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces | Macros │ │ │ │ │ -intersection.hh File Reference │ │ │ │ │ -Model of the Intersection concept provided by GridGlue. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#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 │ │ │ │ │ - class   Dune::GridGlue::IntersectionData<_P0,_P1_> │ │ │ │ │ -  storage class for Dune::GridGlue::Intersection related data More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::IntersectionTraits<_P0,_P1,_inside,_outside_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::GridGlue::Intersection<_P0,_P1,_I,_O_> │ │ │ │ │ -  The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ - More... │ │ │ │ │ +class   Dune::GridGlue::GridGlueAmiraWriter │ │ │ │ │ +  Write remote intersections to a AmiraMesh file for debugging purposes. │ │ │ │ │ + More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Model of the Intersection concept provided by GridGlue. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ ONLY_SIMPLEX_INTERSECTIONS ***** │ │ │ │ │ -#define ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ +Write all remote intersections to a AmiraMesh file. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00017_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersection.hh Source File │ │ │ │ +dune-grid-glue: gridglueamirawriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,569 +74,166 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
intersection.hh
│ │ │ │ +
gridglueamirawriter.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
│ │ │ │ -
11#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ -
12#define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ -
13
│ │ │ │ -
14#include <algorithm>
│ │ │ │ -
15#include <optional>
│ │ │ │ -
16#include <tuple>
│ │ │ │ +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
│ │ │ │ +
8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ +
9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │ +
10
│ │ │ │ +
11#include <fstream>
│ │ │ │ +
12#include <sstream>
│ │ │ │ +
13#include <type_traits>
│ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16namespace GridGlue {
│ │ │ │
17
│ │ │ │ -
18#include <dune/common/deprecated.hh>
│ │ │ │ -
19#include <dune/common/version.hh>
│ │ │ │ -
20#include <dune/geometry/affinegeometry.hh>
│ │ │ │ -
21#include <dune/geometry/referenceelements.hh>
│ │ │ │ - │ │ │ │ -
23
│ │ │ │ -
24#define ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ -
25
│ │ │ │ -
26namespace Dune {
│ │ │ │ -
27 namespace GridGlue {
│ │ │ │ -
28
│ │ │ │ -
29 // forward declaration
│ │ │ │ -
30 template<typename P0, typename P1>
│ │ │ │ -
31 class IntersectionIndexSet;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
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
│ │ │ │ -
36 template<typename P0, typename P1>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
38 {
│ │ │ │ -
39 public:
│ │ │ │ -
40 typedef ::Dune::GridGlue::GridGlue<P0, P1> GridGlue;
│ │ │ │ -
41
│ │ │ │ - │ │ │ │ +
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
│ │ │ │ -
45 static constexpr int coorddim = GridGlue::dimworld;
│ │ │ │ -
46
│ │ │ │ -
47 private:
│ │ │ │ -
48 // intermediate quantities
│ │ │ │ -
49 template<int side>
│ │ │ │ -
50 static constexpr int dim() { return GridGlue::template GridView<side>::Grid::dimension - GridGlue::template GridPatch<side>::codim; }
│ │ │ │ -
51
│ │ │ │ -
52 public:
│ │ │ │ -
54 static constexpr int mydim = dim<0>() < dim<1>() ? dim<0>() : dim<1>();
│ │ │ │ -
55
│ │ │ │ -
56 template<int side>
│ │ │ │ -
57 using GridLocalGeometry = AffineGeometry<
│ │ │ │ -
58 typename GridGlue::template GridView<side>::ctype, mydim, GridGlue::template GridView<side>::dimension>;
│ │ │ │ -
59
│ │ │ │ -
60 using Grid0LocalGeometry [[deprecated("please use GridLocalGeometry<0> instead")]] = GridLocalGeometry<0>;
│ │ │ │ -
61 using Grid1LocalGeometry [[deprecated("please use GridLocalGeometry<1> instead")]] = GridLocalGeometry<1>;
│ │ │ │ -
62
│ │ │ │ -
63 template<int side>
│ │ │ │ -
64 using GridGeometry = AffineGeometry<
│ │ │ │ -
65 typename GridGlue::template GridView<side>::ctype, mydim, GridGlue::template GridView<side>::dimensionworld>;
│ │ │ │ -
66
│ │ │ │ -
67 using Grid0Geometry [[deprecated("please use GridGeometry<0> instead")]] = GridGeometry<0>;
│ │ │ │ -
68 using Grid1Geometry [[deprecated("please use GridGeometry<1> instead")]] = GridGeometry<1>;
│ │ │ │ -
69
│ │ │ │ -
70 template<int side>
│ │ │ │ -
71 using GridIndexType = typename GridGlue::template GridView<side>::IndexSet::IndexType;
│ │ │ │ -
72
│ │ │ │ -
73 using Grid0IndexType [[deprecated("please use GridIndexType<0> instead")]] = GridIndexType<0>;
│ │ │ │ -
74 using Grid1IndexType [[deprecated("please use GridIndexType<1> instead")]] = GridIndexType<1>;
│ │ │ │ +
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
│ │ │ │ -
77 IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int offset, bool grid0local, bool grid1local);
│ │ │ │ -
78
│ │ │ │ -
80 IntersectionData() = default;
│ │ │ │ -
81
│ │ │ │ -
82 /* Accessor Functions */
│ │ │ │ -
83
│ │ │ │ -
84 template<int side>
│ │ │ │ -
│ │ │ │ -
85 const GridLocalGeometry<side>& localGeometry(unsigned int parentId = 0) const
│ │ │ │ -
86 { return *std::get<side>(sideData_).gridlocalgeom[parentId]; }
│ │ │ │ -
│ │ │ │ -
87
│ │ │ │ -
88 template<int side>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
90 { return *std::get<side>(sideData_).gridgeom; }
│ │ │ │ -
│ │ │ │ -
91
│ │ │ │ -
92 template<int side>
│ │ │ │ -
│ │ │ │ -
93 bool local() const
│ │ │ │ -
94 { return std::get<side>(sideData_).gridlocal; }
│ │ │ │ -
│ │ │ │ -
95
│ │ │ │ -
96 template<int side>
│ │ │ │ -
│ │ │ │ -
97 IndexType index(unsigned int parentId = 0) const
│ │ │ │ -
98 { return std::get<side>(sideData_).gridindices[parentId]; }
│ │ │ │ -
│ │ │ │ -
99
│ │ │ │ -
100 template<int side>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
102 { return std::get<side>(sideData_).gridindices.size(); }
│ │ │ │ -
│ │ │ │ -
103
│ │ │ │ -
104 private:
│ │ │ │ -
105 template<int side>
│ │ │ │ -
106 void initializeGeometry(const GridGlue& glue, unsigned mergeindex);
│ │ │ │ -
107
│ │ │ │ -
108 /* M E M B E R V A R I A B L E S */
│ │ │ │ -
109
│ │ │ │ -
110 public:
│ │ │ │ - │ │ │ │ -
113
│ │ │ │ -
114 private:
│ │ │ │ -
115 template<int side>
│ │ │ │ -
116 struct SideData {
│ │ │ │ -
118 bool gridlocal = false;
│ │ │ │ -
119
│ │ │ │ -
121 std::vector< GridIndexType<side> > gridindices;
│ │ │ │ -
122
│ │ │ │ -
124 std::vector< std::optional< GridLocalGeometry<side> > > gridlocalgeom;
│ │ │ │ +
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
│ │ │ │ -
133 std::optional< GridGeometry<side> > gridgeom;
│ │ │ │ -
134 };
│ │ │ │ -
135
│ │ │ │ -
136 std::tuple< SideData<0>, SideData<1> > sideData_;
│ │ │ │ -
137 };
│ │ │ │ +
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 }
│ │ │ │
│ │ │ │ -
138
│ │ │ │ -
139 template<typename P0, typename P1>
│ │ │ │ -
140 template<int side>
│ │ │ │ -
141 void IntersectionData<P0, P1>::initializeGeometry(const GridGlue& glue, unsigned mergeindex)
│ │ │ │ -
142 {
│ │ │ │ -
143 auto& data = std::get<side>(sideData_);
│ │ │ │ -
144
│ │ │ │ -
145 const unsigned n_parents = glue.merger_->template parents<side>(mergeindex);
│ │ │ │
146
│ │ │ │ -
147 // init containers
│ │ │ │ -
148 data.gridindices.resize(n_parents);
│ │ │ │ -
149 data.gridlocalgeom.resize(n_parents);
│ │ │ │ -
150
│ │ │ │ -
151 // default values
│ │ │ │ -
152 data.gridindices[0] = 0;
│ │ │ │ -
153
│ │ │ │ -
154 static constexpr int nSimplexCorners = mydim + 1;
│ │ │ │ -
155 using ctype = typename GridGlue::ctype;
│ │ │ │ -
156
│ │ │ │ -
157 // initialize the local and the global geometries of grid `side`
│ │ │ │ -
158
│ │ │ │ -
159 // compute the coordinates of the subface's corners in codim 0 entity local coordinates
│ │ │ │ -
160 static constexpr int elementdim = GridGlue::template GridView<side>::template Codim<0>::Geometry::mydimension;
│ │ │ │ -
161
│ │ │ │ -
162 // coordinates within the subentity that contains the remote intersection
│ │ │ │ -
163 std::array<Dune::FieldVector< ctype, dim<side>() >, nSimplexCorners> corners_subEntity_local;
│ │ │ │ -
164
│ │ │ │ -
165 for (unsigned int par = 0; par < n_parents; ++par) {
│ │ │ │ -
166 for (int i = 0; i < nSimplexCorners; ++i)
│ │ │ │ -
167 corners_subEntity_local[i] = glue.merger_->template parentLocal<side>(mergeindex, i, par);
│ │ │ │ -
168
│ │ │ │ -
169 // Coordinates of the remote intersection corners wrt the element coordinate system
│ │ │ │ -
170 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
│ │ │ │ -
171
│ │ │ │ -
172 if (data.gridlocal) {
│ │ │ │ -
173 data.gridindices[par] = glue.merger_->template parent<side>(mergeindex,par);
│ │ │ │ -
174
│ │ │ │ -
175 typename GridGlue::template GridPatch<side>::LocalGeometry
│ │ │ │ -
176 gridLocalGeometry = glue.template patch<side>().geometryLocal(data.gridindices[par]);
│ │ │ │ -
177 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
│ │ │ │ -
178 corners_element_local[i] = gridLocalGeometry.global(corners_subEntity_local[i]);
│ │ │ │ -
179 }
│ │ │ │ -
180
│ │ │ │ -
181 // set the corners of the local geometry
│ │ │ │ -
182#ifdef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ -
183 const Dune::GeometryType type = Dune::GeometryTypes::simplex(mydim);
│ │ │ │ -
184#else
│ │ │ │ -
185#error Not Implemented
│ │ │ │ -
186#endif
│ │ │ │ -
187 data.gridlocalgeom[par].emplace(type, corners_element_local);
│ │ │ │ -
188
│ │ │ │ -
189 // Add world geometry only for 0th parent
│ │ │ │ -
190 if (par == 0) {
│ │ │ │ -
191 typename GridGlue::template GridPatch<side>::Geometry
│ │ │ │ -
192 gridWorldGeometry = glue.template patch<side>().geometry(data.gridindices[par]);
│ │ │ │ -
193
│ │ │ │ -
194 // world coordinates of the remote intersection corners
│ │ │ │ -
195 std::array<Dune::FieldVector<ctype, GridGlue::template GridView<side>::dimensionworld>, nSimplexCorners> corners_global;
│ │ │ │ -
196
│ │ │ │ -
197 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
│ │ │ │ -
198 corners_global[i] = gridWorldGeometry.global(corners_subEntity_local[i]);
│ │ │ │ -
199 }
│ │ │ │ -
200
│ │ │ │ -
201 data.gridgeom.emplace(type, corners_global);
│ │ │ │ -
202 }
│ │ │ │ -
203 }
│ │ │ │ -
204 }
│ │ │ │ -
205 }
│ │ │ │ -
206
│ │ │ │ -
208 template<typename P0, typename P1>
│ │ │ │ -
│ │ │ │ -
209 IntersectionData<P0, P1>::IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int offset,
│ │ │ │ -
210 bool grid0local, bool grid1local)
│ │ │ │ -
211 : index_(mergeindex+offset)
│ │ │ │ -
212 {
│ │ │ │ -
213 // if an invalid index is given do not proceed!
│ │ │ │ -
214 // (happens when the parent GridGlue initializes the "end"-Intersection)
│ │ │ │ -
215 assert (0 <= mergeindex || mergeindex < glue.index__sz);
│ │ │ │ -
216
│ │ │ │ -
217 std::get<0>(sideData_).gridlocal = grid0local;
│ │ │ │ -
218 std::get<1>(sideData_).gridlocal = grid1local;
│ │ │ │ -
219
│ │ │ │ -
220 initializeGeometry<0>(glue, mergeindex);
│ │ │ │ -
221 initializeGeometry<1>(glue, mergeindex);
│ │ │ │ -
222 }
│ │ │ │ -
│ │ │ │ -
223
│ │ │ │ -
228 template<typename P0, typename P1, int inside, int outside>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
230 {
│ │ │ │ - │ │ │ │ - │ │ │ │ -
233
│ │ │ │ -
234 using InsideGridView = typename GridGlue::template GridView<inside>;
│ │ │ │ -
235 using OutsideGridView = typename GridGlue::template GridView<outside>;
│ │ │ │ -
236
│ │ │ │ -
237 using InsideLocalGeometry = typename IntersectionData::template GridLocalGeometry<inside>;
│ │ │ │ -
238 using OutsideLocalGeometry = typename IntersectionData::template GridLocalGeometry<outside>;
│ │ │ │ -
239
│ │ │ │ -
240 using Geometry = typename IntersectionData::template GridGeometry<inside>;
│ │ │ │ -
241 using OutsideGeometry = typename IntersectionData::template GridGeometry<outside>;
│ │ │ │ -
242
│ │ │ │ -
243 static constexpr auto coorddim = IntersectionData::coorddim;
│ │ │ │ -
244 static constexpr auto mydim = IntersectionData::mydim;
│ │ │ │ -
245 static constexpr int insidePatch = inside;
│ │ │ │ -
246 static constexpr int outsidePatch = outside;
│ │ │ │ -
247
│ │ │ │ -
248 using ctype = typename GridGlue::ctype;
│ │ │ │ -
249 using LocalCoordinate = Dune::FieldVector<ctype, mydim>;
│ │ │ │ -
250 using GlobalCoordinate = Dune::FieldVector<ctype, coorddim>;
│ │ │ │ -
251 };
│ │ │ │ -
│ │ │ │ -
252
│ │ │ │ -
255 template<typename P0, typename P1, int I, int O>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
257 {
│ │ │ │ -
258
│ │ │ │ -
259 public:
│ │ │ │ -
260
│ │ │ │ - │ │ │ │ -
262
│ │ │ │ -
263 typedef typename Traits::GridGlue GridGlue;
│ │ │ │ - │ │ │ │ -
265
│ │ │ │ -
266
│ │ │ │ - │ │ │ │ - │ │ │ │ -
269
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
273
│ │ │ │ -
274 typedef typename Traits::Geometry Geometry;
│ │ │ │ -
275 typedef typename Traits::ctype ctype;
│ │ │ │ -
276
│ │ │ │ -
277 typedef typename InsideGridView::Traits::template Codim<0>::Entity InsideEntity;
│ │ │ │ -
278 typedef typename OutsideGridView::Traits::template Codim<0>::Entity OutsideEntity;
│ │ │ │ -
279
│ │ │ │ - │ │ │ │ - │ │ │ │ -
282
│ │ │ │ -
284 static constexpr auto coorddim = Traits::coorddim;
│ │ │ │ -
285
│ │ │ │ -
287 static constexpr auto mydim = Traits::mydim;
│ │ │ │ -
288
│ │ │ │ -
290 static constexpr int insidePatch = Traits::insidePatch;
│ │ │ │ -
291
│ │ │ │ -
293 static constexpr int outsidePatch = Traits::outsidePatch;
│ │ │ │ -
294
│ │ │ │ -
295 // typedef unsigned int IndexType;
│ │ │ │ -
296
│ │ │ │ -
297 private:
│ │ │ │ -
301 static constexpr int codimensionWorld = coorddim - mydim;
│ │ │ │ -
302
│ │ │ │ -
303 public:
│ │ │ │ -
304 /* C O N S T R U C T O R S */
│ │ │ │ -
305
│ │ │ │ -
│ │ │ │ -
307 Intersection(const GridGlue* glue, const IntersectionData* i) :
│ │ │ │ -
308 glue_(glue), i_(i) {}
│ │ │ │ -
│ │ │ │ -
309
│ │ │ │ -
310 /* F U N C T I O N A L I T Y */
│ │ │ │ -
311
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
315 inside(unsigned int parentId = 0) const
│ │ │ │ -
316 {
│ │ │ │ -
317 assert(self());
│ │ │ │ -
318 return glue_->template patch<I>().element(i_->template index<I>(parentId));
│ │ │ │ -
319 }
│ │ │ │ -
│ │ │ │ -
320
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
324 outside(unsigned int parentId = 0) const
│ │ │ │ -
325 {
│ │ │ │ -
326 assert(neighbor());
│ │ │ │ -
327 return glue_->template patch<O>().element(i_->template index<O>(parentId));
│ │ │ │ -
328 }
│ │ │ │ -
│ │ │ │ -
329
│ │ │ │ -
│ │ │ │ -
331 bool conforming() const
│ │ │ │ -
332 {
│ │ │ │ -
333 throw Dune::NotImplemented();
│ │ │ │ -
334 }
│ │ │ │ -
│ │ │ │ -
335
│ │ │ │ -
│ │ │ │ -
338 const InsideLocalGeometry& geometryInInside(unsigned int parentId = 0) const
│ │ │ │ -
339 {
│ │ │ │ -
340 return i_->template localGeometry<I>(parentId);
│ │ │ │ -
341 }
│ │ │ │ -
│ │ │ │ -
342
│ │ │ │ -
│ │ │ │ -
345 const OutsideLocalGeometry& geometryInOutside(unsigned int parentId = 0) const
│ │ │ │ -
346 {
│ │ │ │ -
347 return i_->template localGeometry<O>(parentId);
│ │ │ │ -
348 }
│ │ │ │ -
│ │ │ │ -
349
│ │ │ │ -
│ │ │ │ -
356 const Geometry& geometry() const
│ │ │ │ -
357 {
│ │ │ │ -
358 return i_->template geometry<I>();
│ │ │ │ -
359 }
│ │ │ │ -
│ │ │ │ -
360
│ │ │ │ -
│ │ │ │ -
367 const OutsideGeometry& geometryOutside() const // DUNE_DEPRECATED
│ │ │ │ -
368 {
│ │ │ │ -
369 return i_->template geometry<O>();
│ │ │ │ -
370 }
│ │ │ │ -
│ │ │ │ -
371
│ │ │ │ -
│ │ │ │ -
373 Dune::GeometryType type() const
│ │ │ │ -
374 {
│ │ │ │ -
375 #ifdef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ -
376 return Dune::GeometryTypes::simplex(mydim);
│ │ │ │ -
377 #else
│ │ │ │ -
378 #error Not Implemented
│ │ │ │ -
379 #endif
│ │ │ │ -
380 }
│ │ │ │ -
│ │ │ │ -
381
│ │ │ │ -
382
│ │ │ │ -
│ │ │ │ -
384 bool self() const
│ │ │ │ -
385 {
│ │ │ │ -
386 return i_->template local<I>();
│ │ │ │ -
387 }
│ │ │ │ -
│ │ │ │ -
388
│ │ │ │ -
│ │ │ │ -
390 size_t neighbor(unsigned int g = 0) const
│ │ │ │ -
391 {
│ │ │ │ -
392 if (g == 0 && i_->template local<O>()) {
│ │ │ │ -
393 return i_->template parents<O>();
│ │ │ │ -
394 } else if (g == 1 && i_->template local<I>()) {
│ │ │ │ -
395 return i_->template parents<I>();
│ │ │ │ -
396 }
│ │ │ │ -
397 return 0;
│ │ │ │ -
398 }
│ │ │ │ -
│ │ │ │ -
399
│ │ │ │ -
│ │ │ │ -
401 int indexInInside(unsigned int parentId = 0) const
│ │ │ │ -
402 {
│ │ │ │ -
403 assert(self());
│ │ │ │ -
404 return glue_->template patch<I>().indexInInside(i_->template index<I>(parentId));
│ │ │ │ -
405 }
│ │ │ │ -
│ │ │ │ -
406
│ │ │ │ -
│ │ │ │ -
408 int indexInOutside(unsigned int parentId = 0) const
│ │ │ │ -
409 {
│ │ │ │ -
410 assert(neighbor());
│ │ │ │ -
411 return glue_->template patch<O>().indexInInside(i_->template index<O>(parentId));
│ │ │ │ -
412 }
│ │ │ │ -
│ │ │ │ -
413
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
419 {
│ │ │ │ -
420 GlobalCoordinate normal;
│ │ │ │ -
421
│ │ │ │ -
422 if (codimensionWorld == 0)
│ │ │ │ -
423 DUNE_THROW(Dune::Exception, "There is no normal vector to a full-dimensional intersection");
│ │ │ │ -
424 else if (codimensionWorld == 1) {
│ │ │ │ -
425 /* TODO: Implement the general n-ary cross product here */
│ │ │ │ -
426 const auto jacobianTransposed = geometry().jacobianTransposed(local);
│ │ │ │ -
427 if (mydim==1) {
│ │ │ │ -
428 normal[0] = - jacobianTransposed[0][1];
│ │ │ │ -
429 normal[1] = jacobianTransposed[0][0];
│ │ │ │ -
430 } else if (mydim==2) {
│ │ │ │ -
431 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
│ │ │ │ -
432 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
│ │ │ │ -
433 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
│ │ │ │ -
434 } else
│ │ │ │ -
435 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the 'outerNormal' method for " << mydim << "-dimensional intersections yet");
│ │ │ │ -
436 } else
│ │ │ │ -
437 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
│ │ │ │ -
438
│ │ │ │ -
439 return normal;
│ │ │ │ -
440 }
│ │ │ │ -
│ │ │ │ -
441
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
447 {
│ │ │ │ -
448 GlobalCoordinate normal = outerNormal(local);
│ │ │ │ -
449 normal /= normal.two_norm();
│ │ │ │ -
450 return normal;
│ │ │ │ -
451 }
│ │ │ │ -
│ │ │ │ -
452
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
458 {
│ │ │ │ -
459 return (unitOuterNormal(local) *= geometry().integrationElement(local));
│ │ │ │ -
460 }
│ │ │ │ -
│ │ │ │ -
461
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
467 {
│ │ │ │ -
468 return unitOuterNormal(ReferenceElements<ctype,mydim>::general(type()).position(0,0));
│ │ │ │ -
469 }
│ │ │ │ -
│ │ │ │ -
470
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
475 {
│ │ │ │ -
476 return Intersection<P0,P1,O,I>(glue_,i_);
│ │ │ │ -
477 }
│ │ │ │ -
│ │ │ │ -
478
│ │ │ │ -
479#ifdef QUICKHACK_INDEX
│ │ │ │ -
480 typedef typename GridGlue::IndexType IndexType;
│ │ │ │ -
481
│ │ │ │ -
482 IndexType index() const
│ │ │ │ -
483 {
│ │ │ │ -
484 return i_->index_;
│ │ │ │ -
485 }
│ │ │ │ -
486
│ │ │ │ -
487#endif
│ │ │ │ -
488
│ │ │ │ -
489 private:
│ │ │ │ -
490
│ │ │ │ -
491 friend class IntersectionIndexSet<P0,P1>;
│ │ │ │ -
492
│ │ │ │ -
493 /* M E M B E R V A R I A B L E S */
│ │ │ │ -
494
│ │ │ │ -
496 const GridGlue* glue_;
│ │ │ │ -
497
│ │ │ │ -
499 const IntersectionData* i_;
│ │ │ │ -
500 };
│ │ │ │ +
147};
│ │ │ │
│ │ │ │ -
501
│ │ │ │ -
502
│ │ │ │ -
503 } // end namespace GridGlue
│ │ │ │ -
504} // end namespace Dune
│ │ │ │ -
505
│ │ │ │ -
506#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
│ │ │ │ -
Central component of the module implementing the coupling of two grids.
│ │ │ │ +
148
│ │ │ │ +
149} // namespace GridGlue
│ │ │ │ +
150} // namespace Dune
│ │ │ │ +
151
│ │ │ │ +
152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH
│ │ │ │
Definition gridglue.hh:37
│ │ │ │ -
sequential adapter to couple two grids at specified close together boundaries
Definition gridglue.hh:67
│ │ │ │ -
unsigned int IndexType
Definition gridglue.hh:147
│ │ │ │ -
PromotionTraits< typenameGridView< 0 >::ctype, typenameGridView< 1 >::ctype >::PromotedType ctype
The type used for coordinates.
Definition gridglue.hh:171
│ │ │ │ -
static constexpr int dimworld
export the world dimension This is the maximum of the extractors' world dimensions.
Definition gridglue.hh:166
│ │ │ │ -
storage class for Dune::GridGlue::Intersection related data
Definition intersection.hh:38
│ │ │ │ -
GridGlue::IndexType IndexType
Definition intersection.hh:42
│ │ │ │ -
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimensionworld > GridGeometry
Definition intersection.hh:65
│ │ │ │ -
const GridLocalGeometry< side > & localGeometry(unsigned int parentId=0) const
Definition intersection.hh:85
│ │ │ │ -
static constexpr int coorddim
Dimension of the world space of the intersection.
Definition intersection.hh:45
│ │ │ │ -
GridGeometry< 0 > Grid0Geometry
Definition intersection.hh:67
│ │ │ │ -
typename GridGlue::template GridView< side >::IndexSet::IndexType GridIndexType
Definition intersection.hh:71
│ │ │ │ -
IndexType index(unsigned int parentId=0) const
Definition intersection.hh:97
│ │ │ │ -
IndexType parents() const
Definition intersection.hh:101
│ │ │ │ -
GridLocalGeometry< 1 > Grid1LocalGeometry
Definition intersection.hh:61
│ │ │ │ -
const GridGeometry< side > & geometry() const
Definition intersection.hh:89
│ │ │ │ -
bool local() const
Definition intersection.hh:93
│ │ │ │ -
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition intersection.hh:40
│ │ │ │ -
static constexpr int mydim
Dimension of the intersection.
Definition intersection.hh:54
│ │ │ │ -
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimension > GridLocalGeometry
Definition intersection.hh:58
│ │ │ │ -
GridLocalGeometry< 0 > Grid0LocalGeometry
Definition intersection.hh:60
│ │ │ │ -
IndexType index_
index of this intersection after GridGlue interface
Definition intersection.hh:112
│ │ │ │ -
GridIndexType< 1 > Grid1IndexType
Definition intersection.hh:74
│ │ │ │ -
GridGeometry< 1 > Grid1Geometry
Definition intersection.hh:68
│ │ │ │ -
GridIndexType< 0 > Grid0IndexType
Definition intersection.hh:73
│ │ │ │ -
IntersectionData()=default
Default Constructor.
│ │ │ │ -
The intersection of two entities of the two patches of a GridGlue.
Definition intersection.hh:257
│ │ │ │ -
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition intersection.hh:271
│ │ │ │ -
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition intersection.hh:474
│ │ │ │ -
bool conforming() const
Return true if intersection is conforming.
Definition intersection.hh:331
│ │ │ │ -
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition intersection.hh:277
│ │ │ │ -
Traits::GridGlue GridGlue
Definition intersection.hh:263
│ │ │ │ -
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in.
Definition intersection.hh:408
│ │ │ │ -
int indexInInside(unsigned int parentId=0) const
Local number of codim 1 entity in the inside() Entity where intersection is contained in.
Definition intersection.hh:401
│ │ │ │ -
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition intersection.hh:384
│ │ │ │ -
static constexpr auto mydim
dimension of the intersection
Definition intersection.hh:287
│ │ │ │ -
static constexpr int outsidePatch
outside patch
Definition intersection.hh:293
│ │ │ │ -
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition intersection.hh:373
│ │ │ │ -
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition intersection.hh:315
│ │ │ │ -
Traits::LocalCoordinate LocalCoordinate
Definition intersection.hh:280
│ │ │ │ -
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() element.
Definition intersection.hh:345
│ │ │ │ -
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return a unit outer normal.
Definition intersection.hh:446
│ │ │ │ -
Traits::ctype ctype
Definition intersection.hh:275
│ │ │ │ -
IntersectionTraits< P0, P1, I, O > Traits
Definition intersection.hh:261
│ │ │ │ -
Traits::IntersectionData IntersectionData
Definition intersection.hh:264
│ │ │ │ -
Traits::GlobalCoordinate GlobalCoordinate
Definition intersection.hh:281
│ │ │ │ -
Traits::OutsideGeometry OutsideGeometry
Definition intersection.hh:272
│ │ │ │ -
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition intersection.hh:390
│ │ │ │ -
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition intersection.hh:307
│ │ │ │ -
static constexpr int insidePatch
inside patch
Definition intersection.hh:290
│ │ │ │ -
Traits::Geometry Geometry
Definition intersection.hh:274
│ │ │ │ -
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition intersection.hh:278
│ │ │ │ -
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition intersection.hh:324
│ │ │ │ -
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition intersection.hh:356
│ │ │ │ -
Traits::InsideLocalGeometry InsideLocalGeometry
Definition intersection.hh:268
│ │ │ │ -
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition intersection.hh:418
│ │ │ │ -
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition intersection.hh:367
│ │ │ │ -
Traits::OutsideGridView OutsideGridView
Definition intersection.hh:270
│ │ │ │ -
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Return an outer normal with the length of the integration element.
Definition intersection.hh:457
│ │ │ │ -
Traits::InsideGridView InsideGridView
Definition intersection.hh:267
│ │ │ │ -
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() element.
Definition intersection.hh:338
│ │ │ │ -
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition intersection.hh:466
│ │ │ │ -
static constexpr auto coorddim
dimension of the world space of the intersection
Definition intersection.hh:284
│ │ │ │ -
Definition intersection.hh:230
│ │ │ │ -
static constexpr int insidePatch
Definition intersection.hh:245
│ │ │ │ -
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition intersection.hh:249
│ │ │ │ -
static constexpr auto coorddim
Definition intersection.hh:243
│ │ │ │ -
typename IntersectionData::template GridGeometry< outside > OutsideGeometry
Definition intersection.hh:241
│ │ │ │ -
typename GridGlue::ctype ctype
Definition intersection.hh:248
│ │ │ │ -
typename GridGlue::template GridView< outside > OutsideGridView
Definition intersection.hh:235
│ │ │ │ -
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition intersection.hh:250
│ │ │ │ -
typename IntersectionData::template GridLocalGeometry< outside > OutsideLocalGeometry
Definition intersection.hh:238
│ │ │ │ -
typename GridGlue::template GridView< inside > InsideGridView
Definition intersection.hh:234
│ │ │ │ -
typename IntersectionData::template GridGeometry< inside > Geometry
Definition intersection.hh:240
│ │ │ │ -
typename IntersectionData::template GridLocalGeometry< inside > InsideLocalGeometry
Definition intersection.hh:237
│ │ │ │ -
static constexpr int outsidePatch
Definition intersection.hh:246
│ │ │ │ -
static constexpr auto mydim
Definition intersection.hh:244
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,743 +1,165 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -intersection.hh │ │ │ │ │ +gridglueamirawriter.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-with- │ │ │ │ │ +2// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with- │ │ │ │ │ dune-grid-glue-exception │ │ │ │ │ -11#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ -12#define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ -13 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ +8#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ +9#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_HH │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune { │ │ │ │ │ +16namespace GridGlue { │ │ │ │ │ 17 │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23 │ │ │ │ │ -24#define ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ -25 │ │ │ │ │ -26namespace Dune { │ │ │ │ │ -27 namespace GridGlue { │ │ │ │ │ -28 │ │ │ │ │ -29 // forward declaration │ │ │ │ │ -30 template │ │ │ │ │ -31 class IntersectionIndexSet; │ │ │ │ │ +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 │ │ │ │ │ -36 template │ │ │ │ │ -37 class IntersectionData │ │ │ │ │ -38 { │ │ │ │ │ -39 public: │ │ │ │ │ -40 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ -41 │ │ │ │ │ -42 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ +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 │ │ │ │ │ -45 static constexpr int coorddim = GridGlue::dimworld; │ │ │ │ │ -46 │ │ │ │ │ -47 private: │ │ │ │ │ -48 // intermediate quantities │ │ │ │ │ -49 template │ │ │ │ │ -50 static constexpr int dim() { return GridGlue::template GridView:: │ │ │ │ │ -Grid::dimension - GridGlue::template GridPatch::codim; } │ │ │ │ │ -51 │ │ │ │ │ -52 public: │ │ │ │ │ -54 static constexpr int mydim = dim<0>() < dim<1>() ? dim<0>() : dim<1>(); │ │ │ │ │ -55 │ │ │ │ │ -56 template │ │ │ │ │ -57 using GridLocalGeometry = AffineGeometry< │ │ │ │ │ -58 typename GridGlue::template GridView::ctype, mydim, GridGlue::template │ │ │ │ │ -GridView::dimension>; │ │ │ │ │ -59 │ │ │ │ │ -60 using Grid0LocalGeometry [[deprecated("please use GridLocalGeometry<0> │ │ │ │ │ -instead")]] = GridLocalGeometry<0>; │ │ │ │ │ -61 using Grid1LocalGeometry [[deprecated("please use GridLocalGeometry<1> │ │ │ │ │ -instead")]] = GridLocalGeometry<1>; │ │ │ │ │ -62 │ │ │ │ │ -63 template │ │ │ │ │ -64 using GridGeometry = AffineGeometry< │ │ │ │ │ -65 typename GridGlue::template GridView::ctype, mydim, GridGlue::template │ │ │ │ │ -GridView::dimensionworld>; │ │ │ │ │ -66 │ │ │ │ │ -67 using Grid0Geometry [[deprecated("please use GridGeometry<0> instead")]] = │ │ │ │ │ -GridGeometry<0>; │ │ │ │ │ -68 using Grid1Geometry [[deprecated("please use GridGeometry<1> instead")]] = │ │ │ │ │ -GridGeometry<1>; │ │ │ │ │ -69 │ │ │ │ │ -70 template │ │ │ │ │ -71 using GridIndexType = typename GridGlue::template GridView::IndexSet:: │ │ │ │ │ -IndexType; │ │ │ │ │ -72 │ │ │ │ │ -73 using Grid0IndexType [[deprecated("please use GridIndexType<0> instead")]] = │ │ │ │ │ -GridIndexType<0>; │ │ │ │ │ -74 using Grid1IndexType [[deprecated("please use GridIndexType<1> instead")]] = │ │ │ │ │ -GridIndexType<1>; │ │ │ │ │ +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 │ │ │ │ │ -77 IntersectionData(const GridGlue& glue, unsigned int mergeindex, unsigned int │ │ │ │ │ -offset, bool grid0local, bool grid1local); │ │ │ │ │ -78 │ │ │ │ │ -80 IntersectionData() = default; │ │ │ │ │ -81 │ │ │ │ │ -82 /* Accessor Functions */ │ │ │ │ │ -83 │ │ │ │ │ -84 template │ │ │ │ │ -85 const GridLocalGeometry& localGeometry(unsigned int parentId = 0) │ │ │ │ │ -const │ │ │ │ │ -86 { return *std::get(sideData_).gridlocalgeom[parentId]; } │ │ │ │ │ -87 │ │ │ │ │ -88 template │ │ │ │ │ -89 const GridGeometry& geometry() const │ │ │ │ │ -90 { return *std::get(sideData_).gridgeom; } │ │ │ │ │ -91 │ │ │ │ │ -92 template │ │ │ │ │ -93 bool local() const │ │ │ │ │ -94 { return std::get(sideData_).gridlocal; } │ │ │ │ │ -95 │ │ │ │ │ -96 template │ │ │ │ │ -97 IndexType index(unsigned int parentId = 0) const │ │ │ │ │ -98 { return std::get(sideData_).gridindices[parentId]; } │ │ │ │ │ -99 │ │ │ │ │ -100 template │ │ │ │ │ -101 IndexType parents() const │ │ │ │ │ -102 { return std::get(sideData_).gridindices.size(); } │ │ │ │ │ -103 │ │ │ │ │ -104 private: │ │ │ │ │ -105 template │ │ │ │ │ -106 void initializeGeometry(const GridGlue& glue, unsigned mergeindex); │ │ │ │ │ -107 │ │ │ │ │ -108 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ -109 │ │ │ │ │ -110 public: │ │ │ │ │ -112 IndexType index_; │ │ │ │ │ -113 │ │ │ │ │ -114 private: │ │ │ │ │ -115 template │ │ │ │ │ -116 struct SideData { │ │ │ │ │ -118 bool gridlocal = false; │ │ │ │ │ -119 │ │ │ │ │ -121 std::vector< GridIndexType > gridindices; │ │ │ │ │ -122 │ │ │ │ │ -124 std::vector< std::optional< GridLocalGeometry > > gridlocalgeom; │ │ │ │ │ +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 │ │ │ │ │ -133 std::optional< GridGeometry > gridgeom; │ │ │ │ │ -134 }; │ │ │ │ │ -135 │ │ │ │ │ -136 std::tuple< SideData<0>, SideData<1> > sideData_; │ │ │ │ │ -137 }; │ │ │ │ │ -138 │ │ │ │ │ -139 template │ │ │ │ │ -140 template │ │ │ │ │ -141 void IntersectionData::initializeGeometry(const GridGlue& glue, │ │ │ │ │ -unsigned mergeindex) │ │ │ │ │ -142 { │ │ │ │ │ -143 auto& data = std::get(sideData_); │ │ │ │ │ -144 │ │ │ │ │ -145 const unsigned n_parents = glue.merger_->template parents │ │ │ │ │ -(mergeindex); │ │ │ │ │ +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 // init containers │ │ │ │ │ -148 data.gridindices.resize(n_parents); │ │ │ │ │ -149 data.gridlocalgeom.resize(n_parents); │ │ │ │ │ -150 │ │ │ │ │ -151 // default values │ │ │ │ │ -152 data.gridindices[0] = 0; │ │ │ │ │ -153 │ │ │ │ │ -154 static constexpr int nSimplexCorners = mydim + 1; │ │ │ │ │ -155 using ctype = typename GridGlue::ctype; │ │ │ │ │ -156 │ │ │ │ │ -157 // initialize the local and the global geometries of grid `side` │ │ │ │ │ -158 │ │ │ │ │ -159 // compute the coordinates of the subface's corners in codim 0 entity local │ │ │ │ │ -coordinates │ │ │ │ │ -160 static constexpr int elementdim = GridGlue::template GridView:: │ │ │ │ │ -template Codim<0>::Geometry::mydimension; │ │ │ │ │ -161 │ │ │ │ │ -162 // coordinates within the subentity that contains the remote intersection │ │ │ │ │ -163 std::array() >, nSimplexCorners> │ │ │ │ │ -corners_subEntity_local; │ │ │ │ │ -164 │ │ │ │ │ -165 for (unsigned int par = 0; par < n_parents; ++par) { │ │ │ │ │ -166 for (int i = 0; i < nSimplexCorners; ++i) │ │ │ │ │ -167 corners_subEntity_local[i] = glue.merger_->template parentLocal │ │ │ │ │ -(mergeindex, i, par); │ │ │ │ │ -168 │ │ │ │ │ -169 // Coordinates of the remote intersection corners wrt the element │ │ │ │ │ -coordinate system │ │ │ │ │ -170 std::array, nSimplexCorners> corners_ │ │ │ │ │ -element_local; │ │ │ │ │ -171 │ │ │ │ │ -172 if (data.gridlocal) { │ │ │ │ │ -173 data.gridindices[par] = glue.merger_->template parent │ │ │ │ │ -(mergeindex,par); │ │ │ │ │ -174 │ │ │ │ │ -175 typename GridGlue::template GridPatch::LocalGeometry │ │ │ │ │ -176 gridLocalGeometry = glue.template patch().geometryLocal │ │ │ │ │ -(data.gridindices[par]); │ │ │ │ │ -177 for (std::size_t i=0; i::Geometry │ │ │ │ │ -192 gridWorldGeometry = glue.template patch().geometry(data.gridindices │ │ │ │ │ -[par]); │ │ │ │ │ -193 │ │ │ │ │ -194 // world coordinates of the remote intersection corners │ │ │ │ │ -195 std::array:: │ │ │ │ │ -dimensionworld>, nSimplexCorners> corners_global; │ │ │ │ │ -196 │ │ │ │ │ -197 for (std::size_t i=0; i │ │ │ │ │ -209 IntersectionData::IntersectionData(const GridGlue& glue, unsigned │ │ │ │ │ -int mergeindex, unsigned int offset, │ │ │ │ │ -210 bool grid0local, bool grid1local) │ │ │ │ │ -211 : index_(mergeindex+offset) │ │ │ │ │ -212 { │ │ │ │ │ -213 // if an invalid index is given do not proceed! │ │ │ │ │ -214 // (happens when the parent GridGlue initializes the "end"-Intersection) │ │ │ │ │ -215 assert (0 <= mergeindex || mergeindex < glue.index__sz); │ │ │ │ │ -216 │ │ │ │ │ -217 std::get<0>(sideData_).gridlocal = grid0local; │ │ │ │ │ -218 std::get<1>(sideData_).gridlocal = grid1local; │ │ │ │ │ -219 │ │ │ │ │ -220 initializeGeometry<0>(glue, mergeindex); │ │ │ │ │ -221 initializeGeometry<1>(glue, mergeindex); │ │ │ │ │ -222 } │ │ │ │ │ -223 │ │ │ │ │ -228 template │ │ │ │ │ -229 struct IntersectionTraits │ │ │ │ │ -230 { │ │ │ │ │ -231 using GridGlue = ::Dune::GridGlue::GridGlue; │ │ │ │ │ -232 using IntersectionData = Dune::GridGlue::IntersectionData; │ │ │ │ │ -233 │ │ │ │ │ -234 using InsideGridView = typename GridGlue::template GridView; │ │ │ │ │ -235 using OutsideGridView = typename GridGlue::template GridView; │ │ │ │ │ -236 │ │ │ │ │ -237 using InsideLocalGeometry = typename IntersectionData::template │ │ │ │ │ -GridLocalGeometry; │ │ │ │ │ -238 using OutsideLocalGeometry = typename IntersectionData::template │ │ │ │ │ -GridLocalGeometry; │ │ │ │ │ -239 │ │ │ │ │ -240 using Geometry = typename IntersectionData::template GridGeometry; │ │ │ │ │ -241 using OutsideGeometry = typename IntersectionData::template │ │ │ │ │ -GridGeometry; │ │ │ │ │ -242 │ │ │ │ │ -243 static constexpr auto coorddim = IntersectionData::coorddim; │ │ │ │ │ -244 static constexpr auto mydim = IntersectionData::mydim; │ │ │ │ │ -245 static constexpr int insidePatch = inside; │ │ │ │ │ -246 static constexpr int outsidePatch = outside; │ │ │ │ │ -247 │ │ │ │ │ -248 using ctype = typename GridGlue::ctype; │ │ │ │ │ -249 using LocalCoordinate = Dune::FieldVector; │ │ │ │ │ -250 using GlobalCoordinate = Dune::FieldVector; │ │ │ │ │ -251 }; │ │ │ │ │ -252 │ │ │ │ │ -255 template │ │ │ │ │ -256 class Intersection │ │ │ │ │ -257 { │ │ │ │ │ -258 │ │ │ │ │ -259 public: │ │ │ │ │ -260 │ │ │ │ │ -261 typedef IntersectionTraits Traits; │ │ │ │ │ -262 │ │ │ │ │ -263 typedef typename Traits::GridGlue GridGlue; │ │ │ │ │ -264 typedef typename Traits::IntersectionData IntersectionData; │ │ │ │ │ -265 │ │ │ │ │ -266 │ │ │ │ │ -267 typedef typename Traits::InsideGridView InsideGridView; │ │ │ │ │ -268 typedef typename Traits::InsideLocalGeometry InsideLocalGeometry; │ │ │ │ │ -269 │ │ │ │ │ -270 typedef typename Traits::OutsideGridView OutsideGridView; │ │ │ │ │ -271 typedef typename Traits::OutsideLocalGeometry OutsideLocalGeometry; │ │ │ │ │ -272 typedef typename Traits::OutsideGeometry OutsideGeometry; │ │ │ │ │ -273 │ │ │ │ │ -274 typedef typename Traits::Geometry Geometry; │ │ │ │ │ -275 typedef typename Traits::ctype ctype; │ │ │ │ │ -276 │ │ │ │ │ -277 typedef typename InsideGridView::Traits::template Codim<0>::Entity │ │ │ │ │ -InsideEntity; │ │ │ │ │ -278 typedef typename OutsideGridView::Traits::template Codim<0>::Entity │ │ │ │ │ -OutsideEntity; │ │ │ │ │ -279 │ │ │ │ │ -280 typedef typename Traits::LocalCoordinate LocalCoordinate; │ │ │ │ │ -281 typedef typename Traits::GlobalCoordinate GlobalCoordinate; │ │ │ │ │ -282 │ │ │ │ │ -284 static constexpr auto coorddim = Traits::coorddim; │ │ │ │ │ -285 │ │ │ │ │ -287 static constexpr auto mydim = Traits::mydim; │ │ │ │ │ -288 │ │ │ │ │ -290 static constexpr int insidePatch = Traits::insidePatch; │ │ │ │ │ -291 │ │ │ │ │ -293 static constexpr int outsidePatch = Traits::outsidePatch; │ │ │ │ │ -294 │ │ │ │ │ -295 // typedef unsigned int IndexType; │ │ │ │ │ -296 │ │ │ │ │ -297 private: │ │ │ │ │ -301 static constexpr int codimensionWorld = coorddim - mydim; │ │ │ │ │ -302 │ │ │ │ │ -303 public: │ │ │ │ │ -304 /* C O N S T R U C T O R S */ │ │ │ │ │ -305 │ │ │ │ │ -307 Intersection(const GridGlue* glue, const IntersectionData* i) : │ │ │ │ │ -308 glue_(glue), i_(i) {} │ │ │ │ │ -309 │ │ │ │ │ -310 /* F U N C T I O N A L I T Y */ │ │ │ │ │ -311 │ │ │ │ │ -314 InsideEntity │ │ │ │ │ -315 inside(unsigned int parentId = 0) const │ │ │ │ │ -316 { │ │ │ │ │ -317 assert(self()); │ │ │ │ │ -318 return glue_->template patch().element(i_->template index(parentId)); │ │ │ │ │ -319 } │ │ │ │ │ -320 │ │ │ │ │ -323 OutsideEntity │ │ │ │ │ -324 outside(unsigned int parentId = 0) const │ │ │ │ │ -325 { │ │ │ │ │ -326 assert(neighbor()); │ │ │ │ │ -327 return glue_->template patch().element(i_->template index(parentId)); │ │ │ │ │ -328 } │ │ │ │ │ -329 │ │ │ │ │ -331 bool conforming() const │ │ │ │ │ -332 { │ │ │ │ │ -333 throw Dune::NotImplemented(); │ │ │ │ │ -334 } │ │ │ │ │ -335 │ │ │ │ │ -338 const InsideLocalGeometry& geometryInInside(unsigned int parentId = 0) │ │ │ │ │ -const │ │ │ │ │ -339 { │ │ │ │ │ -340 return i_->template localGeometry(parentId); │ │ │ │ │ -341 } │ │ │ │ │ -342 │ │ │ │ │ -345 const OutsideLocalGeometry& geometryInOutside(unsigned int parentId = 0) │ │ │ │ │ -const │ │ │ │ │ -346 { │ │ │ │ │ -347 return i_->template localGeometry(parentId); │ │ │ │ │ -348 } │ │ │ │ │ -349 │ │ │ │ │ -356 const Geometry& geometry() const │ │ │ │ │ -357 { │ │ │ │ │ -358 return i_->template geometry(); │ │ │ │ │ -359 } │ │ │ │ │ -360 │ │ │ │ │ -367 const OutsideGeometry& geometryOutside() const // DUNE_DEPRECATED │ │ │ │ │ -368 { │ │ │ │ │ -369 return i_->template geometry(); │ │ │ │ │ -370 } │ │ │ │ │ -371 │ │ │ │ │ -373 Dune::GeometryType type() const │ │ │ │ │ -374 { │ │ │ │ │ -375 #ifdef ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ -376 return Dune::GeometryTypes::simplex(mydim); │ │ │ │ │ -377 #else │ │ │ │ │ -378 #error Not Implemented │ │ │ │ │ -379 #endif │ │ │ │ │ -380 } │ │ │ │ │ -381 │ │ │ │ │ -382 │ │ │ │ │ -384 bool self() const │ │ │ │ │ -385 { │ │ │ │ │ -386 return i_->template local(); │ │ │ │ │ -387 } │ │ │ │ │ -388 │ │ │ │ │ -390 size_t neighbor(unsigned int g = 0) const │ │ │ │ │ -391 { │ │ │ │ │ -392 if (g == 0 && i_->template local()) { │ │ │ │ │ -393 return i_->template parents(); │ │ │ │ │ -394 } else if (g == 1 && i_->template local()) { │ │ │ │ │ -395 return i_->template parents(); │ │ │ │ │ -396 } │ │ │ │ │ -397 return 0; │ │ │ │ │ -398 } │ │ │ │ │ -399 │ │ │ │ │ -401 int indexInInside(unsigned int parentId = 0) const │ │ │ │ │ -402 { │ │ │ │ │ -403 assert(self()); │ │ │ │ │ -404 return glue_->template patch().indexInInside(i_->template index │ │ │ │ │ -(parentId)); │ │ │ │ │ -405 } │ │ │ │ │ -406 │ │ │ │ │ -408 int indexInOutside(unsigned int parentId = 0) const │ │ │ │ │ -409 { │ │ │ │ │ -410 assert(neighbor()); │ │ │ │ │ -411 return glue_->template patch().indexInInside(i_->template index │ │ │ │ │ -(parentId)); │ │ │ │ │ -412 } │ │ │ │ │ -413 │ │ │ │ │ -418 GlobalCoordinate outerNormal(const LocalCoordinate &local) const │ │ │ │ │ -419 { │ │ │ │ │ -420 GlobalCoordinate normal; │ │ │ │ │ -421 │ │ │ │ │ -422 if (codimensionWorld == 0) │ │ │ │ │ -423 DUNE_THROW(Dune::Exception, "There is no normal vector to a full- │ │ │ │ │ -dimensional intersection"); │ │ │ │ │ -424 else if (codimensionWorld == 1) { │ │ │ │ │ -425 /* TODO: Implement the general n-ary cross product here */ │ │ │ │ │ -426 const auto jacobianTransposed = geometry().jacobianTransposed(local); │ │ │ │ │ -427 if (mydim==1) { │ │ │ │ │ -428 normal[0] = - jacobianTransposed[0][1]; │ │ │ │ │ -429 normal[1] = jacobianTransposed[0][0]; │ │ │ │ │ -430 } else if (mydim==2) { │ │ │ │ │ -431 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - │ │ │ │ │ -jacobianTransposed[0][2] * jacobianTransposed[1][1]); │ │ │ │ │ -432 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - │ │ │ │ │ -jacobianTransposed[0][2] * jacobianTransposed[1][0]); │ │ │ │ │ -433 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - │ │ │ │ │ -jacobianTransposed[0][1] * jacobianTransposed[1][0]); │ │ │ │ │ -434 } else │ │ │ │ │ -435 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the │ │ │ │ │ -'outerNormal' method for " << mydim << "-dimensional intersections yet"); │ │ │ │ │ -436 } else │ │ │ │ │ -437 DUNE_THROW(Dune::NotImplemented, "Remote intersections don't implement the │ │ │ │ │ -'outerNormal' method for intersections with codim >= 2 yet"); │ │ │ │ │ -438 │ │ │ │ │ -439 return normal; │ │ │ │ │ -440 } │ │ │ │ │ -441 │ │ │ │ │ -446 GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ -447 { │ │ │ │ │ -448 GlobalCoordinate normal = outerNormal(local); │ │ │ │ │ -449 normal /= normal.two_norm(); │ │ │ │ │ -450 return normal; │ │ │ │ │ -451 } │ │ │ │ │ -452 │ │ │ │ │ -457 GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ -458 { │ │ │ │ │ -459 return (unitOuterNormal(local) *= geometry().integrationElement(local)); │ │ │ │ │ -460 } │ │ │ │ │ -461 │ │ │ │ │ -466 GlobalCoordinate centerUnitOuterNormal () const │ │ │ │ │ -467 { │ │ │ │ │ -468 return unitOuterNormal(ReferenceElements::general(type │ │ │ │ │ -()).position(0,0)); │ │ │ │ │ -469 } │ │ │ │ │ -470 │ │ │ │ │ -474 Intersection flip() const │ │ │ │ │ -475 { │ │ │ │ │ -476 return Intersection(glue_,i_); │ │ │ │ │ -477 } │ │ │ │ │ -478 │ │ │ │ │ -479#ifdef QUICKHACK_INDEX │ │ │ │ │ -480 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ -481 │ │ │ │ │ -482 IndexType index() const │ │ │ │ │ -483 { │ │ │ │ │ -484 return i_->index_; │ │ │ │ │ -485 } │ │ │ │ │ -486 │ │ │ │ │ -487#endif │ │ │ │ │ -488 │ │ │ │ │ -489 private: │ │ │ │ │ -490 │ │ │ │ │ -491 friend class IntersectionIndexSet; │ │ │ │ │ -492 │ │ │ │ │ -493 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ -494 │ │ │ │ │ -496 const GridGlue* glue_; │ │ │ │ │ -497 │ │ │ │ │ -499 const IntersectionData* i_; │ │ │ │ │ -500 }; │ │ │ │ │ -501 │ │ │ │ │ -502 │ │ │ │ │ -503 } // end namespace GridGlue │ │ │ │ │ -504} // end namespace Dune │ │ │ │ │ -505 │ │ │ │ │ -506#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH │ │ │ │ │ -gridglue.hh │ │ │ │ │ -Central component of the module implementing the coupling of two grids. │ │ │ │ │ +147}; │ │ │ │ │ +148 │ │ │ │ │ +149} // namespace GridGlue │ │ │ │ │ +150} // namespace Dune │ │ │ │ │ +151 │ │ │ │ │ +152#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEAMIRAWRITER_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::IndexType │ │ │ │ │ -unsigned int IndexType │ │ │ │ │ -Definition gridglue.hh:147 │ │ │ │ │ -Dune::GridGlue::GridGlue::ctype │ │ │ │ │ -PromotionTraits< typenameGridView< 0 >::ctype, typenameGridView< 1 >::ctype >:: │ │ │ │ │ -PromotedType ctype │ │ │ │ │ -The type used for coordinates. │ │ │ │ │ -Definition gridglue.hh:171 │ │ │ │ │ -Dune::GridGlue::GridGlue::dimworld │ │ │ │ │ -static constexpr int dimworld │ │ │ │ │ -export the world dimension This is the maximum of the extractors' world │ │ │ │ │ -dimensions. │ │ │ │ │ -Definition gridglue.hh:166 │ │ │ │ │ -Dune::GridGlue::IntersectionData │ │ │ │ │ -storage class for Dune::GridGlue::Intersection related data │ │ │ │ │ -Definition intersection.hh:38 │ │ │ │ │ -Dune::GridGlue::IntersectionData::IndexType │ │ │ │ │ -GridGlue::IndexType IndexType │ │ │ │ │ -Definition intersection.hh:42 │ │ │ │ │ -Dune::GridGlue::IntersectionData::GridGeometry │ │ │ │ │ -AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, │ │ │ │ │ -GridGlue::template GridView< side >::dimensionworld > GridGeometry │ │ │ │ │ -Definition intersection.hh:65 │ │ │ │ │ -Dune::GridGlue::IntersectionData::localGeometry │ │ │ │ │ -const GridLocalGeometry< side > & localGeometry(unsigned int parentId=0) const │ │ │ │ │ -Definition intersection.hh:85 │ │ │ │ │ -Dune::GridGlue::IntersectionData::coorddim │ │ │ │ │ -static constexpr int coorddim │ │ │ │ │ -Dimension of the world space of the intersection. │ │ │ │ │ -Definition intersection.hh:45 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid0Geometry │ │ │ │ │ -GridGeometry< 0 > Grid0Geometry │ │ │ │ │ -Definition intersection.hh:67 │ │ │ │ │ -Dune::GridGlue::IntersectionData::GridIndexType │ │ │ │ │ -typename GridGlue::template GridView< side >::IndexSet::IndexType GridIndexType │ │ │ │ │ -Definition intersection.hh:71 │ │ │ │ │ -Dune::GridGlue::IntersectionData::index │ │ │ │ │ -IndexType index(unsigned int parentId=0) const │ │ │ │ │ -Definition intersection.hh:97 │ │ │ │ │ -Dune::GridGlue::IntersectionData::parents │ │ │ │ │ -IndexType parents() const │ │ │ │ │ -Definition intersection.hh:101 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid1LocalGeometry │ │ │ │ │ -GridLocalGeometry< 1 > Grid1LocalGeometry │ │ │ │ │ -Definition intersection.hh:61 │ │ │ │ │ -Dune::GridGlue::IntersectionData::geometry │ │ │ │ │ -const GridGeometry< side > & geometry() const │ │ │ │ │ -Definition intersection.hh:89 │ │ │ │ │ -Dune::GridGlue::IntersectionData::local │ │ │ │ │ -bool local() const │ │ │ │ │ -Definition intersection.hh:93 │ │ │ │ │ -Dune::GridGlue::IntersectionData::GridGlue │ │ │ │ │ -::Dune::GridGlue::GridGlue< P0, P1 > GridGlue │ │ │ │ │ -Definition intersection.hh:40 │ │ │ │ │ -Dune::GridGlue::IntersectionData::mydim │ │ │ │ │ -static constexpr int mydim │ │ │ │ │ -Dimension of the intersection. │ │ │ │ │ -Definition intersection.hh:54 │ │ │ │ │ -Dune::GridGlue::IntersectionData::GridLocalGeometry │ │ │ │ │ -AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, │ │ │ │ │ -GridGlue::template GridView< side >::dimension > GridLocalGeometry │ │ │ │ │ -Definition intersection.hh:58 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid0LocalGeometry │ │ │ │ │ -GridLocalGeometry< 0 > Grid0LocalGeometry │ │ │ │ │ -Definition intersection.hh:60 │ │ │ │ │ -Dune::GridGlue::IntersectionData::index_ │ │ │ │ │ -IndexType index_ │ │ │ │ │ -index of this intersection after GridGlue interface │ │ │ │ │ -Definition intersection.hh:112 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid1IndexType │ │ │ │ │ -GridIndexType< 1 > Grid1IndexType │ │ │ │ │ -Definition intersection.hh:74 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid1Geometry │ │ │ │ │ -GridGeometry< 1 > Grid1Geometry │ │ │ │ │ -Definition intersection.hh:68 │ │ │ │ │ -Dune::GridGlue::IntersectionData::Grid0IndexType │ │ │ │ │ -GridIndexType< 0 > Grid0IndexType │ │ │ │ │ -Definition intersection.hh:73 │ │ │ │ │ -Dune::GridGlue::IntersectionData::IntersectionData │ │ │ │ │ -IntersectionData()=default │ │ │ │ │ -Default Constructor. │ │ │ │ │ -Dune::GridGlue::Intersection │ │ │ │ │ -The intersection of two entities of the two patches of a GridGlue. │ │ │ │ │ -Definition intersection.hh:257 │ │ │ │ │ -Dune::GridGlue::Intersection::OutsideLocalGeometry │ │ │ │ │ -Traits::OutsideLocalGeometry OutsideLocalGeometry │ │ │ │ │ -Definition intersection.hh:271 │ │ │ │ │ -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:474 │ │ │ │ │ -Dune::GridGlue::Intersection::conforming │ │ │ │ │ -bool conforming() const │ │ │ │ │ -Return true if intersection is conforming. │ │ │ │ │ -Definition intersection.hh:331 │ │ │ │ │ -Dune::GridGlue::Intersection::InsideEntity │ │ │ │ │ -InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity │ │ │ │ │ -Definition intersection.hh:277 │ │ │ │ │ -Dune::GridGlue::Intersection::GridGlue │ │ │ │ │ -Traits::GridGlue GridGlue │ │ │ │ │ -Definition intersection.hh:263 │ │ │ │ │ -Dune::GridGlue::Intersection::indexInOutside │ │ │ │ │ -int indexInOutside(unsigned int parentId=0) const │ │ │ │ │ -Local number of codim 1 entity in outside() Entity where intersection is │ │ │ │ │ -contained in. │ │ │ │ │ -Definition intersection.hh:408 │ │ │ │ │ -Dune::GridGlue::Intersection::indexInInside │ │ │ │ │ -int indexInInside(unsigned int parentId=0) const │ │ │ │ │ -Local number of codim 1 entity in the inside() Entity where intersection is │ │ │ │ │ -contained in. │ │ │ │ │ -Definition intersection.hh:401 │ │ │ │ │ -Dune::GridGlue::Intersection::self │ │ │ │ │ -bool self() const │ │ │ │ │ -For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ -Definition intersection.hh:384 │ │ │ │ │ -Dune::GridGlue::Intersection::mydim │ │ │ │ │ -static constexpr auto mydim │ │ │ │ │ -dimension of the intersection │ │ │ │ │ -Definition intersection.hh:287 │ │ │ │ │ -Dune::GridGlue::Intersection::outsidePatch │ │ │ │ │ -static constexpr int outsidePatch │ │ │ │ │ -outside patch │ │ │ │ │ -Definition intersection.hh:293 │ │ │ │ │ -Dune::GridGlue::Intersection::type │ │ │ │ │ -Dune::GeometryType type() const │ │ │ │ │ -Type of reference element for this intersection. │ │ │ │ │ -Definition intersection.hh:373 │ │ │ │ │ -Dune::GridGlue::Intersection::inside │ │ │ │ │ -InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the inside of this intersection. │ │ │ │ │ -Definition intersection.hh:315 │ │ │ │ │ -Dune::GridGlue::Intersection::LocalCoordinate │ │ │ │ │ -Traits::LocalCoordinate LocalCoordinate │ │ │ │ │ -Definition intersection.hh:280 │ │ │ │ │ -Dune::GridGlue::Intersection::geometryInOutside │ │ │ │ │ -const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const │ │ │ │ │ -Geometric information about this intersection in local coordinates of the │ │ │ │ │ -outside() element. │ │ │ │ │ -Definition intersection.hh:345 │ │ │ │ │ -Dune::GridGlue::Intersection::unitOuterNormal │ │ │ │ │ -GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ -Return a unit outer normal. │ │ │ │ │ -Definition intersection.hh:446 │ │ │ │ │ -Dune::GridGlue::Intersection::ctype │ │ │ │ │ -Traits::ctype ctype │ │ │ │ │ -Definition intersection.hh:275 │ │ │ │ │ -Dune::GridGlue::Intersection::Traits │ │ │ │ │ -IntersectionTraits< P0, P1, I, O > Traits │ │ │ │ │ -Definition intersection.hh:261 │ │ │ │ │ -Dune::GridGlue::Intersection::IntersectionData │ │ │ │ │ -Traits::IntersectionData IntersectionData │ │ │ │ │ -Definition intersection.hh:264 │ │ │ │ │ -Dune::GridGlue::Intersection::GlobalCoordinate │ │ │ │ │ -Traits::GlobalCoordinate GlobalCoordinate │ │ │ │ │ -Definition intersection.hh:281 │ │ │ │ │ -Dune::GridGlue::Intersection::OutsideGeometry │ │ │ │ │ -Traits::OutsideGeometry OutsideGeometry │ │ │ │ │ -Definition intersection.hh:272 │ │ │ │ │ -Dune::GridGlue::Intersection::neighbor │ │ │ │ │ -size_t neighbor(unsigned int g=0) const │ │ │ │ │ -Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ -Definition intersection.hh:390 │ │ │ │ │ -Dune::GridGlue::Intersection::Intersection │ │ │ │ │ -Intersection(const GridGlue *glue, const IntersectionData *i) │ │ │ │ │ -Constructor for a given Dataset. │ │ │ │ │ -Definition intersection.hh:307 │ │ │ │ │ -Dune::GridGlue::Intersection::insidePatch │ │ │ │ │ -static constexpr int insidePatch │ │ │ │ │ -inside patch │ │ │ │ │ -Definition intersection.hh:290 │ │ │ │ │ -Dune::GridGlue::Intersection::Geometry │ │ │ │ │ -Traits::Geometry Geometry │ │ │ │ │ -Definition intersection.hh:274 │ │ │ │ │ -Dune::GridGlue::Intersection::OutsideEntity │ │ │ │ │ -OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity │ │ │ │ │ -Definition intersection.hh:278 │ │ │ │ │ -Dune::GridGlue::Intersection::outside │ │ │ │ │ -OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ -Return element on the outside of this intersection. │ │ │ │ │ -Definition intersection.hh:324 │ │ │ │ │ -Dune::GridGlue::Intersection::geometry │ │ │ │ │ -const Geometry & geometry() const │ │ │ │ │ -Geometric information about this intersection as part of the inside grid. │ │ │ │ │ -Definition intersection.hh:356 │ │ │ │ │ -Dune::GridGlue::Intersection::InsideLocalGeometry │ │ │ │ │ -Traits::InsideLocalGeometry InsideLocalGeometry │ │ │ │ │ -Definition intersection.hh:268 │ │ │ │ │ -Dune::GridGlue::Intersection::outerNormal │ │ │ │ │ -GlobalCoordinate outerNormal(const LocalCoordinate &local) const │ │ │ │ │ -Return an outer normal (length not necessarily 1) │ │ │ │ │ -Definition intersection.hh:418 │ │ │ │ │ -Dune::GridGlue::Intersection::geometryOutside │ │ │ │ │ -const OutsideGeometry & geometryOutside() const │ │ │ │ │ -Geometric information about this intersection as part of the outside grid. │ │ │ │ │ -Definition intersection.hh:367 │ │ │ │ │ -Dune::GridGlue::Intersection::OutsideGridView │ │ │ │ │ -Traits::OutsideGridView OutsideGridView │ │ │ │ │ -Definition intersection.hh:270 │ │ │ │ │ -Dune::GridGlue::Intersection::integrationOuterNormal │ │ │ │ │ -GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const │ │ │ │ │ -Return an outer normal with the length of the integration element. │ │ │ │ │ -Definition intersection.hh:457 │ │ │ │ │ -Dune::GridGlue::Intersection::InsideGridView │ │ │ │ │ -Traits::InsideGridView InsideGridView │ │ │ │ │ -Definition intersection.hh:267 │ │ │ │ │ -Dune::GridGlue::Intersection::geometryInInside │ │ │ │ │ -const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const │ │ │ │ │ -Geometric information about this intersection in local coordinates of the │ │ │ │ │ -inside() element. │ │ │ │ │ -Definition intersection.hh:338 │ │ │ │ │ -Dune::GridGlue::Intersection::centerUnitOuterNormal │ │ │ │ │ -GlobalCoordinate centerUnitOuterNormal() const │ │ │ │ │ -Unit outer normal at the center of the intersection. │ │ │ │ │ -Definition intersection.hh:466 │ │ │ │ │ -Dune::GridGlue::Intersection::coorddim │ │ │ │ │ -static constexpr auto coorddim │ │ │ │ │ -dimension of the world space of the intersection │ │ │ │ │ -Definition intersection.hh:284 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits │ │ │ │ │ -Definition intersection.hh:230 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::insidePatch │ │ │ │ │ -static constexpr int insidePatch │ │ │ │ │ -Definition intersection.hh:245 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::LocalCoordinate │ │ │ │ │ -Dune::FieldVector< ctype, mydim > LocalCoordinate │ │ │ │ │ -Definition intersection.hh:249 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::coorddim │ │ │ │ │ -static constexpr auto coorddim │ │ │ │ │ -Definition intersection.hh:243 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::OutsideGeometry │ │ │ │ │ -typename IntersectionData::template GridGeometry< outside > OutsideGeometry │ │ │ │ │ -Definition intersection.hh:241 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::ctype │ │ │ │ │ -typename GridGlue::ctype ctype │ │ │ │ │ -Definition intersection.hh:248 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::OutsideGridView │ │ │ │ │ -typename GridGlue::template GridView< outside > OutsideGridView │ │ │ │ │ -Definition intersection.hh:235 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::GlobalCoordinate │ │ │ │ │ -Dune::FieldVector< ctype, coorddim > GlobalCoordinate │ │ │ │ │ -Definition intersection.hh:250 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::OutsideLocalGeometry │ │ │ │ │ -typename IntersectionData::template GridLocalGeometry< outside > │ │ │ │ │ -OutsideLocalGeometry │ │ │ │ │ -Definition intersection.hh:238 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::InsideGridView │ │ │ │ │ -typename GridGlue::template GridView< inside > InsideGridView │ │ │ │ │ -Definition intersection.hh:234 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::Geometry │ │ │ │ │ -typename IntersectionData::template GridGeometry< inside > Geometry │ │ │ │ │ -Definition intersection.hh:240 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::InsideLocalGeometry │ │ │ │ │ -typename IntersectionData::template GridLocalGeometry< inside > │ │ │ │ │ -InsideLocalGeometry │ │ │ │ │ -Definition intersection.hh:237 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::outsidePatch │ │ │ │ │ -static constexpr int outsidePatch │ │ │ │ │ -Definition intersection.hh:246 │ │ │ │ │ -Dune::GridGlue::IntersectionTraits::mydim │ │ │ │ │ -static constexpr auto mydim │ │ │ │ │ -Definition intersection.hh:244 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluevtkwriter.hh File Reference │ │ │ │ +dune-grid-glue: intersectioniterator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,46 +72,39 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
gridgluevtkwriter.hh File Reference
│ │ │ │ +
intersectioniterator.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Write all remote intersections to a vtk file for debugging. │ │ │ │ +

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

│ │ │ │ -
#include <fstream>
│ │ │ │ -#include <iomanip>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/classname.hh>
│ │ │ │ -#include <dune/geometry/type.hh>
│ │ │ │ -#include <dune/geometry/referenceelements.hh>
│ │ │ │ -#include <dune/grid-glue/gridglue.hh>
│ │ │ │ +
#include <dune/grid-glue/gridglue.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::GridGlue::GridGlueVtkWriter
 Write remote intersections to a vtk file for debugging purposes. More...
class  Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │

Detailed Description

│ │ │ │ -

Write all remote intersections to a vtk file for debugging.

│ │ │ │ +

Implement iterators over GridGlue intersections.

│ │ │ │ +
Author
Christian Engwer
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,32 +2,25 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -gridgluevtkwriter.hh File Reference │ │ │ │ │ -Write all remote intersections to a vtk file for debugging. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +intersectioniterator.hh File Reference │ │ │ │ │ +Implement iterators over GridGlue intersections. More... │ │ │ │ │ #include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::GridGlue::GridGlueVtkWriter │ │ │ │ │ -  Write remote intersections to a vtk file for debugging purposes. │ │ │ │ │ - More... │ │ │ │ │ +class   Dune::GridGlue::IntersectionIterator<_P0,_P1,_inside,_outside_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Write all remote intersections to a vtk file for debugging. │ │ │ │ │ +Implement iterators over GridGlue intersections. │ │ │ │ │ + Author │ │ │ │ │ + Christian Engwer │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00020_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: gridgluevtkwriter.hh Source File │ │ │ │ +dune-grid-glue: intersectioniterator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,318 +74,95 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
gridgluevtkwriter.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/*
│ │ │ │ -
6 * Filename: GridGlueVtkWriter.hh
│ │ │ │ -
7 * Version: 1.0
│ │ │ │ -
8 * Created on: Mar 5, 2009
│ │ │ │ -
9 * Author: Gerrit Buse
│ │ │ │ -
10 * ---------------------------------
│ │ │ │ -
11 * Project: dune-grid-glue
│ │ │ │ -
12 * Description: Class thought to make graphical debugging of couplings easier.
│ │ │ │ -
13 *
│ │ │ │ -
14 */
│ │ │ │ -
20#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH
│ │ │ │ -
21#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH
│ │ │ │ -
22
│ │ │ │ -
23
│ │ │ │ -
24#include <fstream>
│ │ │ │ -
25#include <iomanip>
│ │ │ │ -
26#include <type_traits>
│ │ │ │ -
27#include <vector>
│ │ │ │ -
28
│ │ │ │ -
29#include <dune/common/classname.hh>
│ │ │ │ -
30#include <dune/geometry/type.hh>
│ │ │ │ -
31#include <dune/geometry/referenceelements.hh>
│ │ │ │ -
32
│ │ │ │ - │ │ │ │ -
34
│ │ │ │ -
35namespace Dune {
│ │ │ │ -
36namespace GridGlue {
│ │ │ │ -
37
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
41{
│ │ │ │ -
42
│ │ │ │ -
46 template <class Glue, int side>
│ │ │ │ -
47 static void writeExtractedPart(const Glue& glue, const std::string& filename)
│ │ │ │ -
48 {
│ │ │ │ -
49 static_assert((side==0 || side==1), "'side' can only be 0 or 1");
│ │ │ │ -
50
│ │ │ │ -
51 std::ofstream fgrid;
│ │ │ │ -
52
│ │ │ │ -
53 fgrid.open(filename.c_str());
│ │ │ │ -
54
│ │ │ │ -
55 using GridView = typename Glue::template GridView<side>;
│ │ │ │ -
56 using Extractor = typename Glue::template GridPatch<side>;
│ │ │ │ -
57
│ │ │ │ -
58 typedef typename GridView::ctype ctype;
│ │ │ │ -
59
│ │ │ │ -
60 const int domdimw = GridView::dimensionworld;
│ │ │ │ -
61 const int patchDim = Extractor::dim - Extractor::codim;
│ │ │ │ -
62
│ │ │ │ -
63 // coordinates have to be in R^3 in the VTK format
│ │ │ │ -
64 std::string coordinatePadding;
│ │ │ │ -
65 for (int i=domdimw; i<3; i++)
│ │ │ │ -
66 coordinatePadding += " 0";
│ │ │ │ -
67
│ │ │ │ -
68 fgrid << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" << std::endl;
│ │ │ │ -
69
│ │ │ │ -
70 // WRITE POINTS
│ │ │ │ -
71 // ----------------
│ │ │ │ -
72 std::vector<typename Extractor::Coords> coords;
│ │ │ │ -
73 glue.template patch<side>().getCoords(coords);
│ │ │ │ -
74
│ │ │ │ -
75 fgrid << ((patchDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") << std::endl;
│ │ │ │ -
76 fgrid << "POINTS " << coords.size() << " " << Dune::className<ctype>() << std::endl;
│ │ │ │ -
77
│ │ │ │ -
78 for (size_t i=0; i<coords.size(); i++)
│ │ │ │ -
79 fgrid << coords[i] << coordinatePadding << std::endl;
│ │ │ │ -
80
│ │ │ │ -
81 fgrid << std::endl;
│ │ │ │ -
82
│ │ │ │ -
83 // WRITE POLYGONS
│ │ │ │ -
84 // ----------------
│ │ │ │ -
85
│ │ │ │ -
86 std::vector<typename Extractor::VertexVector> faces;
│ │ │ │ -
87 std::vector<Dune::GeometryType> geometryTypes;
│ │ │ │ -
88 glue.template patch<side>().getFaces(faces);
│ │ │ │ -
89 glue.template patch<side>().getGeometryTypes(geometryTypes);
│ │ │ │ -
90
│ │ │ │ -
91 unsigned int faceCornerCount = 0;
│ │ │ │ -
92 for (size_t i=0; i<faces.size(); i++)
│ │ │ │ -
93 faceCornerCount += faces[i].size();
│ │ │ │ -
94
│ │ │ │ -
95 fgrid << ((patchDim==3) ? "CELLS " : "POLYGONS ")
│ │ │ │ -
96 << geometryTypes.size() << " " << geometryTypes.size() + faceCornerCount << std::endl;
│ │ │ │ -
97
│ │ │ │ -
98 for (size_t i=0; i<faces.size(); i++) {
│ │ │ │ -
99
│ │ │ │ -
100 fgrid << faces[i].size();
│ │ │ │ -
101
│ │ │ │ -
102 // vtk expects the vertices to by cyclically ordered
│ │ │ │ -
103 // therefore unfortunately we have to deal with several element types on a case-by-case basis
│ │ │ │ -
104 if (geometryTypes[i].isSimplex()) {
│ │ │ │ -
105 for (int j=0; j<patchDim+1; j++)
│ │ │ │ -
106 fgrid << " " << faces[i][j];
│ │ │ │ -
107
│ │ │ │ -
108 } else if (geometryTypes[i].isQuadrilateral()) {
│ │ │ │ -
109 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ -
110 << " " << faces[i][3] << " " << faces[i][2];
│ │ │ │ -
111
│ │ │ │ -
112 } else if (geometryTypes[i].isPyramid()) {
│ │ │ │ -
113 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ -
114 << " " << faces[i][3] << " " << faces[i][2] << " " << faces[i][4];
│ │ │ │ -
115
│ │ │ │ -
116 } else if (geometryTypes[i].isPrism()) {
│ │ │ │ -
117 fgrid << " " << faces[i][0] << " " << faces[i][2] << " " << faces[i][1]
│ │ │ │ -
118 << " " << faces[i][3] << " " << faces[i][5] << " " << faces[i][4];
│ │ │ │ -
119
│ │ │ │ -
120 } else if (geometryTypes[i].isHexahedron()) {
│ │ │ │ -
121 fgrid << " " << faces[i][0] << " " << faces[i][1]
│ │ │ │ -
122 << " " << faces[i][3] << " " << faces[i][2]
│ │ │ │ -
123 << " " << faces[i][4] << " " << faces[i][5]
│ │ │ │ -
124 << " " << faces[i][7] << " " << faces[i][6];
│ │ │ │ -
125
│ │ │ │ -
126 } else {
│ │ │ │ -
127 DUNE_THROW(Dune::NotImplemented, "Geometry type " << geometryTypes[i] << " not supported yet");
│ │ │ │ -
128 }
│ │ │ │ -
129
│ │ │ │ -
130 fgrid << std::endl;
│ │ │ │ -
131 }
│ │ │ │ -
132
│ │ │ │ -
133 fgrid << std::endl;
│ │ │ │ -
134
│ │ │ │ -
135 // 3d VTK files need an extra section specifying the CELL_TYPES aka GeometryTypes
│ │ │ │ -
136 if (patchDim==3) {
│ │ │ │ -
137
│ │ │ │ -
138 fgrid << "CELL_TYPES " << geometryTypes.size() << std::endl;
│ │ │ │ -
139
│ │ │ │ -
140 for (size_t i=0; i<geometryTypes.size(); i++) {
│ │ │ │ -
141 if (geometryTypes[i].isSimplex())
│ │ │ │ -
142 fgrid << "10" << std::endl;
│ │ │ │ -
143 else if (geometryTypes[i].isHexahedron())
│ │ │ │ -
144 fgrid << "12" << std::endl;
│ │ │ │ -
145 else if (geometryTypes[i].isPrism())
│ │ │ │ -
146 fgrid << "13" << std::endl;
│ │ │ │ -
147 else if (geometryTypes[i].isPyramid())
│ │ │ │ -
148 fgrid << "14" << std::endl;
│ │ │ │ -
149 else
│ │ │ │ -
150 DUNE_THROW(Dune::NotImplemented, "Geometry type " << geometryTypes[i] << " not supported yet");
│ │ │ │ -
151
│ │ │ │ -
152 }
│ │ │ │ -
153
│ │ │ │ -
154 }
│ │ │ │ -
155
│ │ │ │ -
156#if 0
│ │ │ │ -
157 // WRITE CELL DATA
│ │ │ │ -
158 // ---------------
│ │ │ │ -
159 ctype accum = 0.0, delta = 1.0 / (ctype) (gridSubEntityData.size()-1);
│ │ │ │ -
160
│ │ │ │ -
161 fgrid << "CELL_DATA " << gridSubEntityData.size() << std::endl;
│ │ │ │ -
162 fgrid << "SCALARS property_coding " << Dune::className<ctype>() << " 1" << std::endl;
│ │ │ │ -
163 fgrid << "LOOKUP_TABLE default" << std::endl;
│ │ │ │ -
164
│ │ │ │ -
165 for (typename GridSubEntityData::const_iterator sEIt = gridSubEntityData.begin();
│ │ │ │ -
166 sEIt != gridSubEntityData.end();
│ │ │ │ -
167 ++sEIt, accum += delta)
│ │ │ │ -
168 {
│ │ │ │ -
169 // "encode" the parent with one color...
│ │ │ │ -
170 fgrid << accum << std::endl;
│ │ │ │ -
171 }
│ │ │ │ -
172#endif
│ │ │ │ -
173 fgrid.close();
│ │ │ │ -
174 }
│ │ │ │ -
175
│ │ │ │ -
176
│ │ │ │ -
180 template <class Glue, int side>
│ │ │ │ -
181 static void writeIntersections(const Glue& glue, const std::string& filename)
│ │ │ │ -
182 {
│ │ │ │ -
183 static_assert((side==0 || side==1), "'side' can only be 0 or 1");
│ │ │ │ -
184
│ │ │ │ -
185 std::ofstream fmerged;
│ │ │ │ -
186
│ │ │ │ -
187 fmerged.open(filename.c_str());
│ │ │ │ -
188
│ │ │ │ -
189 using GridView = typename Glue::template GridView<side>;
│ │ │ │ -
190 typedef typename GridView::ctype ctype;
│ │ │ │ -
191
│ │ │ │ -
192 const int domdimw = GridView::dimensionworld;
│ │ │ │ -
193 const int intersectionDim = Glue::Intersection::mydim;
│ │ │ │ -
194
│ │ │ │ -
195 // coordinates have to be in R^3 in the VTK format
│ │ │ │ -
196 std::string coordinatePadding;
│ │ │ │ -
197 for (int i=domdimw; i<3; i++)
│ │ │ │ -
198 coordinatePadding += " 0";
│ │ │ │ -
199
│ │ │ │ -
200 int overlaps = glue.size();
│ │ │ │ -
201
│ │ │ │ -
202 // WRITE POINTS
│ │ │ │ -
203 // ----------------
│ │ │ │ -
204 using Extractor = typename Glue::template GridPatch<0>;
│ │ │ │ -
205 std::vector<typename Extractor::Coords> coords;
│ │ │ │ -
206 glue.template patch<side>().getCoords(coords);
│ │ │ │ -
207
│ │ │ │ -
208 // the merged grid (i.e. the set of remote intersections
│ │ │ │ -
209 fmerged << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" << std::endl;
│ │ │ │ -
210 fmerged << ((intersectionDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") << std::endl;
│ │ │ │ -
211 fmerged << "POINTS " << overlaps*(intersectionDim+1) << " " << Dune::className<ctype>() << std::endl;
│ │ │ │ -
212
│ │ │ │ -
213 for (const auto& intersection : intersections(glue, Reverse<side == 1>{}))
│ │ │ │ -
214 {
│ │ │ │ -
215 const auto& geometry = intersection.geometry();
│ │ │ │ -
216 for (int i = 0; i < geometry.corners(); ++i)
│ │ │ │ -
217 fmerged << geometry.corner(i) << coordinatePadding << std::endl;
│ │ │ │ -
218 }
│ │ │ │ -
219
│ │ │ │ -
220 // WRITE POLYGONS
│ │ │ │ -
221 // ----------------
│ │ │ │ -
222
│ │ │ │ -
223 std::vector<typename Extractor::VertexVector> faces;
│ │ │ │ -
224 std::vector<Dune::GeometryType> geometryTypes;
│ │ │ │ -
225 glue.template patch<side>().getFaces(faces);
│ │ │ │ -
226 glue.template patch<side>().getGeometryTypes(geometryTypes);
│ │ │ │ -
227
│ │ │ │ -
228 unsigned int faceCornerCount = 0;
│ │ │ │ -
229 for (size_t i=0; i<faces.size(); i++)
│ │ │ │ -
230 faceCornerCount += faces[i].size();
│ │ │ │ -
231
│ │ │ │ -
232 int grid0SimplexCorners = intersectionDim+1;
│ │ │ │ -
233 fmerged << ((intersectionDim==3) ? "CELLS " : "POLYGONS ")
│ │ │ │ -
234 << overlaps << " " << (grid0SimplexCorners+1)*overlaps << std::endl;
│ │ │ │ -
235
│ │ │ │ -
236 for (int i = 0; i < overlaps; ++i) {
│ │ │ │ -
237 fmerged << grid0SimplexCorners;
│ │ │ │ -
238 for (int j=0; j<grid0SimplexCorners; j++)
│ │ │ │ -
239 fmerged << " " << grid0SimplexCorners*i+j;
│ │ │ │ -
240 fmerged << std::endl;
│ │ │ │ -
241 }
│ │ │ │ -
242
│ │ │ │ -
243 // 3d VTK files need an extra section specifying the CELL_TYPES aka GeometryTypes
│ │ │ │ -
244 if (intersectionDim==3) {
│ │ │ │ -
245
│ │ │ │ -
246 fmerged << "CELL_TYPES " << overlaps << std::endl;
│ │ │ │ -
247
│ │ │ │ -
248 for (int i = 0; i < overlaps; i++)
│ │ │ │ -
249 fmerged << "10" << std::endl;
│ │ │ │ -
250
│ │ │ │ -
251 }
│ │ │ │ -
252
│ │ │ │ -
253#if 0
│ │ │ │ -
254 // WRITE CELL DATA
│ │ │ │ -
255 // ---------------
│ │ │ │ -
256 ctype accum = 0.0, delta = 1.0 / (ctype) (gridSubEntityData.size()-1);
│ │ │ │ -
257
│ │ │ │ -
258 fmerged << "CELL_DATA " << overlaps << std::endl;
│ │ │ │ -
259 fmerged << "SCALARS property_coding " << Dune::className<ctype>() << " 1" << std::endl;
│ │ │ │ -
260 fmerged << "LOOKUP_TABLE default" << std::endl;
│ │ │ │ -
261
│ │ │ │ -
262 for (typename GridSubEntityData::const_iterator sEIt = gridSubEntityData.begin();
│ │ │ │ -
263 sEIt != gridSubEntityData.end();
│ │ │ │ -
264 ++sEIt, accum += delta)
│ │ │ │ -
265 {
│ │ │ │ -
266 // ...and mark all of its merged grid parts with the same color
│ │ │ │ -
267 for (int j = 0; j < sEIt->first.second; ++j)
│ │ │ │ -
268 fmerged << accum << std::endl;
│ │ │ │ -
269 }
│ │ │ │ -
270#endif
│ │ │ │ -
271 fmerged.close();
│ │ │ │ -
272 }
│ │ │ │ -
273
│ │ │ │ -
274public:
│ │ │ │ -
275 template<typename Glue>
│ │ │ │ -
│ │ │ │ -
276 static void write(const Glue& glue, const std::string& filenameTrunk)
│ │ │ │ -
277 {
│ │ │ │ -
278
│ │ │ │ -
279 // Write extracted grid and remote intersection on the grid0-side
│ │ │ │ -
280 writeExtractedPart<Glue,0>(glue,
│ │ │ │ -
281 filenameTrunk + "-grid0.vtk");
│ │ │ │ -
282
│ │ │ │ -
283 writeIntersections<Glue,0>(glue,
│ │ │ │ -
284 filenameTrunk + "-intersections-grid0.vtk");
│ │ │ │ -
285
│ │ │ │ -
286 // Write extracted grid and remote intersection on the grid1-side
│ │ │ │ -
287 writeExtractedPart<Glue,1>(glue,
│ │ │ │ -
288 filenameTrunk + "-grid1.vtk");
│ │ │ │ -
289
│ │ │ │ -
290 writeIntersections<Glue,1>(glue,
│ │ │ │ -
291 filenameTrunk + "-intersections-grid1.vtk");
│ │ │ │ -
292
│ │ │ │ -
293 }
│ │ │ │ -
│ │ │ │ -
294
│ │ │ │ -
295};
│ │ │ │ -
│ │ │ │ -
296
│ │ │ │ -
297} /* namespace GridGlue */
│ │ │ │ -
298} /* namespace Dune */
│ │ │ │ -
299
│ │ │ │ -
300#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH
│ │ │ │ +
12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ +
13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH
│ │ │ │ +
14
│ │ │ │ + │ │ │ │ +
16
│ │ │ │ +
17namespace Dune {
│ │ │ │ +
18 namespace GridGlue {
│ │ │ │ +
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_;
│ │ │ │ +
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_;
│ │ │ │ +
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.
│ │ │ │
Definition gridglue.hh:37
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
Write remote intersections to a vtk file for debugging purposes.
Definition gridgluevtkwriter.hh:41
│ │ │ │ -
static void write(const Glue &glue, const std::string &filenameTrunk)
Definition gridgluevtkwriter.hh:276
│ │ │ │ -
Definition rangegenerators.hh:17
│ │ │ │ -
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
│ │ │ │ -
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │ -
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition extractor.hh:256
│ │ │ │ -
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,349 +1,99 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -gridgluevtkwriter.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/* │ │ │ │ │ -6 * Filename: GridGlueVtkWriter.hh │ │ │ │ │ -7 * Version: 1.0 │ │ │ │ │ -8 * Created on: Mar 5, 2009 │ │ │ │ │ -9 * Author: Gerrit Buse │ │ │ │ │ -10 * --------------------------------- │ │ │ │ │ -11 * Project: dune-grid-glue │ │ │ │ │ -12 * Description: Class thought to make graphical debugging of couplings │ │ │ │ │ -easier. │ │ │ │ │ -13 * │ │ │ │ │ -14 */ │ │ │ │ │ -20#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH │ │ │ │ │ -21#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH │ │ │ │ │ -22 │ │ │ │ │ -23 │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28 │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32 │ │ │ │ │ -33#include │ │ │ │ │ -34 │ │ │ │ │ -35namespace Dune { │ │ │ │ │ -36namespace GridGlue { │ │ │ │ │ -37 │ │ │ │ │ -40class GridGlueVtkWriter │ │ │ │ │ -41{ │ │ │ │ │ -42 │ │ │ │ │ -46 template │ │ │ │ │ -47 static void writeExtractedPart(const Glue& glue, const std::string& │ │ │ │ │ -filename) │ │ │ │ │ -48 { │ │ │ │ │ -49 static_assert((side==0 || side==1), "'side' can only be 0 or 1"); │ │ │ │ │ -50 │ │ │ │ │ -51 std::ofstream fgrid; │ │ │ │ │ -52 │ │ │ │ │ -53 fgrid.open(filename.c_str()); │ │ │ │ │ -54 │ │ │ │ │ -55 using GridView = typename Glue::template GridView; │ │ │ │ │ -56 using Extractor = typename Glue::template GridPatch; │ │ │ │ │ -57 │ │ │ │ │ -58 typedef typename GridView::ctype ctype; │ │ │ │ │ -59 │ │ │ │ │ -60 const int domdimw = GridView::dimensionworld; │ │ │ │ │ -61 const int patchDim = Extractor::dim - Extractor::codim; │ │ │ │ │ -62 │ │ │ │ │ -63 // coordinates have to be in R^3 in the VTK format │ │ │ │ │ -64 std::string coordinatePadding; │ │ │ │ │ -65 for (int i=domdimw; i<3; i++) │ │ │ │ │ -66 coordinatePadding += " 0"; │ │ │ │ │ -67 │ │ │ │ │ -68 fgrid << "# vtk DataFile Version 2.0\nFilename: " << filename << "\nASCII" │ │ │ │ │ -<< std::endl; │ │ │ │ │ -69 │ │ │ │ │ -70 // WRITE POINTS │ │ │ │ │ -71 // ---------------- │ │ │ │ │ -72 std::vector coords; │ │ │ │ │ -73 glue.template patch().getCoords(coords); │ │ │ │ │ -74 │ │ │ │ │ -75 fgrid << ((patchDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET POLYDATA") │ │ │ │ │ -<< std::endl; │ │ │ │ │ -76 fgrid << "POINTS " << coords.size() << " " << Dune::className() << │ │ │ │ │ -std::endl; │ │ │ │ │ -77 │ │ │ │ │ -78 for (size_t i=0; i faces; │ │ │ │ │ -87 std::vector geometryTypes; │ │ │ │ │ -88 glue.template patch().getFaces(faces); │ │ │ │ │ -89 glue.template patch().getGeometryTypes(geometryTypes); │ │ │ │ │ -90 │ │ │ │ │ -91 unsigned int faceCornerCount = 0; │ │ │ │ │ -92 for (size_t i=0; i() << " 1" << │ │ │ │ │ -std::endl; │ │ │ │ │ -163 fgrid << "LOOKUP_TABLE default" << std::endl; │ │ │ │ │ -164 │ │ │ │ │ -165 for (typename GridSubEntityData::const_iterator sEIt = │ │ │ │ │ -gridSubEntityData.begin(); │ │ │ │ │ -166 sEIt != gridSubEntityData.end(); │ │ │ │ │ -167 ++sEIt, accum += delta) │ │ │ │ │ -168 { │ │ │ │ │ -169 // "encode" the parent with one color... │ │ │ │ │ -170 fgrid << accum << std::endl; │ │ │ │ │ -171 } │ │ │ │ │ -172#endif │ │ │ │ │ -173 fgrid.close(); │ │ │ │ │ -174 } │ │ │ │ │ -175 │ │ │ │ │ -176 │ │ │ │ │ -180 template │ │ │ │ │ -181 static void writeIntersections(const Glue& glue, const std::string& │ │ │ │ │ -filename) │ │ │ │ │ -182 { │ │ │ │ │ -183 static_assert((side==0 || side==1), "'side' can only be 0 or 1"); │ │ │ │ │ -184 │ │ │ │ │ -185 std::ofstream fmerged; │ │ │ │ │ -186 │ │ │ │ │ -187 fmerged.open(filename.c_str()); │ │ │ │ │ -188 │ │ │ │ │ -189 using GridView = typename Glue::template GridView; │ │ │ │ │ -190 typedef typename GridView::ctype ctype; │ │ │ │ │ -191 │ │ │ │ │ -192 const int domdimw = GridView::dimensionworld; │ │ │ │ │ -193 const int intersectionDim = Glue::Intersection::mydim; │ │ │ │ │ -194 │ │ │ │ │ -195 // coordinates have to be in R^3 in the VTK format │ │ │ │ │ -196 std::string coordinatePadding; │ │ │ │ │ -197 for (int i=domdimw; i<3; i++) │ │ │ │ │ -198 coordinatePadding += " 0"; │ │ │ │ │ -199 │ │ │ │ │ -200 int overlaps = glue.size(); │ │ │ │ │ -201 │ │ │ │ │ -202 // WRITE POINTS │ │ │ │ │ -203 // ---------------- │ │ │ │ │ -204 using Extractor = typename Glue::template GridPatch<0>; │ │ │ │ │ -205 std::vector coords; │ │ │ │ │ -206 glue.template patch().getCoords(coords); │ │ │ │ │ -207 │ │ │ │ │ -208 // the merged grid (i.e. the set of remote intersections │ │ │ │ │ -209 fmerged << "# vtk DataFile Version 2.0\nFilename: " << filename << │ │ │ │ │ -"\nASCII" << std::endl; │ │ │ │ │ -210 fmerged << ((intersectionDim==3) ? "DATASET UNSTRUCTURED_GRID" : "DATASET │ │ │ │ │ -POLYDATA") << std::endl; │ │ │ │ │ -211 fmerged << "POINTS " << overlaps*(intersectionDim+1) << " " << Dune:: │ │ │ │ │ -className() << std::endl; │ │ │ │ │ -212 │ │ │ │ │ -213 for (const auto& intersection : intersections(glue, Reverse{})) │ │ │ │ │ -214 { │ │ │ │ │ -215 const auto& geometry = intersection.geometry(); │ │ │ │ │ -216 for (int i = 0; i < geometry.corners(); ++i) │ │ │ │ │ -217 fmerged << geometry.corner(i) << coordinatePadding << std::endl; │ │ │ │ │ -218 } │ │ │ │ │ -219 │ │ │ │ │ -220 // WRITE POLYGONS │ │ │ │ │ -221 // ---------------- │ │ │ │ │ -222 │ │ │ │ │ -223 std::vector faces; │ │ │ │ │ -224 std::vector geometryTypes; │ │ │ │ │ -225 glue.template patch().getFaces(faces); │ │ │ │ │ -226 glue.template patch().getGeometryTypes(geometryTypes); │ │ │ │ │ -227 │ │ │ │ │ -228 unsigned int faceCornerCount = 0; │ │ │ │ │ -229 for (size_t i=0; i() << " 1" │ │ │ │ │ -<< std::endl; │ │ │ │ │ -260 fmerged << "LOOKUP_TABLE default" << std::endl; │ │ │ │ │ -261 │ │ │ │ │ -262 for (typename GridSubEntityData::const_iterator sEIt = │ │ │ │ │ -gridSubEntityData.begin(); │ │ │ │ │ -263 sEIt != gridSubEntityData.end(); │ │ │ │ │ -264 ++sEIt, accum += delta) │ │ │ │ │ -265 { │ │ │ │ │ -266 // ...and mark all of its merged grid parts with the same color │ │ │ │ │ -267 for (int j = 0; j < sEIt->first.second; ++j) │ │ │ │ │ -268 fmerged << accum << std::endl; │ │ │ │ │ -269 } │ │ │ │ │ -270#endif │ │ │ │ │ -271 fmerged.close(); │ │ │ │ │ -272 } │ │ │ │ │ -273 │ │ │ │ │ -274public: │ │ │ │ │ -275 template │ │ │ │ │ -276 static void write(const Glue& glue, const std::string& filenameTrunk) │ │ │ │ │ -277 { │ │ │ │ │ -278 │ │ │ │ │ -279 // Write extracted grid and remote intersection on the grid0-side │ │ │ │ │ -280 writeExtractedPart(glue, │ │ │ │ │ -281 filenameTrunk + "-grid0.vtk"); │ │ │ │ │ -282 │ │ │ │ │ -283 writeIntersections(glue, │ │ │ │ │ -284 filenameTrunk + "-intersections-grid0.vtk"); │ │ │ │ │ -285 │ │ │ │ │ -286 // Write extracted grid and remote intersection on the grid1-side │ │ │ │ │ -287 writeExtractedPart(glue, │ │ │ │ │ -288 filenameTrunk + "-grid1.vtk"); │ │ │ │ │ -289 │ │ │ │ │ -290 writeIntersections(glue, │ │ │ │ │ -291 filenameTrunk + "-intersections-grid1.vtk"); │ │ │ │ │ -292 │ │ │ │ │ -293 } │ │ │ │ │ -294 │ │ │ │ │ -295}; │ │ │ │ │ -296 │ │ │ │ │ -297} /* namespace GridGlue */ │ │ │ │ │ -298} /* namespace Dune */ │ │ │ │ │ -299 │ │ │ │ │ -300#endif // DUNE_GRIDGLUE_ADAPTER_GRIDGLUEVTKWRITER_HH │ │ │ │ │ +12#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ +13#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONITERATOR_HH │ │ │ │ │ +14 │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +17namespace Dune { │ │ │ │ │ +18 namespace GridGlue { │ │ │ │ │ +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_; │ │ │ │ │ +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_; │ │ │ │ │ +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. │ │ │ │ │ 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::GridGlueVtkWriter │ │ │ │ │ -Write remote intersections to a vtk file for debugging purposes. │ │ │ │ │ -Definition gridgluevtkwriter.hh:41 │ │ │ │ │ -Dune::GridGlue::GridGlueVtkWriter::write │ │ │ │ │ -static void write(const Glue &glue, const std::string &filenameTrunk) │ │ │ │ │ -Definition gridgluevtkwriter.hh:276 │ │ │ │ │ -Dune::GridGlue::Reverse │ │ │ │ │ -Definition rangegenerators.hh:17 │ │ │ │ │ -Dune::GridGlue::Extractor │ │ │ │ │ -Provides codimension-independent methods for grid extraction. │ │ │ │ │ -Definition extractor.hh:46 │ │ │ │ │ -Dune::GridGlue::Extractor::codim │ │ │ │ │ -static constexpr auto codim │ │ │ │ │ -Definition extractor.hh:52 │ │ │ │ │ -Dune::GridGlue::Extractor::getCoords │ │ │ │ │ -void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) │ │ │ │ │ -const │ │ │ │ │ -getter for the coordinates array │ │ │ │ │ -Definition extractor.hh:256 │ │ │ │ │ -Dune::GridGlue::Extractor::dim │ │ │ │ │ -static constexpr auto dim │ │ │ │ │ -Definition extractor.hh:51 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectionindexset.hh File Reference │ │ │ │ +dune-grid-glue: gridgluecommunicate.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,35 +71,74 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
intersectionindexset.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions
│ │ │ │ +
gridgluecommunicate.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/grid-glue/gridglue.hh>
│ │ │ │ -#include <dune/grid-glue/adapter/intersection.hh>
│ │ │ │ + │ │ │ │ +

Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ +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>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::GridGlue::IntersectionIndexSet< P0, P1 >
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 required 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

│ │ │ │ +

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

│ │ │ │ +
Author
Christian Engwer
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,22 +1,61 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -intersectionindexset.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#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::IntersectionIndexSet<_P0,_P1_> │ │ │ │ │ +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 required 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 ***** │ │ │ │ │ +Describes the parallel communication interface class for Dune::GridGlue. │ │ │ │ │ + Author │ │ │ │ │ + Christian Engwer │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00023_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: intersectionindexset.hh Source File │ │ │ │ +dune-grid-glue: gridgluecommunicate.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,87 +74,365 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
intersectionindexset.hh
│ │ │ │ +
gridgluecommunicate.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_INTERSECTIONINDEXSET_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH
│ │ │ │ -
5
│ │ │ │ - │ │ │ │ - │ │ │ │ -
8
│ │ │ │ -
9#ifndef ONLY_SIMPLEX_INTERSECTIONS
│ │ │ │ -
10// we currently support only one intersection type. If we want to support more,
│ │ │ │ -
11// we have to think about the semantics of our IndexSet
│ │ │ │ -
12#error Not Implemented
│ │ │ │ -
13#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_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ +
6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH
│ │ │ │ +
7
│ │ │ │ +
13#include <type_traits>
│ │ │ │
14
│ │ │ │ -
15namespace Dune {
│ │ │ │ -
16 namespace GridGlue {
│ │ │ │ -
17
│ │ │ │ -
18 template<typename P0, typename P1>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
20 {
│ │ │ │ -
21 friend class ::Dune::GridGlue::GridGlue<P0,P1>;
│ │ │ │ -
22 typedef ::Dune::GridGlue::GridGlue<P0,P1> 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
│ │ │ │ +
20
│ │ │ │ +
21namespace Dune {
│ │ │ │ +
22 namespace GridGlue {
│ │ │ │
23
│ │ │ │ -
24 public:
│ │ │ │ -
25
│ │ │ │ - │ │ │ │ -
29 typedef size_t SizeType;
│ │ │ │ -
30
│ │ │ │ -
33 template<int I, int O>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
35 {
│ │ │ │ -
36 return i.i_->index_;
│ │ │ │ -
37 }
│ │ │ │ -
│ │ │ │ -
38
│ │ │ │ -
│ │ │ │ -
41 SizeType size () const
│ │ │ │ -
42 {
│ │ │ │ -
43 return glue_->size();
│ │ │ │ -
44 }
│ │ │ │ -
│ │ │ │ -
45
│ │ │ │ -
46 private:
│ │ │ │ -
47
│ │ │ │ - │ │ │ │ -
50 glue_(g) {}
│ │ │ │ -
51
│ │ │ │ -
52 const GridGlue * glue_;
│ │ │ │ -
53 };
│ │ │ │ +
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 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
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
│ │ │ │ -
55 } // end namespace GridGlue
│ │ │ │ -
56} // end namespace Dune
│ │ │ │ -
57
│ │ │ │ -
58#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH
│ │ │ │ -
Central component of the module implementing the coupling of two grids.
│ │ │ │ -
Model of the Intersection concept provided by GridGlue.
│ │ │ │ +
│ │ │ │ +
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 interface 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
│ │ │ │ -
unsigned int IndexType
Definition gridglue.hh:147
│ │ │ │ -
size_t size() const
Definition gridglue.hh:393
│ │ │ │ -
IndexType index_
index of this intersection after GridGlue interface
Definition intersection.hh:112
│ │ │ │ +
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:257
│ │ │ │ -
Definition intersectionindexset.hh:20
│ │ │ │ -
SizeType size() const
Return total number of intersections.
Definition intersectionindexset.hh:41
│ │ │ │ -
GridGlue::IndexType IndexType
The type used for the indices.
Definition intersectionindexset.hh:27
│ │ │ │ -
IndexType index(const Intersection< P0, P1, I, O > &i) const
Map Dune::GridGlue::Intersection to index.
Definition intersectionindexset.hh:34
│ │ │ │ -
size_t SizeType
The type used for the size.
Definition intersectionindexset.hh:29
│ │ │ │ +
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition intersection.hh:474
│ │ │ │ +
bool self() const
For parallel computations: Return true if inside() entity exists locally.
Definition intersection.hh:384
│ │ │ │ +
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition intersection.hh:315
│ │ │ │ +
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition intersection.hh:390
│ │ │ │ +
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition intersection.hh:324
│ │ │ │ +
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 required 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 {} │ │ │ │ │ @@ -1,105 +1,442 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * adapter │ │ │ │ │ -intersectionindexset.hh │ │ │ │ │ +gridgluecommunicate.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-with- │ │ │ │ │ +4// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with- │ │ │ │ │ dune-grid-glue-exception │ │ │ │ │ -3#ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ -4#define DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ -5 │ │ │ │ │ -6#include │ │ │ │ │ -7#include │ │ │ │ │ -8 │ │ │ │ │ -9#ifndef ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ -10// we currently support only one intersection type. If we want to support │ │ │ │ │ -more, │ │ │ │ │ -11// we have to think about the semantics of our IndexSet │ │ │ │ │ -12#error Not Implemented │ │ │ │ │ -13#endif │ │ │ │ │ +5#ifndef DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ +6#define DUNE_GRIDGLUE_ADAPTER_GRIDGLUECOMMUNICATE_HH │ │ │ │ │ +7 │ │ │ │ │ +13#include │ │ │ │ │ 14 │ │ │ │ │ -15namespace Dune { │ │ │ │ │ -16 namespace GridGlue { │ │ │ │ │ -17 │ │ │ │ │ -18 template │ │ │ │ │ -19 class IntersectionIndexSet │ │ │ │ │ -20 { │ │ │ │ │ -21 friend class ::Dune::GridGlue::GridGlue; │ │ │ │ │ -22 typedef ::Dune::GridGlue::GridGlue GridGlue; │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19 │ │ │ │ │ +20 │ │ │ │ │ +21namespace Dune { │ │ │ │ │ +22 namespace GridGlue { │ │ │ │ │ 23 │ │ │ │ │ -24 public: │ │ │ │ │ -25 │ │ │ │ │ -27 typedef typename GridGlue::IndexType IndexType; │ │ │ │ │ -29 typedef size_t SizeType; │ │ │ │ │ -30 │ │ │ │ │ -33 template │ │ │ │ │ -34 IndexType index (const Intersection & i) const │ │ │ │ │ -35 { │ │ │ │ │ -36 return i.i_->index_; │ │ │ │ │ -37 } │ │ │ │ │ -38 │ │ │ │ │ -41 SizeType size () const │ │ │ │ │ -42 { │ │ │ │ │ -43 return glue_->size(); │ │ │ │ │ -44 } │ │ │ │ │ -45 │ │ │ │ │ -46 private: │ │ │ │ │ -47 │ │ │ │ │ -49 IntersectionIndexSet(const GridGlue * g) : │ │ │ │ │ -50 glue_(g) {} │ │ │ │ │ -51 │ │ │ │ │ -52 const GridGlue * glue_; │ │ │ │ │ +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 } │ │ │ │ │ +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 │ │ │ │ │ -55 } // end namespace GridGlue │ │ │ │ │ -56} // end namespace Dune │ │ │ │ │ -57 │ │ │ │ │ -58#endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTIONINDEXSET_HH │ │ │ │ │ -gridglue.hh │ │ │ │ │ -Central component of the module implementing the coupling of two grids. │ │ │ │ │ -intersection.hh │ │ │ │ │ -Model of the Intersection concept provided by GridGlue. │ │ │ │ │ +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 interface 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::GridGlue::IndexType │ │ │ │ │ -unsigned int IndexType │ │ │ │ │ -Definition gridglue.hh:147 │ │ │ │ │ -Dune::GridGlue::GridGlue::size │ │ │ │ │ -size_t size() const │ │ │ │ │ -Definition gridglue.hh:393 │ │ │ │ │ -Dune::GridGlue::IntersectionData::index_ │ │ │ │ │ -IndexType index_ │ │ │ │ │ -index of this intersection after GridGlue interface │ │ │ │ │ -Definition intersection.hh:112 │ │ │ │ │ +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:257 │ │ │ │ │ -Dune::GridGlue::IntersectionIndexSet │ │ │ │ │ -Definition intersectionindexset.hh:20 │ │ │ │ │ -Dune::GridGlue::IntersectionIndexSet::size │ │ │ │ │ -SizeType size() const │ │ │ │ │ -Return total number of intersections. │ │ │ │ │ -Definition intersectionindexset.hh:41 │ │ │ │ │ -Dune::GridGlue::IntersectionIndexSet::IndexType │ │ │ │ │ -GridGlue::IndexType IndexType │ │ │ │ │ -The type used for the indices. │ │ │ │ │ -Definition intersectionindexset.hh:27 │ │ │ │ │ -Dune::GridGlue::IntersectionIndexSet::index │ │ │ │ │ -IndexType index(const Intersection< P0, P1, I, O > &i) const │ │ │ │ │ -Map Dune::GridGlue::Intersection to index. │ │ │ │ │ -Definition intersectionindexset.hh:34 │ │ │ │ │ -Dune::GridGlue::IntersectionIndexSet::SizeType │ │ │ │ │ -size_t SizeType │ │ │ │ │ -The type used for the size. │ │ │ │ │ -Definition intersectionindexset.hh:29 │ │ │ │ │ +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:474 │ │ │ │ │ +Dune::GridGlue::Intersection::self │ │ │ │ │ +bool self() const │ │ │ │ │ +For parallel computations: Return true if inside() entity exists locally. │ │ │ │ │ +Definition intersection.hh:384 │ │ │ │ │ +Dune::GridGlue::Intersection::inside │ │ │ │ │ +InsideEntity inside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the inside of this intersection. │ │ │ │ │ +Definition intersection.hh:315 │ │ │ │ │ +Dune::GridGlue::Intersection::neighbor │ │ │ │ │ +size_t neighbor(unsigned int g=0) const │ │ │ │ │ +Return number of embeddings into local grid0 (grid1) entities. │ │ │ │ │ +Definition intersection.hh:390 │ │ │ │ │ +Dune::GridGlue::Intersection::outside │ │ │ │ │ +OutsideEntity outside(unsigned int parentId=0) const │ │ │ │ │ +Return element on the outside of this intersection. │ │ │ │ │ +Definition intersection.hh:324 │ │ │ │ │ +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 required 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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026.html │ │ │ │ @@ -75,19 +75,19 @@ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │
gridglue.cc File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include "intersection.hh"
│ │ │ │ +
#include "intersection.hh"
│ │ │ │ #include <vector>
│ │ │ │ #include <iterator>
│ │ │ │ #include "../gridglue.hh"
│ │ │ │ -#include "../common/ringcomm.hh"
│ │ │ │ +#include "../common/ringcomm.hh"
│ │ │ │ #include <dune/common/unused.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00026_source.html │ │ │ │ @@ -83,15 +83,15 @@ │ │ │ │
│ │ │ │ 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
│ │ │ │ -
7#include "intersection.hh"
│ │ │ │ +
7#include "intersection.hh"
│ │ │ │
8#include <vector>
│ │ │ │
9#include <iterator>
│ │ │ │
10#include "../gridglue.hh"
│ │ │ │
11#if HAVE_MPI
│ │ │ │
12#include "../common/ringcomm.hh"
│ │ │ │
13#endif
│ │ │ │
14
│ │ │ │ @@ -534,15 +534,15 @@ │ │ │ │
440 }
│ │ │ │
441 }
│ │ │ │
442}
│ │ │ │
│ │ │ │
443
│ │ │ │
444} // end namespace GridGlue
│ │ │ │
445} // end namespace Dune
│ │ │ │ -
Model of the Intersection concept provided by GridGlue.
│ │ │ │ +
Model of the Intersection concept provided by GridGlue.
│ │ │ │
Definition gridglue.hh:37
│ │ │ │
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │
void printVector(const std::vector< T > &v, std::string name, int rank)
Definition gridglue.cc:168
│ │ │ │
void MPI_AllApply(MPI_Comm mpicomm, OP &&op, const Args &... data)
apply an operator locally to a difstributed data set
Definition ringcomm.hh:297
│ │ │ │
sequential adapter to couple two grids at specified close together boundaries
Definition gridglue.hh:67
│ │ │ │
void mergePatches(const std::vector< Dune::FieldVector< ctype, dimworld > > &patch0coords, const std::vector< unsigned int > &patch0entities, const std::vector< Dune::GeometryType > &patch0types, const int patch0rank, const std::vector< Dune::FieldVector< ctype, dimworld > > &patch1coords, const std::vector< unsigned int > &patch1entities, const std::vector< Dune::GeometryType > &patch1types, const int patch1rank)
after building the merged grid the intersection can be updated through this method (for internal use)
Definition gridglue.cc:179
│ │ │ │
void communicate(Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate information on the MergedGrid of a GridGlue.
Definition gridglue.cc:300
│ │ │ ├── ./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: projection_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,59 +72,47 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
projectionwriter_impl.hh File Reference
│ │ │ │ +
projection_impl.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <fstream>
│ │ │ │ +
#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <cmath>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Namespaces

namespace  Dune
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

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

│ │ │ │ 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
 
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
 
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.
 
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 {} │ │ │ │ │ @@ -2,59 +2,43 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -projectionwriter_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +projection_impl.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -namespace   Dune::GridGlue::ProjectionWriterImplementation │ │ │ │ │ +namespace   Dune::GridGlue::ProjectionImplementation │ │ │ │ │   │ │ │ │ │ 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 │ │ │ │ │ + Coordinate  Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + corner (unsigned c) │ │ │ │ │ +  │ │ │ │ │ + std::pair< unsigned, unsigned Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + >  edgeToCorners (unsigned edge) │ │ │ │ │   │ │ │ │ │ template │ │ │ │ │ -void  Dune::GridGlue::ProjectionWriterImplementation::write_edge_intersection_ │ │ │ │ │ - points (const Projection< Coordinate > &projection, const Corners │ │ │ │ │ - &corners, std::ostream &out) │ │ │ │ │ + Corners::value_type  Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ + interpolate (const Coordinate &x, const Corners │ │ │ │ │ + &corners) │ │ │ │ │   │ │ │ │ │ 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 │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ -  write projection in VTK format │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals) │ │ │ │ │ -  Print information about the projection to std::cout stream. │ │ │ │ │ + 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.8 │ │ │ ├── ./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: projection_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,211 +74,464 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
projectionwriter_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>
│ │ │ │ +
3#include <dune/common/fmatrix.hh>
│ │ │ │
4
│ │ │ │ -
5namespace Dune {
│ │ │ │ -
6namespace GridGlue {
│ │ │ │ -
7
│ │ │ │ -
│ │ │ │ -
8namespace ProjectionWriterImplementation {
│ │ │ │ +
5#include <cmath>
│ │ │ │ +
6
│ │ │ │ +
7namespace Dune {
│ │ │ │ +
8namespace GridGlue {
│ │ │ │
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}
│ │ │ │ +
│ │ │ │ +
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}
│ │ │ │
│ │ │ │ -
41
│ │ │ │ -
42template<typename Coordinate, typename Corners>
│ │ │ │ +
32
│ │ │ │ +
42inline std::pair<unsigned, unsigned>
│ │ │ │
│ │ │ │ -
43void write_edge_intersection_points(const Projection<Coordinate>& projection, const Corners& corners, std::ostream& out)
│ │ │ │ +
43edgeToCorners(unsigned edge)
│ │ │ │
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}
│ │ │ │ +
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}
│ │ │ │
│ │ │ │ -
128
│ │ │ │ -
129template<typename Coordinate, typename Corners, typename Normals>
│ │ │ │ +
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>
│ │ │ │ +
129Projection<Coordinate>
│ │ │ │
│ │ │ │ -
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>
│ │ │ │ +
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
│ │ │ │ + │ │ │ │
│ │ │ │ -
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 */
│ │ │ │ +
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>
│ │ │ │ +
468void Projection<Coordinate>
│ │ │ │ +
│ │ │ │ +
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(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
│ │ │ │ -
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
│ │ │ │ +
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
│ │ │ │ -
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
│ │ │ │ +
Coordinate::field_type Field
Scalar type.
Definition projection.hh:61
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,238 +1,480 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projectionwriter_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 │ │ │ │ │ +3#include │ │ │ │ │ 4 │ │ │ │ │ -5namespace Dune { │ │ │ │ │ -6namespace GridGlue { │ │ │ │ │ -7 │ │ │ │ │ -8namespace ProjectionWriterImplementation { │ │ │ │ │ +5#include │ │ │ │ │ +6 │ │ │ │ │ +7namespace Dune { │ │ │ │ │ +8namespace GridGlue { │ │ │ │ │ 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; │ │ │ │ │ +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 │ │ │ │ │ -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) │ │ │ │ │ +42inline std::pair │ │ │ │ │ +43edgeToCorners(unsigned edge) │ │ │ │ │ 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"; │ │ │ │ │ +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 │ │ │ │ │ -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 */ │ │ │ │ │ +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 */ │ │ │ │ │ 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::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::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::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::Projection::Field │ │ │ │ │ +Coordinate::field_type Field │ │ │ │ │ +Scalar type. │ │ │ │ │ +Definition projection.hh:61 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter.hh File Reference │ │ │ │ +dune-grid-glue: ringcomm.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,43 +71,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
 
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ CheckMPIStatus

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define CheckMPIStatus( A,
 
)   {}
│ │ │ │ +
│ │ │ │ +
Todo:
Implement MPI Status check with exception handling
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,32 +1,39 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * 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 │ │ │ │ │   │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ CheckMPIStatus ***** │ │ │ │ │ +#define CheckMPIStatus (   A, │ │ │ │ │ +   B  │ │ │ │ │ + )    {} │ │ │ │ │ + Todo: │ │ │ │ │ + Implement MPI Status check with exception handling │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00032_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter.hh Source File │ │ │ │ +dune-grid-glue: ringcomm.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,47 +74,309 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
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 actual 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 {} │ │ │ │ │ @@ -1,48 +1,308 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * 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-with- │ │ │ │ │ +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 actual 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: ringcomm.hh File Reference │ │ │ │ +dune-grid-glue: projectionwriter_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,77 +71,61 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ -Macros | │ │ │ │ Functions
│ │ │ │ -
ringcomm.hh File Reference
│ │ │ │ +
projectionwriter_impl.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 <fstream>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Namespaces

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

│ │ │ │ -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
 
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
 
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
 
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.
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ CheckMPIStatus

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define CheckMPIStatus( A,
 
)   {}
│ │ │ │ -
│ │ │ │ -
Todo:
Implement MPI Status check with exception handling
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,39 +1,60 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -ringcomm.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +projectionwriter_impl.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Parallel │ │ │ │ │ +namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  CheckMPIStatus(A, B)   {} │ │ │ │ │ +namespace   Dune::GridGlue::ProjectionWriterImplementation │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -void  Dune::Parallel::MPI_AllApply (MPI_Comm mpicomm, OP &&op, const Args &... │ │ │ │ │ - data) │ │ │ │ │ -  apply an operator locally to a difstributed data set │ │ │ │ │ -  │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ CheckMPIStatus ***** │ │ │ │ │ -#define CheckMPIStatus (   A, │ │ │ │ │ -   B  │ │ │ │ │ - )    {} │ │ │ │ │ - Todo: │ │ │ │ │ - Implement MPI Status check with exception handling │ │ │ │ │ +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 │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ +  write projection in VTK format │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals) │ │ │ │ │ +  Print information about the projection to std::cout stream. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00035_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: ringcomm.hh Source File │ │ │ │ +dune-grid-glue: projectionwriter_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,309 +74,211 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
ringcomm.hh
│ │ │ │ +
projectionwriter_impl.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) {}
│ │ │ │ +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
│ │ │ │ -
10#include <mpi.h>
│ │ │ │ -
11#include <functional>
│ │ │ │ -
12#include <utility>
│ │ │ │ -
13
│ │ │ │ -
14#include <dune/common/fvector.hh>
│ │ │ │ -
15#include <dune/common/hybridutilities.hh>
│ │ │ │ +
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#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 };
│ │ │ │ +
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 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 actual 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}
│ │ │ │ +
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}
│ │ │ │
│ │ │ │ -
308
│ │ │ │ -
309} // end namespace Parallel
│ │ │ │ +
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}
│ │ │ │
│ │ │ │ -
310} // end namespace Dune
│ │ │ │ +
161
│ │ │ │ +
162} /* namespace GridGlue */
│ │ │ │ +
163} /* namespace Dune */
│ │ │ │
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
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,308 +1,238 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -ringcomm.hh │ │ │ │ │ +projectionwriter_impl.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-with- │ │ │ │ │ +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) {} │ │ │ │ │ +3#include │ │ │ │ │ +4 │ │ │ │ │ +5namespace Dune { │ │ │ │ │ +6namespace GridGlue { │ │ │ │ │ +7 │ │ │ │ │ +8namespace ProjectionWriterImplementation { │ │ │ │ │ 9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ +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#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 }; │ │ │ │ │ +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 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 actual 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(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::Parallel::MPI_AllApply │ │ │ │ │ -void MPI_AllApply(MPI_Comm mpicomm, OP &&op, const Args &... data) │ │ │ │ │ -apply an operator locally to a difstributed data set │ │ │ │ │ -Definition ringcomm.hh:297 │ │ │ │ │ +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::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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projection.hh File Reference │ │ │ │ +dune-grid-glue: areawriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,41 +70,43 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
projection.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
areawriter.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <array>
│ │ │ │ -#include <bitset>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include "projection_impl.hh"
│ │ │ │ +
#include <ostream>
│ │ │ │ +#include <string>
│ │ │ │ +#include "areawriter_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...
 
struct  Dune::GridGlue::Projection< Coordinate >::EdgeIntersection
 Intersection between two edges of a triangle. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

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

│ │ │ │ +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)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,28 +1,32 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -projection.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "projection_impl.hh" │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +areawriter.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "areawriter_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... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Projection<_Coordinate_>::EdgeIntersection │ │ │ │ │ -  Intersection between two edges of a triangle. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +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) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::write_glue_areas_vtk (const Glue &glue, const std::string │ │ │ │ │ + &base) │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00038_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projection.hh Source File │ │ │ │ +dune-grid-glue: areawriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,137 +74,47 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
projection.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#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH
│ │ │ │
5
│ │ │ │ -
6#include <array>
│ │ │ │ -
7#include <bitset>
│ │ │ │ -
8#include <tuple>
│ │ │ │ -
9
│ │ │ │ -
10namespace Dune {
│ │ │ │ -
11namespace GridGlue {
│ │ │ │ -
12
│ │ │ │ -
19template<typename Coordinate>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
21{
│ │ │ │ -
22public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
29 {
│ │ │ │ -
33 std::array<unsigned, 2> edge;
│ │ │ │ -
34
│ │ │ │ -
41 std::array<Coordinate, 2> local;
│ │ │ │ -
42 };
│ │ │ │ -
│ │ │ │ -
43
│ │ │ │ -
47 constexpr static unsigned dim = Coordinate::dimension;
│ │ │ │ -
48
│ │ │ │ -
54 constexpr static unsigned maxEdgeIntersections = dim == 3 ? 9 : 0;
│ │ │ │ -
55
│ │ │ │ -
56 static_assert(dim == 2 || dim == 3, "Projection only implemented for dim=2 or dim=3");
│ │ │ │ -
57
│ │ │ │ -
61 typedef typename Coordinate::field_type Field;
│ │ │ │ -
62
│ │ │ │ -
70 typedef std::array<Coordinate, dim> Images;
│ │ │ │ -
71
│ │ │ │ - │ │ │ │ -
79
│ │ │ │ -
80private:
│ │ │ │ -
84 const Field m_overlap;
│ │ │ │ -
85
│ │ │ │ -
94 const Field m_max_normal_product;
│ │ │ │ -
95
│ │ │ │ -
101 Field m_epsilon = Field(1e-12);
│ │ │ │ -
102
│ │ │ │ -
104 std::tuple<Images, Preimages> m_images;
│ │ │ │ -
105
│ │ │ │ -
107 std::tuple<std::bitset<dim>, std::bitset<dim> > m_success;
│ │ │ │ -
108
│ │ │ │ -
110 unsigned m_number_of_edge_intersections;
│ │ │ │ -
111
│ │ │ │ -
113 std::array<EdgeIntersection, maxEdgeIntersections> m_edge_intersections;
│ │ │ │ -
114
│ │ │ │ -
126 bool m_projection_valid;
│ │ │ │ -
127
│ │ │ │ -
133 template<typename Corners, typename Normals>
│ │ │ │ -
134 void doProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ -
135
│ │ │ │ -
144 template<typename Corners, typename Normals>
│ │ │ │ -
145 void doInverseProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ -
146
│ │ │ │ -
155 template<typename Corners, typename Normals>
│ │ │ │ -
156 void doEdgeIntersection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ -
157
│ │ │ │ -
183 template<typename Corners, typename Normals>
│ │ │ │ -
184 inline bool projectionFeasible(const Coordinate& x, const Coordinate& nx, const Coordinate& px, const Corners& corners, const Normals& normals) const;
│ │ │ │ -
185
│ │ │ │ -
186public:
│ │ │ │ -
191 Projection(const Field overlap = Field(0), const Field max_normal_product = Field(-0.1));
│ │ │ │ -
192
│ │ │ │ -
198 void epsilon(const Field epsilon);
│ │ │ │ -
199
│ │ │ │ -
212 template<typename Corners, typename Normals>
│ │ │ │ -
213 void project(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ -
214
│ │ │ │ -
│ │ │ │ -
235 const std::tuple<Images, Preimages>& images() const
│ │ │ │ -
236 { return m_images; }
│ │ │ │ -
│ │ │ │ -
237
│ │ │ │ -
│ │ │ │ -
252 const std::tuple<std::bitset<dim>, std::bitset<dim> >& success() const
│ │ │ │ -
253 { return m_success; }
│ │ │ │ -
│ │ │ │ -
254
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
263 { return m_number_of_edge_intersections; }
│ │ │ │ -
│ │ │ │ -
264
│ │ │ │ -
│ │ │ │ -
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"
│ │ │ │ -
281
│ │ │ │ -
282#endif
│ │ │ │ - │ │ │ │ +
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
│ │ │ │ + │ │ │ │
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
│ │ │ │ -
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
│ │ │ │ -
std::array< Coordinate, dim > Images
List of corner images.
Definition projection.hh:70
│ │ │ │ -
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
│ │ │ │ -
static constexpr unsigned dim
dimension of coordinates
Definition projection.hh:47
│ │ │ │ -
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
│ │ │ │ -
Intersection between two edges of a triangle.
Definition projection.hh:29
│ │ │ │ -
std::array< Coordinate, 2 > local
Local coordinates of intersection and distance along normals.
Definition projection.hh:41
│ │ │ │ -
std::array< unsigned, 2 > edge
Edge numbers in image and preimage triangle.
Definition projection.hh:33
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,175 +1,48 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projection.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#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH │ │ │ │ │ -4#define DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH │ │ │ │ │ +3#ifndef DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_COMMON_AREAWRITER_HH │ │ │ │ │ 5 │ │ │ │ │ -6#include │ │ │ │ │ -7#include │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10namespace Dune { │ │ │ │ │ -11namespace GridGlue { │ │ │ │ │ -12 │ │ │ │ │ -19template │ │ │ │ │ -20class Projection │ │ │ │ │ -21{ │ │ │ │ │ -22public: │ │ │ │ │ -28 struct EdgeIntersection │ │ │ │ │ -29 { │ │ │ │ │ -33 std::array edge; │ │ │ │ │ -34 │ │ │ │ │ -41 std::array local; │ │ │ │ │ -42 }; │ │ │ │ │ -43 │ │ │ │ │ -47 constexpr static unsigned dim = Coordinate::dimension; │ │ │ │ │ -48 │ │ │ │ │ -54 constexpr static unsigned maxEdgeIntersections = dim == 3 ? 9 : 0; │ │ │ │ │ -55 │ │ │ │ │ -56 static_assert(dim == 2 || dim == 3, "Projection only implemented for dim=2 │ │ │ │ │ -or dim=3"); │ │ │ │ │ -57 │ │ │ │ │ -61 typedef typename Coordinate::field_type Field; │ │ │ │ │ -62 │ │ │ │ │ -70 typedef std::array Images; │ │ │ │ │ -71 │ │ │ │ │ -78 typedef Images Preimages; │ │ │ │ │ -79 │ │ │ │ │ -80private: │ │ │ │ │ -84 const Field m_overlap; │ │ │ │ │ -85 │ │ │ │ │ -94 const Field m_max_normal_product; │ │ │ │ │ -95 │ │ │ │ │ -101 Field m_epsilon = Field(1e-12); │ │ │ │ │ -102 │ │ │ │ │ -104 std::tuple m_images; │ │ │ │ │ -105 │ │ │ │ │ -107 std::tuple, std::bitset > m_success; │ │ │ │ │ -108 │ │ │ │ │ -110 unsigned m_number_of_edge_intersections; │ │ │ │ │ -111 │ │ │ │ │ -113 std::array m_edge_intersections; │ │ │ │ │ -114 │ │ │ │ │ -126 bool m_projection_valid; │ │ │ │ │ -127 │ │ │ │ │ -133 template │ │ │ │ │ -134 void doProjection(const std::tuple& corners, const │ │ │ │ │ -std::tuple& normals); │ │ │ │ │ -135 │ │ │ │ │ -144 template │ │ │ │ │ -145 void doInverseProjection(const std::tuple& corners, │ │ │ │ │ -const std::tuple& normals); │ │ │ │ │ -146 │ │ │ │ │ -155 template │ │ │ │ │ -156 void doEdgeIntersection(const std::tuple& corners, │ │ │ │ │ -const std::tuple& normals); │ │ │ │ │ -157 │ │ │ │ │ -183 template │ │ │ │ │ -184 inline bool projectionFeasible(const Coordinate& x, const Coordinate& nx, │ │ │ │ │ -const Coordinate& px, const Corners& corners, const Normals& normals) const; │ │ │ │ │ -185 │ │ │ │ │ -186public: │ │ │ │ │ -191 Projection(const Field overlap = Field(0), const Field max_normal_product = │ │ │ │ │ -Field(-0.1)); │ │ │ │ │ -192 │ │ │ │ │ -198 void epsilon(const Field epsilon); │ │ │ │ │ -199 │ │ │ │ │ -212 template │ │ │ │ │ -213 void project(const std::tuple& corners, const std:: │ │ │ │ │ -tuple& normals); │ │ │ │ │ -214 │ │ │ │ │ -235 const std::tuple& images() const │ │ │ │ │ -236 { return m_images; } │ │ │ │ │ -237 │ │ │ │ │ -252 const std::tuple, std::bitset >& success() const │ │ │ │ │ -253 { return m_success; } │ │ │ │ │ -254 │ │ │ │ │ -262 unsigned numberOfEdgeIntersections() const │ │ │ │ │ -263 { return m_number_of_edge_intersections; } │ │ │ │ │ -264 │ │ │ │ │ -273 const std::array& edgeIntersections │ │ │ │ │ -() const │ │ │ │ │ -274 { return m_edge_intersections; } │ │ │ │ │ -275}; │ │ │ │ │ -276 │ │ │ │ │ -277} /* namespace GridGlue */ │ │ │ │ │ -278} /* namespace Dune */ │ │ │ │ │ -279 │ │ │ │ │ -280#include "projection_impl.hh" │ │ │ │ │ -281 │ │ │ │ │ -282#endif │ │ │ │ │ -projection_impl.hh │ │ │ │ │ +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 │ │ │ │ │ Dune │ │ │ │ │ Definition gridglue.hh:37 │ │ │ │ │ -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::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::maxEdgeIntersections │ │ │ │ │ -static constexpr unsigned maxEdgeIntersections │ │ │ │ │ -maximum number of edge-edge intersections │ │ │ │ │ -Definition projection.hh:54 │ │ │ │ │ -Dune::GridGlue::Projection::Preimages │ │ │ │ │ -Images Preimages │ │ │ │ │ -Definition projection.hh:78 │ │ │ │ │ -Dune::GridGlue::Projection::Images │ │ │ │ │ -std::array< Coordinate, dim > Images │ │ │ │ │ -List of corner images. │ │ │ │ │ -Definition projection.hh:70 │ │ │ │ │ -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::Projection::dim │ │ │ │ │ -static constexpr unsigned dim │ │ │ │ │ -dimension of coordinates │ │ │ │ │ -Definition projection.hh:47 │ │ │ │ │ -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::Projection::EdgeIntersection │ │ │ │ │ -Intersection between two edges of a triangle. │ │ │ │ │ -Definition projection.hh:29 │ │ │ │ │ -Dune::GridGlue::Projection::EdgeIntersection::local │ │ │ │ │ -std::array< Coordinate, 2 > local │ │ │ │ │ -Local coordinates of intersection and distance along normals. │ │ │ │ │ -Definition projection.hh:41 │ │ │ │ │ -Dune::GridGlue::Projection::EdgeIntersection::edge │ │ │ │ │ -std::array< unsigned, 2 > edge │ │ │ │ │ -Edge numbers in image and preimage triangle. │ │ │ │ │ -Definition projection.hh:33 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: crossproduct.hh File Reference │ │ │ │ +dune-grid-glue: projectionwriter.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,33 +72,45 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
crossproduct.hh File Reference
│ │ │ │ +
projectionwriter.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ +
#include <iostream>
│ │ │ │ +#include <string>
│ │ │ │ +#include <dune/grid-glue/common/projection.hh>
│ │ │ │ +#include "projectionwriter_impl.hh"
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

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

│ │ │ │ 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
 
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
 
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
 
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.
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,23 +2,36 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ Namespaces | Functions │ │ │ │ │ -crossproduct.hh File Reference │ │ │ │ │ +projectionwriter.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "projectionwriter_impl.hh" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ 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 │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals, std::ostream &out) │ │ │ │ │ +  write projection in VTK format │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ +  write projection in VTK format │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +void  Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ + Corners &corners, const Normals &normals) │ │ │ │ │ +  Print information about the projection to std::cout stream. │ │ │ │ │   │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00041_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: crossproduct.hh Source File │ │ │ │ +dune-grid-glue: projectionwriter.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,48 +74,57 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
crossproduct.hh
│ │ │ │ +
projectionwriter.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#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │
5
│ │ │ │ -
6namespace Dune {
│ │ │ │ -
7namespace GridGlue {
│ │ │ │ +
6#include <iostream>
│ │ │ │ +
7#include <string>
│ │ │ │
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
│ │ │ │ -
26 return c;
│ │ │ │ -
27}
│ │ │ │ -
│ │ │ │ -
28
│ │ │ │ -
29} /* namespace GridGlue */
│ │ │ │ -
30} /* namespace Dune */
│ │ │ │ -
31
│ │ │ │ -
32#endif
│ │ │ │ + │ │ │ │ +
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
│ │ │ │ + │ │ │ │ + │ │ │ │
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(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 {} │ │ │ │ │ @@ -1,49 +1,62 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -crossproduct.hh │ │ │ │ │ +projectionwriter.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#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ 5 │ │ │ │ │ -6namespace Dune { │ │ │ │ │ -7namespace GridGlue { │ │ │ │ │ +6#include │ │ │ │ │ +7#include │ │ │ │ │ 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 │ │ │ │ │ -26 return c; │ │ │ │ │ -27} │ │ │ │ │ -28 │ │ │ │ │ -29} /* namespace GridGlue */ │ │ │ │ │ -30} /* namespace Dune */ │ │ │ │ │ -31 │ │ │ │ │ -32#endif │ │ │ │ │ +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 │ │ │ │ │ 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 │ │ │ │ │ +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 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter_impl.hh File Reference │ │ │ │ +dune-grid-glue: crossproduct.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,56 +70,35 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
areawriter_impl.hh File Reference
│ │ │ │ +
crossproduct.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<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<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
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,43 +1,24 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -areawriter_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +crossproduct.hh File Reference │ │ │ │ │ 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 │ │ │ │ │ -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 │ │ │ │ │ +static Dune::FieldVector< T, dim >  Dune::GridGlue::crossProduct (const Dune:: │ │ │ │ │ + FieldVector< T, dim > &a, const Dune:: │ │ │ │ │ + FieldVector< T, dim > &b) │ │ │ │ │ +  compute cross product │ │ │ │ │   │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00044_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: areawriter_impl.hh Source File │ │ │ │ +dune-grid-glue: crossproduct.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,183 +74,48 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
areawriter_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#include <vector>
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1
│ │ │ │
5
│ │ │ │ -
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>
│ │ │ │ -
│ │ │ │ - │ │ │ │ +
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 bool contains(Dune::GeometryType gt) const
│ │ │ │ -
19 {
│ │ │ │ -
20 return gt.dim() == dimgrid - 1;
│ │ │ │ -
21 }
│ │ │ │ +
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}
│ │ │ │
│ │ │ │ -
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";
│ │ │ │ -
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 */
│ │ │ │ +
29} /* namespace GridGlue */
│ │ │ │ +
30} /* namespace Dune */
│ │ │ │ +
31
│ │ │ │ +
32#endif
│ │ │ │
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
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,184 +1,49 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -areawriter_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#include │ │ │ │ │ +3#ifndef DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_COMMON_CROSSPRODUCT_HH 1 │ │ │ │ │ 5 │ │ │ │ │ -6#include │ │ │ │ │ -7#include │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10namespace Dune { │ │ │ │ │ -11namespace GridGlue { │ │ │ │ │ -12 │ │ │ │ │ -13namespace AreaWriterImplementation { │ │ │ │ │ -14 │ │ │ │ │ -15template │ │ │ │ │ -16struct FacetLayout │ │ │ │ │ +6namespace Dune { │ │ │ │ │ +7namespace GridGlue { │ │ │ │ │ +8 │ │ │ │ │ +14template │ │ │ │ │ +15static Dune::FieldVector crossProduct(const Dune::FieldVector& │ │ │ │ │ +a, │ │ │ │ │ +16 const Dune::FieldVector& b) │ │ │ │ │ 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; │ │ │ │ │ +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} │ │ │ │ │ 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"; │ │ │ │ │ -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 */ │ │ │ │ │ +29} /* namespace GridGlue */ │ │ │ │ │ +30} /* namespace Dune */ │ │ │ │ │ +31 │ │ │ │ │ +32#endif │ │ │ │ │ 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::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.8 │ │ │ ├── ./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: projection.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,49 +70,41 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
projection_impl.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
projection.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <cmath>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <bitset>
│ │ │ │ +#include <tuple>
│ │ │ │ +#include "projection_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...
 
struct  Dune::GridGlue::Projection< Coordinate >::EdgeIntersection
 Intersection between two edges of a triangle. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ 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)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,44 +1,28 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -projection_impl.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +projection.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "projection_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... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Projection<_Coordinate_>::EdgeIntersection │ │ │ │ │ +  Intersection between two edges of a triangle. More... │ │ │ │ │ +  │ │ │ │ │ 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 │ │ │ │ │ - bool  Dune::GridGlue::ProjectionImplementation:: │ │ │ │ │ - inside (const Coordinate &x, const Field │ │ │ │ │ - &epsilon) │ │ │ │ │ -  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./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: projection.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,464 +74,137 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
projection_impl.hh
│ │ │ │ +
projection.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 {
│ │ │ │ +
3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH
│ │ │ │ +
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH
│ │ │ │ +
5
│ │ │ │ +
6#include <array>
│ │ │ │ +
7#include <bitset>
│ │ │ │ +
8#include <tuple>
│ │ │ │
9
│ │ │ │ -
│ │ │ │ -
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 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}
│ │ │ │ +
10namespace Dune {
│ │ │ │ +
11namespace GridGlue {
│ │ │ │ +
12
│ │ │ │ +
19template<typename Coordinate>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
21{
│ │ │ │ +
22public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
29 {
│ │ │ │ +
33 std::array<unsigned, 2> edge;
│ │ │ │ +
34
│ │ │ │ +
41 std::array<Coordinate, 2> local;
│ │ │ │ +
42 };
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │ +
47 constexpr static unsigned dim = Coordinate::dimension;
│ │ │ │ +
48
│ │ │ │ +
54 constexpr static unsigned maxEdgeIntersections = dim == 3 ? 9 : 0;
│ │ │ │ +
55
│ │ │ │ +
56 static_assert(dim == 2 || dim == 3, "Projection only implemented for dim=2 or dim=3");
│ │ │ │ +
57
│ │ │ │ +
61 typedef typename Coordinate::field_type Field;
│ │ │ │ +
62
│ │ │ │ +
70 typedef std::array<Coordinate, dim> Images;
│ │ │ │ +
71
│ │ │ │ + │ │ │ │ +
79
│ │ │ │ +
80private:
│ │ │ │ +
84 const Field m_overlap;
│ │ │ │ +
85
│ │ │ │ +
94 const Field m_max_normal_product;
│ │ │ │ +
95
│ │ │ │ +
101 Field m_epsilon = Field(1e-12);
│ │ │ │ +
102
│ │ │ │ +
104 std::tuple<Images, Preimages> m_images;
│ │ │ │ +
105
│ │ │ │ +
107 std::tuple<std::bitset<dim>, std::bitset<dim> > m_success;
│ │ │ │ +
108
│ │ │ │ +
110 unsigned m_number_of_edge_intersections;
│ │ │ │ +
111
│ │ │ │ +
113 std::array<EdgeIntersection, maxEdgeIntersections> m_edge_intersections;
│ │ │ │ +
114
│ │ │ │ +
126 bool m_projection_valid;
│ │ │ │ +
127
│ │ │ │ +
133 template<typename Corners, typename Normals>
│ │ │ │ +
134 void doProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ +
135
│ │ │ │ +
144 template<typename Corners, typename Normals>
│ │ │ │ +
145 void doInverseProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ +
146
│ │ │ │ +
155 template<typename Corners, typename Normals>
│ │ │ │ +
156 void doEdgeIntersection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ +
157
│ │ │ │ +
183 template<typename Corners, typename Normals>
│ │ │ │ +
184 inline bool projectionFeasible(const Coordinate& x, const Coordinate& nx, const Coordinate& px, const Corners& corners, const Normals& normals) const;
│ │ │ │ +
185
│ │ │ │ +
186public:
│ │ │ │ +
191 Projection(const Field overlap = Field(0), const Field max_normal_product = Field(-0.1));
│ │ │ │ +
192
│ │ │ │ +
198 void epsilon(const Field epsilon);
│ │ │ │ +
199
│ │ │ │ +
212 template<typename Corners, typename Normals>
│ │ │ │ +
213 void project(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
│ │ │ │ +
214
│ │ │ │ +
│ │ │ │ +
235 const std::tuple<Images, Preimages>& images() const
│ │ │ │ +
236 { return m_images; }
│ │ │ │ +
│ │ │ │ +
237
│ │ │ │ +
│ │ │ │ +
252 const std::tuple<std::bitset<dim>, std::bitset<dim> >& success() const
│ │ │ │ +
253 { return m_success; }
│ │ │ │ +
│ │ │ │ +
254
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
263 { return m_number_of_edge_intersections; }
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
│ │ │ │ +
273 const std::array<EdgeIntersection, maxEdgeIntersections>& edgeIntersections() const
│ │ │ │ +
274 { return m_edge_intersections; }
│ │ │ │
│ │ │ │ -
125
│ │ │ │ -
126} /* namespace ProjectionImplementation */
│ │ │ │ +
275};
│ │ │ │
│ │ │ │ -
127
│ │ │ │ -
128template<typename Coordinate>
│ │ │ │ -
129Projection<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>
│ │ │ │ -
468void Projection<Coordinate>
│ │ │ │ -
│ │ │ │ -
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 */
│ │ │ │ +
277} /* namespace GridGlue */
│ │ │ │ +
278} /* namespace Dune */
│ │ │ │ +
279
│ │ │ │ +
280#include "projection_impl.hh"
│ │ │ │ +
281
│ │ │ │ +
282#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
│ │ │ │ +
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
│ │ │ │ +
std::array< Coordinate, dim > Images
List of corner images.
Definition projection.hh:70
│ │ │ │ +
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
│ │ │ │ +
static constexpr unsigned dim
dimension of coordinates
Definition projection.hh:47
│ │ │ │ +
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
│ │ │ │ +
Intersection between two edges of a triangle.
Definition projection.hh:29
│ │ │ │ +
std::array< Coordinate, 2 > local
Local coordinates of intersection and distance along normals.
Definition projection.hh:41
│ │ │ │ +
std::array< unsigned, 2 > edge
Edge numbers in image and preimage triangle.
Definition projection.hh:33
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,480 +1,175 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projection_impl.hh │ │ │ │ │ +projection.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 { │ │ │ │ │ +3#ifndef DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH │ │ │ │ │ +4#define DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH │ │ │ │ │ +5 │ │ │ │ │ +6#include │ │ │ │ │ +7#include │ │ │ │ │ +8#include │ │ │ │ │ 9 │ │ │ │ │ -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 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 */ │ │ │ │ │ +10namespace Dune { │ │ │ │ │ +11namespace GridGlue { │ │ │ │ │ +12 │ │ │ │ │ +19template │ │ │ │ │ +20class Projection │ │ │ │ │ +21{ │ │ │ │ │ +22public: │ │ │ │ │ +28 struct EdgeIntersection │ │ │ │ │ +29 { │ │ │ │ │ +33 std::array edge; │ │ │ │ │ +34 │ │ │ │ │ +41 std::array local; │ │ │ │ │ +42 }; │ │ │ │ │ +43 │ │ │ │ │ +47 constexpr static unsigned dim = Coordinate::dimension; │ │ │ │ │ +48 │ │ │ │ │ +54 constexpr static unsigned maxEdgeIntersections = dim == 3 ? 9 : 0; │ │ │ │ │ +55 │ │ │ │ │ +56 static_assert(dim == 2 || dim == 3, "Projection only implemented for dim=2 │ │ │ │ │ +or dim=3"); │ │ │ │ │ +57 │ │ │ │ │ +61 typedef typename Coordinate::field_type Field; │ │ │ │ │ +62 │ │ │ │ │ +70 typedef std::array Images; │ │ │ │ │ +71 │ │ │ │ │ +78 typedef Images Preimages; │ │ │ │ │ +79 │ │ │ │ │ +80private: │ │ │ │ │ +84 const Field m_overlap; │ │ │ │ │ +85 │ │ │ │ │ +94 const Field m_max_normal_product; │ │ │ │ │ +95 │ │ │ │ │ +101 Field m_epsilon = Field(1e-12); │ │ │ │ │ +102 │ │ │ │ │ +104 std::tuple m_images; │ │ │ │ │ +105 │ │ │ │ │ +107 std::tuple, std::bitset > m_success; │ │ │ │ │ +108 │ │ │ │ │ +110 unsigned m_number_of_edge_intersections; │ │ │ │ │ +111 │ │ │ │ │ +113 std::array m_edge_intersections; │ │ │ │ │ +114 │ │ │ │ │ +126 bool m_projection_valid; │ │ │ │ │ 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 } │ │ │ │ │ +133 template │ │ │ │ │ +134 void doProjection(const std::tuple& corners, const │ │ │ │ │ +std::tuple& normals); │ │ │ │ │ +135 │ │ │ │ │ +144 template │ │ │ │ │ +145 void doInverseProjection(const std::tuple& corners, │ │ │ │ │ +const std::tuple& normals); │ │ │ │ │ +146 │ │ │ │ │ +155 template │ │ │ │ │ +156 void doEdgeIntersection(const std::tuple& corners, │ │ │ │ │ +const std::tuple& normals); │ │ │ │ │ +157 │ │ │ │ │ +183 template │ │ │ │ │ +184 inline bool projectionFeasible(const Coordinate& x, const Coordinate& nx, │ │ │ │ │ +const Coordinate& px, const Corners& corners, const Normals& normals) const; │ │ │ │ │ +185 │ │ │ │ │ +186public: │ │ │ │ │ +191 Projection(const Field overlap = Field(0), const Field max_normal_product = │ │ │ │ │ +Field(-0.1)); │ │ │ │ │ +192 │ │ │ │ │ +198 void epsilon(const Field epsilon); │ │ │ │ │ +199 │ │ │ │ │ +212 template │ │ │ │ │ +213 void project(const std::tuple& corners, const std:: │ │ │ │ │ +tuple& normals); │ │ │ │ │ +214 │ │ │ │ │ +235 const std::tuple& images() const │ │ │ │ │ +236 { return m_images; } │ │ │ │ │ +237 │ │ │ │ │ +252 const std::tuple, std::bitset >& success() const │ │ │ │ │ +253 { return m_success; } │ │ │ │ │ +254 │ │ │ │ │ +262 unsigned numberOfEdgeIntersections() const │ │ │ │ │ +263 { return m_number_of_edge_intersections; } │ │ │ │ │ +264 │ │ │ │ │ +273 const std::array& edgeIntersections │ │ │ │ │ +() const │ │ │ │ │ +274 { return m_edge_intersections; } │ │ │ │ │ +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 */ │ │ │ │ │ +277} /* namespace GridGlue */ │ │ │ │ │ +278} /* namespace Dune */ │ │ │ │ │ +279 │ │ │ │ │ +280#include "projection_impl.hh" │ │ │ │ │ +281 │ │ │ │ │ +282#endif │ │ │ │ │ +projection_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::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::maxEdgeIntersections │ │ │ │ │ +static constexpr unsigned maxEdgeIntersections │ │ │ │ │ +maximum number of edge-edge intersections │ │ │ │ │ +Definition projection.hh:54 │ │ │ │ │ +Dune::GridGlue::Projection::Preimages │ │ │ │ │ +Images Preimages │ │ │ │ │ +Definition projection.hh:78 │ │ │ │ │ +Dune::GridGlue::Projection::Images │ │ │ │ │ +std::array< Coordinate, dim > Images │ │ │ │ │ +List of corner images. │ │ │ │ │ +Definition projection.hh:70 │ │ │ │ │ +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::Projection::dim │ │ │ │ │ +static constexpr unsigned dim │ │ │ │ │ +dimension of coordinates │ │ │ │ │ +Definition projection.hh:47 │ │ │ │ │ +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::Projection::EdgeIntersection │ │ │ │ │ +Intersection between two edges of a triangle. │ │ │ │ │ +Definition projection.hh:29 │ │ │ │ │ +Dune::GridGlue::Projection::EdgeIntersection::local │ │ │ │ │ +std::array< Coordinate, 2 > local │ │ │ │ │ +Local coordinates of intersection and distance along normals. │ │ │ │ │ +Definition projection.hh:41 │ │ │ │ │ +Dune::GridGlue::Projection::EdgeIntersection::edge │ │ │ │ │ +std::array< unsigned, 2 > edge │ │ │ │ │ +Edge numbers in image and preimage triangle. │ │ │ │ │ +Definition projection.hh:33 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00050.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: projectionwriter.hh File Reference │ │ │ │ +dune-grid-glue: areawriter_impl.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,47 +70,56 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
projectionwriter.hh File Reference
│ │ │ │ +
areawriter_impl.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <string>
│ │ │ │ -#include <dune/grid-glue/common/projection.hh>
│ │ │ │ -#include "projectionwriter_impl.hh"
│ │ │ │ +
#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<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
 
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
 
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.
 
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 {} │ │ │ │ │ @@ -1,37 +1,43 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -projectionwriter.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "projectionwriter_impl.hh" │ │ │ │ │ +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 │ │ │ │ │ -void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals, std::ostream &out) │ │ │ │ │ -  write projection in VTK format │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::GridGlue::write (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals, const std::string &filename) │ │ │ │ │ -  write projection in VTK format │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::GridGlue::print (const Projection< Coordinate > &projection, const │ │ │ │ │ - Corners &corners, const Normals &normals) │ │ │ │ │ -  Print information about the projection to std::cout stream. │ │ │ │ │ +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.8 │ │ │ ├── ./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: areawriter_impl.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,57 +74,183 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
projectionwriter.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_PROJECTIONWRITER_HH
│ │ │ │ -
4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH
│ │ │ │ +
3#include <fstream>
│ │ │ │ +
4#include <vector>
│ │ │ │
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
│ │ │ │ - │ │ │ │ - │ │ │ │ +
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 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";
│ │ │ │ +
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
│ │ │ │ -
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
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,62 +1,184 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * common │ │ │ │ │ -projectionwriter.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_PROJECTIONWRITER_HH │ │ │ │ │ -4#define DUNE_GRIDGLUE_COMMON_PROJECTIONWRITER_HH │ │ │ │ │ +3#include │ │ │ │ │ +4#include │ │ │ │ │ 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 │ │ │ │ │ +6#include │ │ │ │ │ +7#include │ │ │ │ │ +8#include │ │ │ │ │ +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"; │ │ │ │ │ +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::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::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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00053.html │ │ │ │ @@ -82,15 +82,15 @@ │ │ │ │ │ │ │ │

helper class for graphical output of grids in generic representation │ │ │ │ More...

│ │ │ │
#include <fstream>
│ │ │ │ #include <iomanip>
│ │ │ │ #include <vector>
│ │ │ │ #include <cstring>
│ │ │ │ -#include "../adapter/gridgluevtkwriter.hh"
│ │ │ │ +#include "../adapter/gridgluevtkwriter.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: extractor.hh File Reference │ │ │ │ +dune-grid-glue: codim1extractor.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,62 +72,44 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
extractor.hh File Reference
│ │ │ │ +
codim1extractor.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

extractor base class │ │ │ │ +

Grid extractor class for codim 1 subgrids. │ │ │ │ More...

│ │ │ │ -
#include <vector>
│ │ │ │ -#include <map>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/fvector.hh>
│ │ │ │ +
#include "extractor.hh"
│ │ │ │ +#include <array>
│ │ │ │ +#include <deque>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <dune/common/deprecated.hh>
│ │ │ │ #include <dune/common/version.hh>
│ │ │ │ -#include <dune/grid/common/geometry.hh>
│ │ │ │ -#include <dune/grid/common/grid.hh>
│ │ │ │ -#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ -#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ +#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::VtkSurfaceWriter
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::Extractor< GV, cd >
 Provides codimension-independent methods for grid extraction. More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::CornerInfo
 Helpful struct holding one index for the coordinate (vertex) to which it is associated and the element's corner index;. More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::CoordinateInfo
 
struct  Dune::GridGlue::Extractor< GV, cd >::VertexInfo
 simple struct holding a vertex pointer and an index More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::ElementInfo
 simple struct holding an element seed and an index More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::SubEntityInfo
 Holds some information about an element's subentity involved in a coupling. More...
class  Dune::GridGlue::Codim1Extractor< GV >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │

Detailed Description

│ │ │ │ -

extractor base class

│ │ │ │ +

Grid extractor class for codim 1 subgrids.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,49 +2,29 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * extractors │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -extractor.hh File Reference │ │ │ │ │ -extractor base class More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +codim1extractor.hh File Reference │ │ │ │ │ +Grid extractor class for codim 1 subgrids. More... │ │ │ │ │ +#include "extractor.hh" │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::GridGlue::Extractor<_GV,_cd_> │ │ │ │ │ -  Provides codimension-independent methods for grid extraction. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Extractor<_GV,_cd_>::CornerInfo │ │ │ │ │ -  Helpful struct holding one index for the coordinate (vertex) to which │ │ │ │ │ - it is associated and the element's corner index;. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Extractor<_GV,_cd_>::CoordinateInfo │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Extractor<_GV,_cd_>::VertexInfo │ │ │ │ │ -  simple struct holding a vertex pointer and an index More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Extractor<_GV,_cd_>::ElementInfo │ │ │ │ │ -  simple struct holding an element seed and an index More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::GridGlue::Extractor<_GV,_cd_>::SubEntityInfo │ │ │ │ │ -  Holds some information about an element's subentity involved in a │ │ │ │ │ - coupling. More... │ │ │ │ │ +class   Dune::GridGlue::Codim1Extractor<_GV_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -extractor base class │ │ │ │ │ +Grid extractor class for codim 1 subgrids. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00056_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: extractor.hh Source File │ │ │ │ +dune-grid-glue: codim1extractor.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,471 +74,400 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
extractor.hh
│ │ │ │ +
codim1extractor.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/*
│ │ │ │ -
6 * Filename: extractor.hh
│ │ │ │ +
6 * Filename: codim1extractor.hh
│ │ │ │
7 * Version: 1.0
│ │ │ │ -
8 * Created on: Oct 05, 2009
│ │ │ │ -
9 * Author: Christian Engwer
│ │ │ │ +
8 * Created on: Jun 23, 2009
│ │ │ │ +
9 * Author: Oliver Sander, Christian Engwer
│ │ │ │
10 * ---------------------------------
│ │ │ │
11 * Project: dune-grid-glue
│ │ │ │ -
12 * Description: base class for all grid extractors
│ │ │ │ +
12 * Description: class for grid extractors extracting surface grids
│ │ │ │
13 *
│ │ │ │
14 */
│ │ │ │ -
20#ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │ -
21#define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │ +
20#ifndef DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │ +
21#define DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │
22
│ │ │ │ -
23#include <vector>
│ │ │ │ -
24#include <map>
│ │ │ │ -
25#include <algorithm>
│ │ │ │ -
26#include <dune/common/exceptions.hh>
│ │ │ │ -
27#include <dune/common/fvector.hh>
│ │ │ │ -
28#include <dune/common/version.hh>
│ │ │ │ -
29#include <dune/grid/common/geometry.hh>
│ │ │ │ -
30#include <dune/grid/common/grid.hh>
│ │ │ │ -
31#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ -
32#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ -
33
│ │ │ │ -
34namespace Dune {
│ │ │ │ -
35
│ │ │ │ -
36 namespace GridGlue {
│ │ │ │ -
37
│ │ │ │ -
44template<typename GV, int cd>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
46{
│ │ │ │ -
47
│ │ │ │ -
48public:
│ │ │ │ -
49
│ │ │ │ -
50 static constexpr auto dimworld = GV::dimensionworld;
│ │ │ │ -
51 static constexpr auto dim = GV::dimension;
│ │ │ │ -
52 static constexpr auto codim = cd;
│ │ │ │ -
53
│ │ │ │ -
54 static constexpr int cube_corners = 1 << (dim-codim);
│ │ │ │ +
23#include "extractor.hh"
│ │ │ │ +
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>
│ │ │ │ +
42{
│ │ │ │ +
43public:
│ │ │ │ +
44
│ │ │ │ +
45 /* 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 */
│ │ │ │ +
46
│ │ │ │ +
47 using Extractor<GV,1>::dimworld;
│ │ │ │ +
48 using Extractor<GV,1>::dim;
│ │ │ │ +
49 using Extractor<GV,1>::codim;
│ │ │ │ +
50 using Extractor<GV,1>::cube_corners;
│ │ │ │ + │ │ │ │ +
52
│ │ │ │ +
54 static constexpr int simplex_corners = dim;
│ │ │ │
55
│ │ │ │ -
56 typedef GV GridView;
│ │ │ │ -
57 typedef typename GridView::Grid Grid;
│ │ │ │ -
58
│ │ │ │ -
59 typedef typename GV::Grid::ctype ctype;
│ │ │ │ -
60 typedef Dune::FieldVector<ctype, dimworld> Coords;
│ │ │ │ -
61 typedef Dune::FieldVector<ctype, dim> LocalCoords;
│ │ │ │ -
62
│ │ │ │ -
63 typedef typename GV::Traits::template Codim<dim>::Entity Vertex;
│ │ │ │ -
64 typedef typename Vertex::EntitySeed VertexSeed;
│ │ │ │ -
65
│ │ │ │ -
66 typedef typename GV::Traits::template Codim<0>::Entity Element;
│ │ │ │ -
67 typedef typename Element::EntitySeed ElementSeed;
│ │ │ │ -
68
│ │ │ │ -
69 typedef std::vector<unsigned int> VertexVector;
│ │ │ │ -
70 using CellMapper = MultipleCodimMultipleGeomTypeMapper<GridView>;
│ │ │ │ +
56 typedef GV GridView;
│ │ │ │ +
57
│ │ │ │ +
58 typedef typename GV::Grid::ctype ctype;
│ │ │ │ +
59 typedef Dune::FieldVector<ctype, dimworld> Coords;
│ │ │ │ +
60
│ │ │ │ +
61 typedef typename GV::Traits::template Codim<dim>::Entity Vertex;
│ │ │ │ +
62 typedef typename GV::Traits::template Codim<0>::Entity Element;
│ │ │ │ +
63 typedef std::function<bool(const Element&, unsigned int subentity)> Predicate;
│ │ │ │ +
64
│ │ │ │ +
65 // import typedefs from base class
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
71
│ │ │ │ -
72 // typedef typename CellMapper::IndexType IndexType;
│ │ │ │ -
73 typedef int IndexType;
│ │ │ │ -
74public:
│ │ │ │ +
72public:
│ │ │ │ +
73
│ │ │ │ +
74 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */
│ │ │ │
75
│ │ │ │ -
76 // transformations
│ │ │ │ -
77 typedef Dune::MultiLinearGeometry<ctype, dim-codim, dimworld> Geometry;
│ │ │ │ -
78 typedef Dune::MultiLinearGeometry<ctype, dim-codim, dim> LocalGeometry;
│ │ │ │ -
79
│ │ │ │ -
80protected:
│ │ │ │ -
81 /************************** PRIVATE SUBCLASSES **********************/
│ │ │ │ -
82
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
88 {
│ │ │ │ -
89 unsigned int idx : 28;
│ │ │ │ -
90 unsigned int num : 4;
│ │ │ │ -
91 };
│ │ │ │ -
│ │ │ │ -
92
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
94 {
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
96 {}
│ │ │ │ -
│ │ │ │ -
97
│ │ │ │ -
│ │ │ │ -
98 CoordinateInfo(unsigned int index_, IndexType vtxindex_)
│ │ │ │ -
99 : vtxindex(vtxindex_), index(index_)
│ │ │ │ -
100 {}
│ │ │ │ -
│ │ │ │ -
101
│ │ │ │ - │ │ │ │ -
104
│ │ │ │ - │ │ │ │ -
107
│ │ │ │ -
109 unsigned int index;
│ │ │ │ -
110 };
│ │ │ │ -
│ │ │ │ -
111
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
116 {
│ │ │ │ -
│ │ │ │ -
117 VertexInfo(unsigned int idx_, const Vertex& p_) : idx(idx_), p(p_.seed())
│ │ │ │ -
118 {}
│ │ │ │ -
│ │ │ │ -
119 unsigned int idx;
│ │ │ │ - │ │ │ │ -
121 };
│ │ │ │ -
│ │ │ │ -
122
│ │ │ │ -
123
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
128 {
│ │ │ │ -
│ │ │ │ -
129 ElementInfo(unsigned int idx_, const Element& p_, unsigned int f_) : idx(idx_), faces(f_), p(p_.seed())
│ │ │ │ -
130 {}
│ │ │ │ -
│ │ │ │ -
131
│ │ │ │ -
133 unsigned int idx : 28;
│ │ │ │ -
134
│ │ │ │ -
136 unsigned int faces : 4;
│ │ │ │ +
│ │ │ │ +
81 Codim1Extractor(const GV& gv, const Predicate& predicate)
│ │ │ │ +
82 : Extractor<GV,1>(gv)
│ │ │ │ +
83 {
│ │ │ │ +
84 std::cout << "This is Codim1Extractor on a <" << dim
│ │ │ │ +
85 << "," << dimworld << "> grid!"
│ │ │ │ +
86 << std::endl;
│ │ │ │ +
87 update(predicate);
│ │ │ │ +
88 }
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
90private:
│ │ │ │ +
91
│ │ │ │ +
105 void update(const Predicate& predicate);
│ │ │ │ +
106
│ │ │ │ +
107};
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
109
│ │ │ │ +
110template<typename GV>
│ │ │ │ +
111void Codim1Extractor<GV>::update(const Predicate& predicate)
│ │ │ │ +
112{
│ │ │ │ +
113 // free everything there is in this object
│ │ │ │ +
114 this->clear();
│ │ │ │ +
115
│ │ │ │ +
116 // In this first pass iterate over all entities of codim 0.
│ │ │ │ +
117 // For each codim 1 intersection check if it is part of the boundary and if so,
│ │ │ │ +
118 // get its corner vertices, find resp. store them together with their associated index,
│ │ │ │ +
119 // and remember the indices of the boundary faces' corners.
│ │ │ │ +
120 {
│ │ │ │ +
121 // several counter for consecutive indexing are needed
│ │ │ │ +
122 int simplex_index = 0;
│ │ │ │ +
123 int vertex_index = 0;
│ │ │ │ +
124 IndexType eindex = 0; // suppress warning
│ │ │ │ +
125
│ │ │ │ +
126 // needed later for insertion into a std::set which only
│ │ │ │ +
127 // works with const references
│ │ │ │ +
128
│ │ │ │ +
129 // a temporary container where newly acquired face
│ │ │ │ +
130 // information can be stored at first
│ │ │ │ +
131 std::deque<SubEntityInfo> temp_faces;
│ │ │ │ +
132
│ │ │ │ +
133 // iterate over interior codim 0 elements on the grid
│ │ │ │ +
134 for (const auto& elmt : elements(this->gv_, Partitions::interior))
│ │ │ │ +
135 {
│ │ │ │ +
136 Dune::GeometryType gt = elmt.type();
│ │ │ │
137
│ │ │ │ - │ │ │ │ -
140 };
│ │ │ │ -
│ │ │ │ -
141
│ │ │ │ -
142
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
147 {
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
149 /*
│ │ │ │ -
150 * TODO: move default value of `geometryType_` to member declaration
│ │ │ │ -
151 * when removing support for older dune-geometry
│ │ │ │ -
152 */
│ │ │ │ -
153 : geometryType_(GeometryTypes::simplex(dim-codim))
│ │ │ │ -
154 {}
│ │ │ │ -
│ │ │ │ -
155
│ │ │ │ -
│ │ │ │ -
156 SubEntityInfo(IndexType parent_, unsigned int num_in_parent_,
│ │ │ │ -
157 const Dune::GeometryType& geometryType)
│ │ │ │ -
158 : parent(parent_), num_in_parent(num_in_parent_), geometryType_(geometryType)
│ │ │ │ -
159 {}
│ │ │ │ -
│ │ │ │ -
160
│ │ │ │ -
│ │ │ │ -
161 unsigned int nCorners() const
│ │ │ │ -
162 {
│ │ │ │ -
163 return Dune::ReferenceElements<ctype, dim-codim>::general(geometryType_).size(dim-codim);
│ │ │ │ -
164 }
│ │ │ │ -
│ │ │ │ -
165
│ │ │ │ - │ │ │ │ -
168
│ │ │ │ -
170 unsigned int num_in_parent : 3;
│ │ │ │ -
171
│ │ │ │ -
173 Dune::GeometryType geometryType_;
│ │ │ │ -
174
│ │ │ │ -
181 CornerInfo corners[cube_corners]; // sim = number of vertices in a simplex
│ │ │ │ -
182 };
│ │ │ │ -
│ │ │ │ -
183
│ │ │ │ -
184
│ │ │ │ -
185 typedef std::map<IndexType, ElementInfo> ElementInfoMap;
│ │ │ │ -
186 typedef std::map<IndexType, VertexInfo> VertexInfoMap;
│ │ │ │ +
138 // if some face is part of the surface add it!
│ │ │ │ +
139 if (elmt.hasBoundaryIntersections())
│ │ │ │ +
140 {
│ │ │ │ +
141 // add an entry to the element info map, the index will be set properly later,
│ │ │ │ +
142 // whereas the number of faces is already known
│ │ │ │ +
143 eindex = this->cellMapper_.index(elmt);
│ │ │ │ +
144 this->elmtInfo_.emplace(eindex, ElementInfo(simplex_index, elmt, 0));
│ │ │ │ +
145
│ │ │ │ +
146 // now add the faces in ascending order of their indices
│ │ │ │ +
147 // (we are only talking about 1-4 faces here, so O(n^2) is ok!)
│ │ │ │ +
148 for (const auto& in : intersections(this->gv_, elmt))
│ │ │ │ +
149 {
│ │ │ │ +
150 // Stop only at selected boundary faces
│ │ │ │ +
151 if (!in.boundary() or !predicate(elmt, in.indexInInside()))
│ │ │ │ +
152 continue;
│ │ │ │ +
153
│ │ │ │ +
154 const auto& refElement = Dune::ReferenceElements<ctype, dim>::general(gt);
│ │ │ │ +
155 // get the corner count of this face
│ │ │ │ +
156 const int face_corners = refElement.size(in.indexInInside(), 1, dim);
│ │ │ │ +
157
│ │ │ │ +
158 // now we only have to care about the 3D case, i.e. a triangle face can be
│ │ │ │ +
159 // inserted directly whereas a quadrilateral face has to be divided into two triangles
│ │ │ │ +
160 switch (face_corners)
│ │ │ │ +
161 {
│ │ │ │ +
162 case 2 :
│ │ │ │ +
163 case 3:
│ │ │ │ +
164 {
│ │ │ │ +
165 // we have a simplex here
│ │ │ │ +
166
│ │ │ │ +
167 // register the additional face(s)
│ │ │ │ +
168 this->elmtInfo_.at(eindex).faces++;
│ │ │ │ +
169
│ │ │ │ +
170 // add a new face to the temporary collection
│ │ │ │ +
171 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ +
172 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ +
173
│ │ │ │ +
174 std::vector<FieldVector<ctype,dimworld> > cornerCoords(face_corners);
│ │ │ │ +
175
│ │ │ │ +
176 // try for each of the faces vertices whether it is already inserted or not
│ │ │ │ +
177 for (int i = 0; i < face_corners; ++i)
│ │ │ │ +
178 {
│ │ │ │ +
179 // get the number of the vertex in the parent element
│ │ │ │ +
180 int vertex_number = refElement.subEntity(in.indexInInside(), 1, i, dim);
│ │ │ │ +
181
│ │ │ │ +
182 // get the vertex pointer and the index from the index set
│ │ │ │ +
183 const Vertex vertex = elmt.template subEntity<dim>(vertex_number);
│ │ │ │ +
184 cornerCoords[i] = vertex.geometry().corner(0);
│ │ │ │ +
185
│ │ │ │ +
186 IndexType vindex = this->gv_.indexSet().template index<dim>(vertex);
│ │ │ │
187
│ │ │ │ -
188 /************************** MEMBER VARIABLES ************************/
│ │ │ │ -
189
│ │ │ │ - │ │ │ │ -
192
│ │ │ │ -
193 /* Geometrical and Topological Information */
│ │ │ │ -
194
│ │ │ │ -
196 std::vector<CoordinateInfo> coords_;
│ │ │ │ -
197
│ │ │ │ -
199 std::vector<SubEntityInfo> subEntities_;
│ │ │ │ -
200
│ │ │ │ - │ │ │ │ -
207
│ │ │ │ - │ │ │ │ -
214
│ │ │ │ - │ │ │ │ -
216
│ │ │ │ -
217public:
│ │ │ │ -
218
│ │ │ │ -
219 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */
│ │ │ │ -
220
│ │ │ │ -
│ │ │ │ -
225 Extractor(const GV& gv)
│ │ │ │ -
226 : gv_(gv)
│ │ │ │ -
227 , cellMapper_(gv, mcmgElementLayout())
│ │ │ │ -
228 {}
│ │ │ │ -
│ │ │ │ -
229
│ │ │ │ -
230 /* F U N C T I O N A L I T Y */
│ │ │ │ +
188 // remember the vertex' number in parent element's vertices
│ │ │ │ +
189 temp_faces.back().corners[i].num = vertex_number;
│ │ │ │ +
190
│ │ │ │ +
191 // if the vertex is not yet inserted in the vertex info map
│ │ │ │ +
192 // it is a new one -> it will be inserted now!
│ │ │ │ +
193 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex);
│ │ │ │ +
194 if (vimit == this->vtxInfo_.end())
│ │ │ │ +
195 {
│ │ │ │ +
196 // insert into the map
│ │ │ │ +
197 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex));
│ │ │ │ +
198 // remember the vertex as a corner of the current face in temp_faces
│ │ │ │ +
199 temp_faces.back().corners[i].idx = vertex_index;
│ │ │ │ +
200 // increase the current index
│ │ │ │ +
201 vertex_index++;
│ │ │ │ +
202 }
│ │ │ │ +
203 else
│ │ │ │ +
204 {
│ │ │ │ +
205 // only insert the index into the simplices array
│ │ │ │ +
206 temp_faces.back().corners[i].idx = vimit->second.idx;
│ │ │ │ +
207 }
│ │ │ │ +
208 }
│ │ │ │ +
209
│ │ │ │ +
210 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ +
211 // have the wrong orientation. We want them to be oriented such that all boundary edges
│ │ │ │ +
212 // point in the counterclockwise direction. Therefore, we check the orientation of the
│ │ │ │ +
213 // new face and possibly switch the two vertices.
│ │ │ │ +
214 FieldVector<ctype,dimworld> realNormal = in.centerUnitOuterNormal();
│ │ │ │ +
215
│ │ │ │ +
216 // Compute segment normal
│ │ │ │ +
217 FieldVector<ctype,dimworld> reconstructedNormal;
│ │ │ │ +
218 if (dim==2) // boundary face is a line segment
│ │ │ │ +
219 {
│ │ │ │ +
220 reconstructedNormal[0] = cornerCoords[1][1] - cornerCoords[0][1];
│ │ │ │ +
221 reconstructedNormal[1] = cornerCoords[0][0] - cornerCoords[1][0];
│ │ │ │ +
222 } else { // boundary face is a triangle
│ │ │ │ +
223 FieldVector<ctype,dimworld> segment1 = cornerCoords[1] - cornerCoords[0];
│ │ │ │ +
224 FieldVector<ctype,dimworld> segment2 = cornerCoords[2] - cornerCoords[0];
│ │ │ │ +
225 reconstructedNormal = crossProduct(segment1, segment2);
│ │ │ │ +
226 }
│ │ │ │ +
227 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ +
228
│ │ │ │ +
229 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ +
230 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │
231
│ │ │ │ -
│ │ │ │ -
235 void clear()
│ │ │ │ -
236 {
│ │ │ │ -
237 coords_.clear();
│ │ │ │ -
238 coords_.shrink_to_fit();
│ │ │ │ -
239
│ │ │ │ -
240 subEntities_.clear();
│ │ │ │ -
241 subEntities_.shrink_to_fit();
│ │ │ │ +
232 // now increase the current face index
│ │ │ │ +
233 simplex_index++;
│ │ │ │ +
234 break;
│ │ │ │ +
235 }
│ │ │ │ +
236 case 4 :
│ │ │ │ +
237 {
│ │ │ │ +
238 assert(dim == 3 && cube_corners == 4);
│ │ │ │ +
239 // we have a quadrilateral here
│ │ │ │ +
240 std::array<unsigned int, 4> vertex_indices;
│ │ │ │ +
241 std::array<unsigned int, 4> vertex_numbers;
│ │ │ │
242
│ │ │ │ -
243 // ...then clear the maps themselves, too
│ │ │ │ -
244 vtxInfo_.clear();
│ │ │ │ -
245 elmtInfo_.clear();
│ │ │ │ -
246 }
│ │ │ │ -
│ │ │ │ +
243 // register the additional face(s) (2 simplices)
│ │ │ │ +
244 this->elmtInfo_.at(eindex).faces += 2;
│ │ │ │ +
245
│ │ │ │ +
246 std::array<FieldVector<ctype,dimworld>, 4> cornerCoords;
│ │ │ │
247
│ │ │ │ -
248
│ │ │ │ -
249 /* G E T T E R S */
│ │ │ │ -
250
│ │ │ │ -
│ │ │ │ -
256 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords) const
│ │ │ │ -
257 {
│ │ │ │ -
258 coords.resize(coords_.size());
│ │ │ │ -
259 for (unsigned int i = 0; i < coords_.size(); ++i)
│ │ │ │ -
260 coords[i] = coords_[i].coord;
│ │ │ │ -
261 }
│ │ │ │ -
│ │ │ │ -
262
│ │ │ │ -
263
│ │ │ │ -
│ │ │ │ -
268 unsigned int nCoords() const
│ │ │ │ -
269 {
│ │ │ │ -
270 return coords_.size();
│ │ │ │ -
271 }
│ │ │ │ -
│ │ │ │ -
272
│ │ │ │ -
│ │ │ │ -
274 void getGeometryTypes(std::vector<Dune::GeometryType>& geometryTypes) const
│ │ │ │ -
275 {
│ │ │ │ -
276 geometryTypes.resize(subEntities_.size());
│ │ │ │ -
277 for (size_t i=0; i<subEntities_.size(); i++)
│ │ │ │ -
278 geometryTypes[i] = subEntities_[i].geometryType_;
│ │ │ │ -
279 }
│ │ │ │ -
│ │ │ │ -
280
│ │ │ │ -
281
│ │ │ │ -
│ │ │ │ -
285 void getFaces(std::vector<VertexVector>& faces) const
│ │ │ │ -
286 {
│ │ │ │ -
287 faces.resize(subEntities_.size());
│ │ │ │ -
288 for (unsigned int i = 0; i < subEntities_.size(); ++i) {
│ │ │ │ -
289 faces[i].resize(subEntities_[i].nCorners());
│ │ │ │ -
290 for (unsigned int j = 0; j < subEntities_[i].nCorners(); ++j)
│ │ │ │ -
291 faces[i][j] = subEntities_[i].corners[j].idx;
│ │ │ │ -
292 }
│ │ │ │ -
293 }
│ │ │ │ -
│ │ │ │ +
248 // get the vertex pointers for the quadrilateral's corner vertices
│ │ │ │ +
249 // and try for each of them whether it is already inserted or not
│ │ │ │ +
250 for (int i = 0; i < cube_corners; ++i)
│ │ │ │ +
251 {
│ │ │ │ +
252 // get the number of the vertex in the parent element
│ │ │ │ +
253 vertex_numbers[i] = refElement.subEntity(in.indexInInside(), 1, i, dim);
│ │ │ │ +
254
│ │ │ │ +
255 // get the vertex pointer and the index from the index set
│ │ │ │ +
256 const Vertex vertex = elmt.template subEntity<dim>(vertex_numbers[i]);
│ │ │ │ +
257 cornerCoords[i] = vertex.geometry().corner(0);
│ │ │ │ +
258
│ │ │ │ +
259 IndexType vindex = this->gv_.indexSet().template index<dim>(vertex);
│ │ │ │ +
260
│ │ │ │ +
261 // if the vertex is not yet inserted in the vertex info map
│ │ │ │ +
262 // it is a new one -> it will be inserted now!
│ │ │ │ +
263 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex);
│ │ │ │ +
264 if (vimit == this->vtxInfo_.end())
│ │ │ │ +
265 {
│ │ │ │ +
266 // insert into the map
│ │ │ │ +
267 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex));
│ │ │ │ +
268 // remember this vertex' index
│ │ │ │ +
269 vertex_indices[i] = vertex_index;
│ │ │ │ +
270 // increase the current index
│ │ │ │ +
271 vertex_index++;
│ │ │ │ +
272 }
│ │ │ │ +
273 else
│ │ │ │ +
274 {
│ │ │ │ +
275 // only remember the vertex' index
│ │ │ │ +
276 vertex_indices[i] = vimit->second.idx;
│ │ │ │ +
277 }
│ │ │ │ +
278 }
│ │ │ │ +
279
│ │ │ │ +
280 // now introduce the two triangles subdividing the quadrilateral
│ │ │ │ +
281 // ATTENTION: the order of vertices given by "orientedSubface" corresponds to the order
│ │ │ │ +
282 // of a Dune quadrilateral, i.e. the triangles are given by 0 1 2 and 3 2 1
│ │ │ │ +
283
│ │ │ │ +
284 // add a new face to the temporary collection for the first tri
│ │ │ │ +
285 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ +
286 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ +
287 temp_faces.back().corners[0].idx = vertex_indices[0];
│ │ │ │ +
288 temp_faces.back().corners[1].idx = vertex_indices[1];
│ │ │ │ +
289 temp_faces.back().corners[2].idx = vertex_indices[2];
│ │ │ │ +
290 // remember the vertices' numbers in parent element's vertices
│ │ │ │ +
291 temp_faces.back().corners[0].num = vertex_numbers[0];
│ │ │ │ +
292 temp_faces.back().corners[1].num = vertex_numbers[1];
│ │ │ │ +
293 temp_faces.back().corners[2].num = vertex_numbers[2];
│ │ │ │
294
│ │ │ │ -
295
│ │ │ │ -
│ │ │ │ -
304 bool faceIndices(const Element& e, int& first, int& count) const
│ │ │ │ -
305 {
│ │ │ │ -
306 typename ElementInfoMap::const_iterator it =
│ │ │ │ -
307 elmtInfo_.find(cellMapper_.map(e));
│ │ │ │ -
308 if (it == elmtInfo_.end())
│ │ │ │ -
309 {
│ │ │ │ -
310 first = -1;
│ │ │ │ -
311 count = 0;
│ │ │ │ -
312 return false;
│ │ │ │ -
313 }
│ │ │ │ -
314 // the iterator is valid, fill the out params
│ │ │ │ -
315 first = it->second.idx;
│ │ │ │ -
316 count = it->second.faces;
│ │ │ │ -
317 return true;
│ │ │ │ -
318 }
│ │ │ │ -
│ │ │ │ -
319
│ │ │ │ +
295 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ +
296 // have the wrong orientation. We want the triangle vertices on counterclockwise order,
│ │ │ │ +
297 // when viewed from the outside of the grid. Therefore, we check the orientation of the
│ │ │ │ +
298 // new face and possibly switch two vertices.
│ │ │ │ +
299 FieldVector<ctype,dimworld> realNormal = in.centerUnitOuterNormal();
│ │ │ │ +
300
│ │ │ │ +
301 // Compute segment normal
│ │ │ │ +
302 FieldVector<ctype,dimworld> reconstructedNormal = crossProduct(cornerCoords[1] - cornerCoords[0],
│ │ │ │ +
303 cornerCoords[2] - cornerCoords[0]);
│ │ │ │ +
304 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ +
305
│ │ │ │ +
306 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ +
307 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │ +
308
│ │ │ │ +
309
│ │ │ │ +
310 // add a new face to the temporary collection for the second tri
│ │ │ │ +
311 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ +
312 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ +
313 temp_faces.back().corners[0].idx = vertex_indices[3];
│ │ │ │ +
314 temp_faces.back().corners[1].idx = vertex_indices[2];
│ │ │ │ +
315 temp_faces.back().corners[2].idx = vertex_indices[1];
│ │ │ │ +
316 // remember the vertices' numbers in parent element's vertices
│ │ │ │ +
317 temp_faces.back().corners[0].num = vertex_numbers[3];
│ │ │ │ +
318 temp_faces.back().corners[1].num = vertex_numbers[2];
│ │ │ │ +
319 temp_faces.back().corners[2].num = vertex_numbers[1];
│ │ │ │
320
│ │ │ │ -
│ │ │ │ -
326 int indexInInside(unsigned int index) const
│ │ │ │ -
327 {
│ │ │ │ -
328 return index < subEntities_.size() ? subEntities_[index].num_in_parent : -1;
│ │ │ │ -
329 }
│ │ │ │ -
│ │ │ │ -
330
│ │ │ │ -
331 // /**
│ │ │ │ -
332 // * @brief tests that a given entry in the extraction set does have local couplings
│ │ │ │ -
333 // * @todo parallel interface
│ │ │ │ -
334 // */
│ │ │ │ -
335 // bool contains (unsigned int global, unsigned int & local) const
│ │ │ │ -
336 // {
│ │ │ │ -
337 // local = global;
│ │ │ │ -
338 // return true;
│ │ │ │ -
339 // }
│ │ │ │ -
340
│ │ │ │ -
│ │ │ │ -
344 const GridView & gridView() const
│ │ │ │ -
345 {
│ │ │ │ -
346 return gv_;
│ │ │ │ -
347 }
│ │ │ │ -
│ │ │ │ -
348
│ │ │ │ -
│ │ │ │ -
349 const Grid& grid() const
│ │ │ │ -
350 {
│ │ │ │ -
351 return gv_.grid();
│ │ │ │ -
352 }
│ │ │ │ -
│ │ │ │ -
353
│ │ │ │ -
360 Element
│ │ │ │ -
│ │ │ │ -
361 element(unsigned int index) const
│ │ │ │ -
362 {
│ │ │ │ -
363 if (index >= subEntities_.size())
│ │ │ │ -
364 DUNE_THROW(Dune::GridError, "invalid face index");
│ │ │ │ -
365 const ElementSeed seed = elmtInfo_.at(subEntities_[index].parent).p;
│ │ │ │ -
366 return grid().entity(seed);
│ │ │ │ +
321 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ +
322 // have the wrong orientation. We want the triangle vertices on counterclockwise order,
│ │ │ │ +
323 // when viewed from the outside of the grid. Therefore, we check the orientation of the
│ │ │ │ +
324 // new face and possibly switch two vertices.
│ │ │ │ +
325 // Compute segment normal
│ │ │ │ +
326 reconstructedNormal = crossProduct(cornerCoords[2] - cornerCoords[3],
│ │ │ │ +
327 cornerCoords[1] - cornerCoords[3]);
│ │ │ │ +
328 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ +
329
│ │ │ │ +
330 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ +
331 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │ +
332
│ │ │ │ +
333 simplex_index+=2;
│ │ │ │ +
334 break;
│ │ │ │ +
335 }
│ │ │ │ +
336 default :
│ │ │ │ +
337 DUNE_THROW(Dune::NotImplemented, "the extractor does only work for triangle and quadrilateral faces (" << face_corners << " corners)");
│ │ │ │ +
338 break;
│ │ │ │ +
339 }
│ │ │ │ +
340 } // end loop over found surface parts
│ │ │ │ +
341 }
│ │ │ │ +
342 } // end loop over elements
│ │ │ │ +
343
│ │ │ │ +
344 std::cout << "added " << simplex_index << " subfaces\n";
│ │ │ │ +
345
│ │ │ │ +
346 // allocate the array for the face specific information...
│ │ │ │ +
347 this->subEntities_.resize(simplex_index);
│ │ │ │ +
348 // ...and fill in the data from the temporary containers
│ │ │ │ +
349 copy(temp_faces.begin(), temp_faces.end(), this->subEntities_.begin());
│ │ │ │ +
350 }
│ │ │ │ +
351
│ │ │ │ +
352
│ │ │ │ +
353 // now first write the array with the coordinates...
│ │ │ │ +
354 this->coords_.resize(this->vtxInfo_.size());
│ │ │ │ +
355 for (const auto& vinfo : this->vtxInfo_)
│ │ │ │ +
356 {
│ │ │ │ +
357 // get a pointer to the associated info object
│ │ │ │ +
358 CoordinateInfo* current = &this->coords_[vinfo.second.idx];
│ │ │ │ +
359 // store this coordinates index // NEEDED?
│ │ │ │ +
360 current->index = vinfo.second.idx;
│ │ │ │ +
361 // store the vertex' index for the index2vertex mapping
│ │ │ │ +
362 current->vtxindex = vinfo.first;
│ │ │ │ +
363 // store the vertex' coordinates under the associated index
│ │ │ │ +
364 // in the coordinates array
│ │ │ │ +
365 const auto vtx = this->grid().entity(vinfo.second.p);
│ │ │ │ +
366 current->coord = vtx.geometry().corner(0);
│ │ │ │
367 }
│ │ │ │ -
│ │ │ │
368
│ │ │ │ -
369#if 1
│ │ │ │ -
376 Vertex
│ │ │ │ -
│ │ │ │ -
377 vertex(unsigned int index) const
│ │ │ │ -
378 {
│ │ │ │ -
379 if (index >= coords_.size())
│ │ │ │ -
380 DUNE_THROW(Dune::GridError, "invalid coordinate index");
│ │ │ │ -
381 const VertexSeed seed = vtxInfo_.at(coords_[index].vtxindex).p;
│ │ │ │ -
382 return grid().entity(seed);
│ │ │ │ -
383 }
│ │ │ │ -
│ │ │ │ -
384#endif
│ │ │ │ -
385
│ │ │ │ -
│ │ │ │ -
387 Geometry geometry(unsigned int index) const;
│ │ │ │ -
388
│ │ │ │ -
│ │ │ │ -
390 LocalGeometry geometryLocal(unsigned int index) const;
│ │ │ │ -
391
│ │ │ │ -
392};
│ │ │ │ -
393
│ │ │ │ -
394
│ │ │ │ -
396template<typename GV, int cd>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
398{
│ │ │ │ -
399 std::vector<Coords> corners(subEntities_[index].nCorners());
│ │ │ │ -
400 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
│ │ │ │ -
401 corners[i] = coords_[subEntities_[index].corners[i].idx].coord;
│ │ │ │ -
402
│ │ │ │ -
403 return Geometry(subEntities_[index].geometryType_, corners);
│ │ │ │ -
404}
│ │ │ │ -
│ │ │ │ -
405
│ │ │ │ -
406
│ │ │ │ -
408template<typename GV, int cd>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
410{
│ │ │ │ -
411 std::vector<LocalCoords> corners(subEntities_[index].nCorners());
│ │ │ │ -
412
│ │ │ │ -
413 // get face info
│ │ │ │ -
414 const SubEntityInfo & face = subEntities_[index];
│ │ │ │ -
415 Dune::GeometryType facetype = subEntities_[index].geometryType_;
│ │ │ │ -
416
│ │ │ │ -
417 // get reference element
│ │ │ │ -
418 const auto elmtseed = elmtInfo_.at(face.parent).p;
│ │ │ │ -
419 const auto elmt = grid().entity(elmtseed);
│ │ │ │ -
420 const Dune::GeometryType celltype = elmt.type();
│ │ │ │ -
421 const auto& re = Dune::ReferenceElements<ctype, dim>::general(celltype);
│ │ │ │ -
422 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
│ │ │ │ -
423 corners[i] = re.position(face.corners[i].num,dim);
│ │ │ │ -
424
│ │ │ │ -
425 return LocalGeometry(facetype, corners);
│ │ │ │ -
426}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
427
│ │ │ │ -
428} // namespace GridGlue
│ │ │ │ -
429
│ │ │ │ -
430} // namespace Dune
│ │ │ │ -
431
│ │ │ │ -
432#endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +
369}
│ │ │ │ +
370
│ │ │ │ +
371} // namespace GridGlue
│ │ │ │ +
372
│ │ │ │ +
373} // namespace Dune
│ │ │ │ +
374
│ │ │ │ +
375#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
│ │ │ │ +
GV::Traits::template Codim< 0 >::Entity Element
Definition codim1extractor.hh:62
│ │ │ │ +
Dune::FieldVector< ctype, dimworld > Coords
Definition codim1extractor.hh:59
│ │ │ │ +
GV::Grid::ctype ctype
Definition codim1extractor.hh:58
│ │ │ │ +
Codim1Extractor(const GV &gv, const Predicate &predicate)
Constructor.
Definition codim1extractor.hh:81
│ │ │ │ +
static constexpr int simplex_corners
compile time number of corners of surface simplices
Definition codim1extractor.hh:54
│ │ │ │ +
Extractor< GV, 1 >::VertexInfo VertexInfo
Definition codim1extractor.hh:68
│ │ │ │ +
Extractor< GV, 1 >::CoordinateInfo CoordinateInfo
Definition codim1extractor.hh:69
│ │ │ │ +
Extractor< GV, 1 >::ElementInfo ElementInfo
Definition codim1extractor.hh:67
│ │ │ │ +
Extractor< GV, 1 >::SubEntityInfo SubEntityInfo
Definition codim1extractor.hh:66
│ │ │ │ +
Extractor< GV, 1 >::VertexInfoMap VertexInfoMap
Definition codim1extractor.hh:70
│ │ │ │ +
std::function< bool(const Element &, unsigned int subentity)> Predicate
Definition codim1extractor.hh:63
│ │ │ │ +
GV::Traits::template Codim< dim >::Entity Vertex
Definition codim1extractor.hh:61
│ │ │ │
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
│ │ │ │ -
GV::Traits::template Codim< dim >::Entity Vertex
Definition extractor.hh:63
│ │ │ │ -
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition extractor.hh:206
│ │ │ │ -
const Grid & grid() const
Definition extractor.hh:349
│ │ │ │ -
Element element(unsigned int index) const
gets the parent element for a given face index, throws an exception if index not valid
Definition extractor.hh:361
│ │ │ │ -
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition extractor.hh:326
│ │ │ │ -
Dune::FieldVector< ctype, dim > LocalCoords
Definition extractor.hh:61
│ │ │ │ -
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition extractor.hh:409
│ │ │ │ -
static constexpr auto dimworld
Definition extractor.hh:50
│ │ │ │ -
Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry
Definition extractor.hh:77
│ │ │ │ +
static constexpr auto dimworld
Definition extractor.hh:50
│ │ │ │
int IndexType
Definition extractor.hh:73
│ │ │ │ -
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition extractor.hh:196
│ │ │ │ -
GV::Traits::template Codim< 0 >::Entity Element
Definition extractor.hh:66
│ │ │ │ -
const GridView & gridView() const
give access to the Dune::GridView where this Patch belongs to
Definition extractor.hh:344
│ │ │ │ -
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition extractor.hh:285
│ │ │ │ -
std::vector< unsigned int > VertexVector
Definition extractor.hh:69
│ │ │ │ -
const GridView gv_
the grid object to extract the surface from
Definition extractor.hh:191
│ │ │ │ -
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition extractor.hh:199
│ │ │ │ -
static constexpr int cube_corners
Definition extractor.hh:54
│ │ │ │ -
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid
Definition extractor.hh:377
│ │ │ │ -
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │ -
Dune::FieldVector< ctype, dimworld > Coords
Definition extractor.hh:60
│ │ │ │ -
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition extractor.hh:274
│ │ │ │ -
MultipleCodimMultipleGeomTypeMapper< GridView > CellMapper
Definition extractor.hh:70
│ │ │ │ +
static constexpr int cube_corners
Definition extractor.hh:54
│ │ │ │ +
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │
std::map< IndexType, VertexInfo > VertexInfoMap
Definition extractor.hh:186
│ │ │ │ -
GridView::Grid Grid
Definition extractor.hh:57
│ │ │ │ -
bool faceIndices(const Element &e, int &first, int &count) const
gets index of first subentity as well as the total number of subentities that were extracted from thi...
Definition extractor.hh:304
│ │ │ │ -
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition extractor.hh:397
│ │ │ │ -
GV GridView
Definition extractor.hh:56
│ │ │ │ -
unsigned int nCoords() const
getter for the count of coordinates
Definition extractor.hh:268
│ │ │ │ -
GV::Grid::ctype ctype
Definition extractor.hh:59
│ │ │ │ -
std::map< IndexType, ElementInfo > ElementInfoMap
Definition extractor.hh:185
│ │ │ │ -
Extractor(const GV &gv)
Constructor.
Definition extractor.hh:225
│ │ │ │ -
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition extractor.hh:256
│ │ │ │ -
CellMapper cellMapper_
Definition extractor.hh:215
│ │ │ │ -
Element::EntitySeed ElementSeed
Definition extractor.hh:67
│ │ │ │ -
Vertex::EntitySeed VertexSeed
Definition extractor.hh:64
│ │ │ │ -
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition extractor.hh:213
│ │ │ │ -
void clear()
delete everything build up so far and free the memory
Definition extractor.hh:235
│ │ │ │ -
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │ -
Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry
Definition extractor.hh:78
│ │ │ │ -
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition extractor.hh:88
│ │ │ │ -
unsigned int idx
index of the vertex
Definition extractor.hh:89
│ │ │ │ -
unsigned int num
element corner
Definition extractor.hh:90
│ │ │ │ +
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │ │ │ │ │ -
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition extractor.hh:98
│ │ │ │ -
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition extractor.hh:109
│ │ │ │ -
CoordinateInfo()
Definition extractor.hh:95
│ │ │ │ -
Coords coord
the coordinate
Definition extractor.hh:106
│ │ │ │ -
IndexType vtxindex
the index of the parent element (from index set)
Definition extractor.hh:103
│ │ │ │
simple struct holding a vertex pointer and an index
Definition extractor.hh:116
│ │ │ │ -
unsigned int idx
Definition extractor.hh:119
│ │ │ │ -
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition extractor.hh:117
│ │ │ │ -
VertexSeed p
Definition extractor.hh:120
│ │ │ │
simple struct holding an element seed and an index
Definition extractor.hh:128
│ │ │ │ -
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition extractor.hh:133
│ │ │ │ -
unsigned int faces
the number of extracted faces for this element
Definition extractor.hh:136
│ │ │ │ -
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition extractor.hh:129
│ │ │ │ -
ElementSeed p
the entity seed for the element
Definition extractor.hh:139
│ │ │ │
Holds some information about an element's subentity involved in a coupling.
Definition extractor.hh:147
│ │ │ │ -
unsigned int nCorners() const
Definition extractor.hh:161
│ │ │ │ -
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition extractor.hh:181
│ │ │ │ -
IndexType parent
the index of the parent element (from index set)
Definition extractor.hh:167
│ │ │ │ -
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition extractor.hh:156
│ │ │ │ -
unsigned int num_in_parent
the number of the face in the parent element
Definition extractor.hh:170
│ │ │ │ -
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition extractor.hh:173
│ │ │ │ -
SubEntityInfo()
Definition extractor.hh:148
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,587 +1,470 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * extractors │ │ │ │ │ -extractor.hh │ │ │ │ │ +codim1extractor.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/* │ │ │ │ │ -6 * Filename: extractor.hh │ │ │ │ │ +6 * Filename: codim1extractor.hh │ │ │ │ │ 7 * Version: 1.0 │ │ │ │ │ -8 * Created on: Oct 05, 2009 │ │ │ │ │ -9 * Author: Christian Engwer │ │ │ │ │ +8 * Created on: Jun 23, 2009 │ │ │ │ │ +9 * Author: Oliver Sander, Christian Engwer │ │ │ │ │ 10 * --------------------------------- │ │ │ │ │ 11 * Project: dune-grid-glue │ │ │ │ │ -12 * Description: base class for all grid extractors │ │ │ │ │ +12 * Description: class for grid extractors extracting surface grids │ │ │ │ │ 13 * │ │ │ │ │ 14 */ │ │ │ │ │ -20#ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH │ │ │ │ │ -21#define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH │ │ │ │ │ +20#ifndef DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ +21#define DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ 22 │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28#include │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32#include │ │ │ │ │ -33 │ │ │ │ │ -34namespace Dune { │ │ │ │ │ -35 │ │ │ │ │ -36 namespace GridGlue { │ │ │ │ │ -37 │ │ │ │ │ -44template │ │ │ │ │ -45class Extractor │ │ │ │ │ -46{ │ │ │ │ │ -47 │ │ │ │ │ -48public: │ │ │ │ │ -49 │ │ │ │ │ -50 static constexpr auto dimworld = GV::dimensionworld; │ │ │ │ │ -51 static constexpr auto dim = GV::dimension; │ │ │ │ │ -52 static constexpr auto codim = cd; │ │ │ │ │ -53 │ │ │ │ │ -54 static constexpr int cube_corners = 1 << (dim-codim); │ │ │ │ │ +23#include "extractor.hh" │ │ │ │ │ +24 │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28 │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32 │ │ │ │ │ +33namespace Dune { │ │ │ │ │ +34 │ │ │ │ │ +35 namespace GridGlue { │ │ │ │ │ +36 │ │ │ │ │ +40template │ │ │ │ │ +41class Codim1Extractor : public Extractor │ │ │ │ │ +42{ │ │ │ │ │ +43public: │ │ │ │ │ +44 │ │ │ │ │ +45 /* 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 */ │ │ │ │ │ +46 │ │ │ │ │ +47 using Extractor::dimworld; │ │ │ │ │ +48 using Extractor::dim; │ │ │ │ │ +49 using Extractor::codim; │ │ │ │ │ +50 using Extractor::cube_corners; │ │ │ │ │ +51 typedef typename Extractor::IndexType IndexType; │ │ │ │ │ +52 │ │ │ │ │ +54 static constexpr int simplex_corners = dim; │ │ │ │ │ 55 │ │ │ │ │ 56 typedef GV GridView; │ │ │ │ │ -57 typedef typename GridView::Grid Grid; │ │ │ │ │ -58 │ │ │ │ │ -59 typedef typename GV::Grid::ctype ctype; │ │ │ │ │ -60 typedef Dune::FieldVector Coords; │ │ │ │ │ -61 typedef Dune::FieldVector LocalCoords; │ │ │ │ │ -62 │ │ │ │ │ -63 typedef typename GV::Traits::template Codim::Entity Vertex; │ │ │ │ │ -64 typedef typename Vertex::EntitySeed VertexSeed; │ │ │ │ │ -65 │ │ │ │ │ -66 typedef typename GV::Traits::template Codim<0>::Entity Element; │ │ │ │ │ -67 typedef typename Element::EntitySeed ElementSeed; │ │ │ │ │ -68 │ │ │ │ │ -69 typedef std::vector VertexVector; │ │ │ │ │ -70 using CellMapper = MultipleCodimMultipleGeomTypeMapper; │ │ │ │ │ +57 │ │ │ │ │ +58 typedef typename GV::Grid::ctype ctype; │ │ │ │ │ +59 typedef Dune::FieldVector Coords; │ │ │ │ │ +60 │ │ │ │ │ +61 typedef typename GV::Traits::template Codim::Entity Vertex; │ │ │ │ │ +62 typedef typename GV::Traits::template Codim<0>::Entity Element; │ │ │ │ │ +63 typedef std::function │ │ │ │ │ +Predicate; │ │ │ │ │ +64 │ │ │ │ │ +65 // import typedefs from base class │ │ │ │ │ +66 typedef typename Extractor::SubEntityInfo SubEntityInfo; │ │ │ │ │ +67 typedef typename Extractor::ElementInfo ElementInfo; │ │ │ │ │ +68 typedef typename Extractor::VertexInfo VertexInfo; │ │ │ │ │ +69 typedef typename Extractor::CoordinateInfo CoordinateInfo; │ │ │ │ │ +70 typedef typename Extractor::VertexInfoMap VertexInfoMap; │ │ │ │ │ 71 │ │ │ │ │ -72 // typedef typename CellMapper::IndexType IndexType; │ │ │ │ │ -73 typedef int IndexType; │ │ │ │ │ -74public: │ │ │ │ │ +72public: │ │ │ │ │ +73 │ │ │ │ │ +74 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */ │ │ │ │ │ 75 │ │ │ │ │ -76 // transformations │ │ │ │ │ -77 typedef Dune::MultiLinearGeometry Geometry; │ │ │ │ │ -78 typedef Dune::MultiLinearGeometry LocalGeometry; │ │ │ │ │ -79 │ │ │ │ │ -80protected: │ │ │ │ │ -81 /************************** PRIVATE SUBCLASSES **********************/ │ │ │ │ │ -82 │ │ │ │ │ -87 struct CornerInfo │ │ │ │ │ -88 { │ │ │ │ │ -89 unsigned int idx : 28; │ │ │ │ │ -90 unsigned int num : 4; │ │ │ │ │ -91 }; │ │ │ │ │ -92 │ │ │ │ │ -93 struct CoordinateInfo │ │ │ │ │ -94 { │ │ │ │ │ -95 CoordinateInfo() │ │ │ │ │ -96 {} │ │ │ │ │ -97 │ │ │ │ │ -98 CoordinateInfo(unsigned int index_, IndexType vtxindex_) │ │ │ │ │ -99 : vtxindex(vtxindex_), index(index_) │ │ │ │ │ -100 {} │ │ │ │ │ -101 │ │ │ │ │ -103 IndexType vtxindex; │ │ │ │ │ -104 │ │ │ │ │ -106 Coords coord; │ │ │ │ │ -107 │ │ │ │ │ -109 unsigned int index; │ │ │ │ │ -110 }; │ │ │ │ │ -111 │ │ │ │ │ -115 struct VertexInfo │ │ │ │ │ -116 { │ │ │ │ │ -117 VertexInfo(unsigned int idx_, const Vertex& p_) : idx(idx_), p(p_.seed()) │ │ │ │ │ -118 {} │ │ │ │ │ -119 unsigned int idx; │ │ │ │ │ -120 VertexSeed p; │ │ │ │ │ -121 }; │ │ │ │ │ -122 │ │ │ │ │ -123 │ │ │ │ │ -127 struct ElementInfo │ │ │ │ │ -128 { │ │ │ │ │ -129 ElementInfo(unsigned int idx_, const Element& p_, unsigned int f_) : idx │ │ │ │ │ -(idx_), faces(f_), p(p_.seed()) │ │ │ │ │ -130 {} │ │ │ │ │ -131 │ │ │ │ │ -133 unsigned int idx : 28; │ │ │ │ │ -134 │ │ │ │ │ -136 unsigned int faces : 4; │ │ │ │ │ +81 Codim1Extractor(const GV& gv, const Predicate& predicate) │ │ │ │ │ +82 : Extractor(gv) │ │ │ │ │ +83 { │ │ │ │ │ +84 std::cout << "This is Codim1Extractor on a <" << dim │ │ │ │ │ +85 << "," << dimworld << "> grid!" │ │ │ │ │ +86 << std::endl; │ │ │ │ │ +87 update(predicate); │ │ │ │ │ +88 } │ │ │ │ │ +89 │ │ │ │ │ +90private: │ │ │ │ │ +91 │ │ │ │ │ +105 void update(const Predicate& predicate); │ │ │ │ │ +106 │ │ │ │ │ +107}; │ │ │ │ │ +108 │ │ │ │ │ +109 │ │ │ │ │ +110template │ │ │ │ │ +111void Codim1Extractor::update(const Predicate& predicate) │ │ │ │ │ +112{ │ │ │ │ │ +113 // free everything there is in this object │ │ │ │ │ +114 this->clear(); │ │ │ │ │ +115 │ │ │ │ │ +116 // In this first pass iterate over all entities of codim 0. │ │ │ │ │ +117 // For each codim 1 intersection check if it is part of the boundary and if │ │ │ │ │ +so, │ │ │ │ │ +118 // get its corner vertices, find resp. store them together with their │ │ │ │ │ +associated index, │ │ │ │ │ +119 // and remember the indices of the boundary faces' corners. │ │ │ │ │ +120 { │ │ │ │ │ +121 // several counter for consecutive indexing are needed │ │ │ │ │ +122 int simplex_index = 0; │ │ │ │ │ +123 int vertex_index = 0; │ │ │ │ │ +124 IndexType eindex = 0; // suppress warning │ │ │ │ │ +125 │ │ │ │ │ +126 // needed later for insertion into a std::set which only │ │ │ │ │ +127 // works with const references │ │ │ │ │ +128 │ │ │ │ │ +129 // a temporary container where newly acquired face │ │ │ │ │ +130 // information can be stored at first │ │ │ │ │ +131 std::deque temp_faces; │ │ │ │ │ +132 │ │ │ │ │ +133 // iterate over interior codim 0 elements on the grid │ │ │ │ │ +134 for (const auto& elmt : elements(this->gv_, Partitions::interior)) │ │ │ │ │ +135 { │ │ │ │ │ +136 Dune::GeometryType gt = elmt.type(); │ │ │ │ │ 137 │ │ │ │ │ -139 ElementSeed p; │ │ │ │ │ -140 }; │ │ │ │ │ -141 │ │ │ │ │ -142 │ │ │ │ │ -146 struct SubEntityInfo │ │ │ │ │ -147 { │ │ │ │ │ -148 SubEntityInfo() │ │ │ │ │ -149 /* │ │ │ │ │ -150 * TODO: move default value of `geometryType_` to member declaration │ │ │ │ │ -151 * when removing support for older dune-geometry │ │ │ │ │ -152 */ │ │ │ │ │ -153 : geometryType_(GeometryTypes::simplex(dim-codim)) │ │ │ │ │ -154 {} │ │ │ │ │ -155 │ │ │ │ │ -156 SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, │ │ │ │ │ -157 const Dune::GeometryType& geometryType) │ │ │ │ │ -158 : parent(parent_), num_in_parent(num_in_parent_), geometryType_ │ │ │ │ │ -(geometryType) │ │ │ │ │ -159 {} │ │ │ │ │ -160 │ │ │ │ │ -161 unsigned int nCorners() const │ │ │ │ │ -162 { │ │ │ │ │ -163 return Dune::ReferenceElements::general(geometryType_ │ │ │ │ │ -).size(dim-codim); │ │ │ │ │ -164 } │ │ │ │ │ -165 │ │ │ │ │ -167 IndexType parent; │ │ │ │ │ -168 │ │ │ │ │ -170 unsigned int num_in_parent : 3; │ │ │ │ │ -171 │ │ │ │ │ -173 Dune::GeometryType geometryType_; │ │ │ │ │ -174 │ │ │ │ │ -181 CornerInfo corners[cube_corners]; // sim = number of vertices in a simplex │ │ │ │ │ -182 }; │ │ │ │ │ -183 │ │ │ │ │ -184 │ │ │ │ │ -185 typedef std::map ElementInfoMap; │ │ │ │ │ -186 typedef std::map VertexInfoMap; │ │ │ │ │ +138 // if some face is part of the surface add it! │ │ │ │ │ +139 if (elmt.hasBoundaryIntersections()) │ │ │ │ │ +140 { │ │ │ │ │ +141 // add an entry to the element info map, the index will be set properly │ │ │ │ │ +later, │ │ │ │ │ +142 // whereas the number of faces is already known │ │ │ │ │ +143 eindex = this->cellMapper_.index(elmt); │ │ │ │ │ +144 this->elmtInfo_.emplace(eindex, ElementInfo(simplex_index, elmt, 0)); │ │ │ │ │ +145 │ │ │ │ │ +146 // now add the faces in ascending order of their indices │ │ │ │ │ +147 // (we are only talking about 1-4 faces here, so O(n^2) is ok!) │ │ │ │ │ +148 for (const auto& in : intersections(this->gv_, elmt)) │ │ │ │ │ +149 { │ │ │ │ │ +150 // Stop only at selected boundary faces │ │ │ │ │ +151 if (!in.boundary() or !predicate(elmt, in.indexInInside())) │ │ │ │ │ +152 continue; │ │ │ │ │ +153 │ │ │ │ │ +154 const auto& refElement = Dune::ReferenceElements::general(gt); │ │ │ │ │ +155 // get the corner count of this face │ │ │ │ │ +156 const int face_corners = refElement.size(in.indexInInside(), 1, dim); │ │ │ │ │ +157 │ │ │ │ │ +158 // now we only have to care about the 3D case, i.e. a triangle face can be │ │ │ │ │ +159 // inserted directly whereas a quadrilateral face has to be divided into │ │ │ │ │ +two triangles │ │ │ │ │ +160 switch (face_corners) │ │ │ │ │ +161 { │ │ │ │ │ +162 case 2 : │ │ │ │ │ +163 case 3: │ │ │ │ │ +164 { │ │ │ │ │ +165 // we have a simplex here │ │ │ │ │ +166 │ │ │ │ │ +167 // register the additional face(s) │ │ │ │ │ +168 this->elmtInfo_.at(eindex).faces++; │ │ │ │ │ +169 │ │ │ │ │ +170 // add a new face to the temporary collection │ │ │ │ │ +171 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ +172 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ +173 │ │ │ │ │ +174 std::vector > cornerCoords(face_corners); │ │ │ │ │ +175 │ │ │ │ │ +176 // try for each of the faces vertices whether it is already inserted or not │ │ │ │ │ +177 for (int i = 0; i < face_corners; ++i) │ │ │ │ │ +178 { │ │ │ │ │ +179 // get the number of the vertex in the parent element │ │ │ │ │ +180 int vertex_number = refElement.subEntity(in.indexInInside(), 1, i, dim); │ │ │ │ │ +181 │ │ │ │ │ +182 // get the vertex pointer and the index from the index set │ │ │ │ │ +183 const Vertex vertex = elmt.template subEntity(vertex_number); │ │ │ │ │ +184 cornerCoords[i] = vertex.geometry().corner(0); │ │ │ │ │ +185 │ │ │ │ │ +186 IndexType vindex = this->gv_.indexSet().template index(vertex); │ │ │ │ │ 187 │ │ │ │ │ -188 /************************** MEMBER VARIABLES ************************/ │ │ │ │ │ -189 │ │ │ │ │ -191 const GridView gv_; │ │ │ │ │ -192 │ │ │ │ │ -193 /* Geometrical and Topological Information */ │ │ │ │ │ -194 │ │ │ │ │ -196 std::vector coords_; │ │ │ │ │ -197 │ │ │ │ │ -199 std::vector subEntities_; │ │ │ │ │ -200 │ │ │ │ │ -206 VertexInfoMap vtxInfo_; │ │ │ │ │ -207 │ │ │ │ │ -213 ElementInfoMap elmtInfo_; │ │ │ │ │ -214 │ │ │ │ │ -215 CellMapper cellMapper_; │ │ │ │ │ -216 │ │ │ │ │ -217public: │ │ │ │ │ -218 │ │ │ │ │ -219 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */ │ │ │ │ │ -220 │ │ │ │ │ -225 Extractor(const GV& gv) │ │ │ │ │ -226 : gv_(gv) │ │ │ │ │ -227 , cellMapper_(gv, mcmgElementLayout()) │ │ │ │ │ -228 {} │ │ │ │ │ -229 │ │ │ │ │ -230 /* F U N C T I O N A L I T Y */ │ │ │ │ │ +188 // remember the vertex' number in parent element's vertices │ │ │ │ │ +189 temp_faces.back().corners[i].num = vertex_number; │ │ │ │ │ +190 │ │ │ │ │ +191 // if the vertex is not yet inserted in the vertex info map │ │ │ │ │ +192 // it is a new one -> it will be inserted now! │ │ │ │ │ +193 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex); │ │ │ │ │ +194 if (vimit == this->vtxInfo_.end()) │ │ │ │ │ +195 { │ │ │ │ │ +196 // insert into the map │ │ │ │ │ +197 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex)); │ │ │ │ │ +198 // remember the vertex as a corner of the current face in temp_faces │ │ │ │ │ +199 temp_faces.back().corners[i].idx = vertex_index; │ │ │ │ │ +200 // increase the current index │ │ │ │ │ +201 vertex_index++; │ │ │ │ │ +202 } │ │ │ │ │ +203 else │ │ │ │ │ +204 { │ │ │ │ │ +205 // only insert the index into the simplices array │ │ │ │ │ +206 temp_faces.back().corners[i].idx = vimit->second.idx; │ │ │ │ │ +207 } │ │ │ │ │ +208 } │ │ │ │ │ +209 │ │ │ │ │ +210 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ +they may │ │ │ │ │ +211 // have the wrong orientation. We want them to be oriented such that all │ │ │ │ │ +boundary edges │ │ │ │ │ +212 // point in the counterclockwise direction. Therefore, we check the │ │ │ │ │ +orientation of the │ │ │ │ │ +213 // new face and possibly switch the two vertices. │ │ │ │ │ +214 FieldVector realNormal = in.centerUnitOuterNormal(); │ │ │ │ │ +215 │ │ │ │ │ +216 // Compute segment normal │ │ │ │ │ +217 FieldVector reconstructedNormal; │ │ │ │ │ +218 if (dim==2) // boundary face is a line segment │ │ │ │ │ +219 { │ │ │ │ │ +220 reconstructedNormal[0] = cornerCoords[1][1] - cornerCoords[0][1]; │ │ │ │ │ +221 reconstructedNormal[1] = cornerCoords[0][0] - cornerCoords[1][0]; │ │ │ │ │ +222 } else { // boundary face is a triangle │ │ │ │ │ +223 FieldVector segment1 = cornerCoords[1] - cornerCoords[0]; │ │ │ │ │ +224 FieldVector segment2 = cornerCoords[2] - cornerCoords[0]; │ │ │ │ │ +225 reconstructedNormal = crossProduct(segment1, segment2); │ │ │ │ │ +226 } │ │ │ │ │ +227 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ +228 │ │ │ │ │ +229 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ +230 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ 231 │ │ │ │ │ -235 void clear() │ │ │ │ │ -236 { │ │ │ │ │ -237 coords_.clear(); │ │ │ │ │ -238 coords_.shrink_to_fit(); │ │ │ │ │ -239 │ │ │ │ │ -240 subEntities_.clear(); │ │ │ │ │ -241 subEntities_.shrink_to_fit(); │ │ │ │ │ +232 // now increase the current face index │ │ │ │ │ +233 simplex_index++; │ │ │ │ │ +234 break; │ │ │ │ │ +235 } │ │ │ │ │ +236 case 4 : │ │ │ │ │ +237 { │ │ │ │ │ +238 assert(dim == 3 && cube_corners == 4); │ │ │ │ │ +239 // we have a quadrilateral here │ │ │ │ │ +240 std::array vertex_indices; │ │ │ │ │ +241 std::array vertex_numbers; │ │ │ │ │ 242 │ │ │ │ │ -243 // ...then clear the maps themselves, too │ │ │ │ │ -244 vtxInfo_.clear(); │ │ │ │ │ -245 elmtInfo_.clear(); │ │ │ │ │ -246 } │ │ │ │ │ +243 // register the additional face(s) (2 simplices) │ │ │ │ │ +244 this->elmtInfo_.at(eindex).faces += 2; │ │ │ │ │ +245 │ │ │ │ │ +246 std::array, 4> cornerCoords; │ │ │ │ │ 247 │ │ │ │ │ -248 │ │ │ │ │ -249 /* G E T T E R S */ │ │ │ │ │ -250 │ │ │ │ │ -256 void getCoords(std::vector >& coords) │ │ │ │ │ -const │ │ │ │ │ -257 { │ │ │ │ │ -258 coords.resize(coords_.size()); │ │ │ │ │ -259 for (unsigned int i = 0; i < coords_.size(); ++i) │ │ │ │ │ -260 coords[i] = coords_[i].coord; │ │ │ │ │ -261 } │ │ │ │ │ -262 │ │ │ │ │ -263 │ │ │ │ │ -268 unsigned int nCoords() const │ │ │ │ │ -269 { │ │ │ │ │ -270 return coords_.size(); │ │ │ │ │ -271 } │ │ │ │ │ -272 │ │ │ │ │ -274 void getGeometryTypes(std::vector& geometryTypes) const │ │ │ │ │ -275 { │ │ │ │ │ -276 geometryTypes.resize(subEntities_.size()); │ │ │ │ │ -277 for (size_t i=0; i& faces) const │ │ │ │ │ -286 { │ │ │ │ │ -287 faces.resize(subEntities_.size()); │ │ │ │ │ -288 for (unsigned int i = 0; i < subEntities_.size(); ++i) { │ │ │ │ │ -289 faces[i].resize(subEntities_[i].nCorners()); │ │ │ │ │ -290 for (unsigned int j = 0; j < subEntities_[i].nCorners(); ++j) │ │ │ │ │ -291 faces[i][j] = subEntities_[i].corners[j].idx; │ │ │ │ │ -292 } │ │ │ │ │ -293 } │ │ │ │ │ +248 // get the vertex pointers for the quadrilateral's corner vertices │ │ │ │ │ +249 // and try for each of them whether it is already inserted or not │ │ │ │ │ +250 for (int i = 0; i < cube_corners; ++i) │ │ │ │ │ +251 { │ │ │ │ │ +252 // get the number of the vertex in the parent element │ │ │ │ │ +253 vertex_numbers[i] = refElement.subEntity(in.indexInInside(), 1, i, dim); │ │ │ │ │ +254 │ │ │ │ │ +255 // get the vertex pointer and the index from the index set │ │ │ │ │ +256 const Vertex vertex = elmt.template subEntity(vertex_numbers[i]); │ │ │ │ │ +257 cornerCoords[i] = vertex.geometry().corner(0); │ │ │ │ │ +258 │ │ │ │ │ +259 IndexType vindex = this->gv_.indexSet().template index(vertex); │ │ │ │ │ +260 │ │ │ │ │ +261 // if the vertex is not yet inserted in the vertex info map │ │ │ │ │ +262 // it is a new one -> it will be inserted now! │ │ │ │ │ +263 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex); │ │ │ │ │ +264 if (vimit == this->vtxInfo_.end()) │ │ │ │ │ +265 { │ │ │ │ │ +266 // insert into the map │ │ │ │ │ +267 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex)); │ │ │ │ │ +268 // remember this vertex' index │ │ │ │ │ +269 vertex_indices[i] = vertex_index; │ │ │ │ │ +270 // increase the current index │ │ │ │ │ +271 vertex_index++; │ │ │ │ │ +272 } │ │ │ │ │ +273 else │ │ │ │ │ +274 { │ │ │ │ │ +275 // only remember the vertex' index │ │ │ │ │ +276 vertex_indices[i] = vimit->second.idx; │ │ │ │ │ +277 } │ │ │ │ │ +278 } │ │ │ │ │ +279 │ │ │ │ │ +280 // now introduce the two triangles subdividing the quadrilateral │ │ │ │ │ +281 // ATTENTION: the order of vertices given by "orientedSubface" corresponds │ │ │ │ │ +to the order │ │ │ │ │ +282 // of a Dune quadrilateral, i.e. the triangles are given by 0 1 2 and 3 2 1 │ │ │ │ │ +283 │ │ │ │ │ +284 // add a new face to the temporary collection for the first tri │ │ │ │ │ +285 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ +286 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ +287 temp_faces.back().corners[0].idx = vertex_indices[0]; │ │ │ │ │ +288 temp_faces.back().corners[1].idx = vertex_indices[1]; │ │ │ │ │ +289 temp_faces.back().corners[2].idx = vertex_indices[2]; │ │ │ │ │ +290 // remember the vertices' numbers in parent element's vertices │ │ │ │ │ +291 temp_faces.back().corners[0].num = vertex_numbers[0]; │ │ │ │ │ +292 temp_faces.back().corners[1].num = vertex_numbers[1]; │ │ │ │ │ +293 temp_faces.back().corners[2].num = vertex_numbers[2]; │ │ │ │ │ 294 │ │ │ │ │ -295 │ │ │ │ │ -304 bool faceIndices(const Element& e, int& first, int& count) const │ │ │ │ │ -305 { │ │ │ │ │ -306 typename ElementInfoMap::const_iterator it = │ │ │ │ │ -307 elmtInfo_.find(cellMapper_.map(e)); │ │ │ │ │ -308 if (it == elmtInfo_.end()) │ │ │ │ │ -309 { │ │ │ │ │ -310 first = -1; │ │ │ │ │ -311 count = 0; │ │ │ │ │ -312 return false; │ │ │ │ │ -313 } │ │ │ │ │ -314 // the iterator is valid, fill the out params │ │ │ │ │ -315 first = it->second.idx; │ │ │ │ │ -316 count = it->second.faces; │ │ │ │ │ -317 return true; │ │ │ │ │ -318 } │ │ │ │ │ -319 │ │ │ │ │ +295 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ +they may │ │ │ │ │ +296 // have the wrong orientation. We want the triangle vertices on │ │ │ │ │ +counterclockwise order, │ │ │ │ │ +297 // when viewed from the outside of the grid. Therefore, we check the │ │ │ │ │ +orientation of the │ │ │ │ │ +298 // new face and possibly switch two vertices. │ │ │ │ │ +299 FieldVector realNormal = in.centerUnitOuterNormal(); │ │ │ │ │ +300 │ │ │ │ │ +301 // Compute segment normal │ │ │ │ │ +302 FieldVector reconstructedNormal = crossProduct(cornerCoords │ │ │ │ │ +[1] - cornerCoords[0], │ │ │ │ │ +303 cornerCoords[2] - cornerCoords[0]); │ │ │ │ │ +304 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ +305 │ │ │ │ │ +306 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ +307 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ +308 │ │ │ │ │ +309 │ │ │ │ │ +310 // add a new face to the temporary collection for the second tri │ │ │ │ │ +311 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ +312 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ +313 temp_faces.back().corners[0].idx = vertex_indices[3]; │ │ │ │ │ +314 temp_faces.back().corners[1].idx = vertex_indices[2]; │ │ │ │ │ +315 temp_faces.back().corners[2].idx = vertex_indices[1]; │ │ │ │ │ +316 // remember the vertices' numbers in parent element's vertices │ │ │ │ │ +317 temp_faces.back().corners[0].num = vertex_numbers[3]; │ │ │ │ │ +318 temp_faces.back().corners[1].num = vertex_numbers[2]; │ │ │ │ │ +319 temp_faces.back().corners[2].num = vertex_numbers[1]; │ │ │ │ │ 320 │ │ │ │ │ -326 int indexInInside(unsigned int index) const │ │ │ │ │ -327 { │ │ │ │ │ -328 return index < subEntities_.size() ? subEntities_[index].num_in_parent : - │ │ │ │ │ -1; │ │ │ │ │ -329 } │ │ │ │ │ -330 │ │ │ │ │ -331 // /** │ │ │ │ │ -332 // * @brief tests that a given entry in the extraction set does have local │ │ │ │ │ -couplings │ │ │ │ │ -333 // * @todo parallel interface │ │ │ │ │ -334 // */ │ │ │ │ │ -335 // bool contains (unsigned int global, unsigned int & local) const │ │ │ │ │ -336 // { │ │ │ │ │ -337 // local = global; │ │ │ │ │ -338 // return true; │ │ │ │ │ -339 // } │ │ │ │ │ -340 │ │ │ │ │ -344 const GridView & gridView() const │ │ │ │ │ -345 { │ │ │ │ │ -346 return gv_; │ │ │ │ │ -347 } │ │ │ │ │ -348 │ │ │ │ │ -349 const Grid& grid() const │ │ │ │ │ -350 { │ │ │ │ │ -351 return gv_.grid(); │ │ │ │ │ -352 } │ │ │ │ │ -353 │ │ │ │ │ -360 Element │ │ │ │ │ -361 element(unsigned int index) const │ │ │ │ │ -362 { │ │ │ │ │ -363 if (index >= subEntities_.size()) │ │ │ │ │ -364 DUNE_THROW(Dune::GridError, "invalid face index"); │ │ │ │ │ -365 const ElementSeed seed = elmtInfo_.at(subEntities_[index].parent).p; │ │ │ │ │ -366 return grid().entity(seed); │ │ │ │ │ +321 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ +they may │ │ │ │ │ +322 // have the wrong orientation. We want the triangle vertices on │ │ │ │ │ +counterclockwise order, │ │ │ │ │ +323 // when viewed from the outside of the grid. Therefore, we check the │ │ │ │ │ +orientation of the │ │ │ │ │ +324 // new face and possibly switch two vertices. │ │ │ │ │ +325 // Compute segment normal │ │ │ │ │ +326 reconstructedNormal = crossProduct(cornerCoords[2] - cornerCoords[3], │ │ │ │ │ +327 cornerCoords[1] - cornerCoords[3]); │ │ │ │ │ +328 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ +329 │ │ │ │ │ +330 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ +331 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ +332 │ │ │ │ │ +333 simplex_index+=2; │ │ │ │ │ +334 break; │ │ │ │ │ +335 } │ │ │ │ │ +336 default : │ │ │ │ │ +337 DUNE_THROW(Dune::NotImplemented, "the extractor does only work for triangle │ │ │ │ │ +and quadrilateral faces (" << face_corners << " corners)"); │ │ │ │ │ +338 break; │ │ │ │ │ +339 } │ │ │ │ │ +340 } // end loop over found surface parts │ │ │ │ │ +341 } │ │ │ │ │ +342 } // end loop over elements │ │ │ │ │ +343 │ │ │ │ │ +344 std::cout << "added " << simplex_index << " subfaces\n"; │ │ │ │ │ +345 │ │ │ │ │ +346 // allocate the array for the face specific information... │ │ │ │ │ +347 this->subEntities_.resize(simplex_index); │ │ │ │ │ +348 // ...and fill in the data from the temporary containers │ │ │ │ │ +349 copy(temp_faces.begin(), temp_faces.end(), this->subEntities_.begin()); │ │ │ │ │ +350 } │ │ │ │ │ +351 │ │ │ │ │ +352 │ │ │ │ │ +353 // now first write the array with the coordinates... │ │ │ │ │ +354 this->coords_.resize(this->vtxInfo_.size()); │ │ │ │ │ +355 for (const auto& vinfo : this->vtxInfo_) │ │ │ │ │ +356 { │ │ │ │ │ +357 // get a pointer to the associated info object │ │ │ │ │ +358 CoordinateInfo* current = &this->coords_[vinfo.second.idx]; │ │ │ │ │ +359 // store this coordinates index // NEEDED? │ │ │ │ │ +360 current->index = vinfo.second.idx; │ │ │ │ │ +361 // store the vertex' index for the index2vertex mapping │ │ │ │ │ +362 current->vtxindex = vinfo.first; │ │ │ │ │ +363 // store the vertex' coordinates under the associated index │ │ │ │ │ +364 // in the coordinates array │ │ │ │ │ +365 const auto vtx = this->grid().entity(vinfo.second.p); │ │ │ │ │ +366 current->coord = vtx.geometry().corner(0); │ │ │ │ │ 367 } │ │ │ │ │ 368 │ │ │ │ │ -369#if 1 │ │ │ │ │ -376 Vertex │ │ │ │ │ -377 vertex(unsigned int index) const │ │ │ │ │ -378 { │ │ │ │ │ -379 if (index >= coords_.size()) │ │ │ │ │ -380 DUNE_THROW(Dune::GridError, "invalid coordinate index"); │ │ │ │ │ -381 const VertexSeed seed = vtxInfo_.at(coords_[index].vtxindex).p; │ │ │ │ │ -382 return grid().entity(seed); │ │ │ │ │ -383 } │ │ │ │ │ -384#endif │ │ │ │ │ -385 │ │ │ │ │ -387 Geometry geometry(unsigned int index) const; │ │ │ │ │ -388 │ │ │ │ │ -390 LocalGeometry geometryLocal(unsigned int index) const; │ │ │ │ │ -391 │ │ │ │ │ -392}; │ │ │ │ │ -393 │ │ │ │ │ -394 │ │ │ │ │ -396template │ │ │ │ │ -397typename Extractor::Geometry Extractor::geometry(unsigned int │ │ │ │ │ -index) const │ │ │ │ │ -398{ │ │ │ │ │ -399 std::vector corners(subEntities_[index].nCorners()); │ │ │ │ │ -400 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i) │ │ │ │ │ -401 corners[i] = coords_[subEntities_[index].corners[i].idx].coord; │ │ │ │ │ -402 │ │ │ │ │ -403 return Geometry(subEntities_[index].geometryType_, corners); │ │ │ │ │ -404} │ │ │ │ │ -405 │ │ │ │ │ -406 │ │ │ │ │ -408template │ │ │ │ │ -409typename Extractor::LocalGeometry Extractor::geometryLocal │ │ │ │ │ -(unsigned int index) const │ │ │ │ │ -410{ │ │ │ │ │ -411 std::vector corners(subEntities_[index].nCorners()); │ │ │ │ │ -412 │ │ │ │ │ -413 // get face info │ │ │ │ │ -414 const SubEntityInfo & face = subEntities_[index]; │ │ │ │ │ -415 Dune::GeometryType facetype = subEntities_[index].geometryType_; │ │ │ │ │ -416 │ │ │ │ │ -417 // get reference element │ │ │ │ │ -418 const auto elmtseed = elmtInfo_.at(face.parent).p; │ │ │ │ │ -419 const auto elmt = grid().entity(elmtseed); │ │ │ │ │ -420 const Dune::GeometryType celltype = elmt.type(); │ │ │ │ │ -421 const auto& re = Dune::ReferenceElements::general(celltype); │ │ │ │ │ -422 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i) │ │ │ │ │ -423 corners[i] = re.position(face.corners[i].num,dim); │ │ │ │ │ -424 │ │ │ │ │ -425 return LocalGeometry(facetype, corners); │ │ │ │ │ -426} │ │ │ │ │ -427 │ │ │ │ │ -428} // namespace GridGlue │ │ │ │ │ -429 │ │ │ │ │ -430} // namespace Dune │ │ │ │ │ -431 │ │ │ │ │ -432#endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH │ │ │ │ │ +369} │ │ │ │ │ +370 │ │ │ │ │ +371} // namespace GridGlue │ │ │ │ │ +372 │ │ │ │ │ +373} // namespace Dune │ │ │ │ │ +374 │ │ │ │ │ +375#endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ +crossproduct.hh │ │ │ │ │ +extractor.hh │ │ │ │ │ +extractor base class │ │ │ │ │ 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::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::Codim1Extractor │ │ │ │ │ +Definition codim1extractor.hh:42 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::IndexType │ │ │ │ │ +Extractor< GV, 1 >::IndexType IndexType │ │ │ │ │ +Definition codim1extractor.hh:51 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::GridView │ │ │ │ │ +GV GridView │ │ │ │ │ +Definition codim1extractor.hh:56 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::Element │ │ │ │ │ +GV::Traits::template Codim< 0 >::Entity Element │ │ │ │ │ +Definition codim1extractor.hh:62 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::Coords │ │ │ │ │ +Dune::FieldVector< ctype, dimworld > Coords │ │ │ │ │ +Definition codim1extractor.hh:59 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::ctype │ │ │ │ │ +GV::Grid::ctype ctype │ │ │ │ │ +Definition codim1extractor.hh:58 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::Codim1Extractor │ │ │ │ │ +Codim1Extractor(const GV &gv, const Predicate &predicate) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition codim1extractor.hh:81 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::simplex_corners │ │ │ │ │ +static constexpr int simplex_corners │ │ │ │ │ +compile time number of corners of surface simplices │ │ │ │ │ +Definition codim1extractor.hh:54 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::VertexInfo │ │ │ │ │ +Extractor< GV, 1 >::VertexInfo VertexInfo │ │ │ │ │ +Definition codim1extractor.hh:68 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::CoordinateInfo │ │ │ │ │ +Extractor< GV, 1 >::CoordinateInfo CoordinateInfo │ │ │ │ │ +Definition codim1extractor.hh:69 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::ElementInfo │ │ │ │ │ +Extractor< GV, 1 >::ElementInfo ElementInfo │ │ │ │ │ +Definition codim1extractor.hh:67 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::SubEntityInfo │ │ │ │ │ +Extractor< GV, 1 >::SubEntityInfo SubEntityInfo │ │ │ │ │ +Definition codim1extractor.hh:66 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::VertexInfoMap │ │ │ │ │ +Extractor< GV, 1 >::VertexInfoMap VertexInfoMap │ │ │ │ │ +Definition codim1extractor.hh:70 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::Predicate │ │ │ │ │ +std::function< bool(const Element &, unsigned int subentity)> Predicate │ │ │ │ │ +Definition codim1extractor.hh:63 │ │ │ │ │ +Dune::GridGlue::Codim1Extractor::Vertex │ │ │ │ │ +GV::Traits::template Codim< dim >::Entity Vertex │ │ │ │ │ +Definition codim1extractor.hh:61 │ │ │ │ │ Dune::GridGlue::Extractor │ │ │ │ │ Provides codimension-independent methods for grid extraction. │ │ │ │ │ Definition extractor.hh:46 │ │ │ │ │ -Dune::GridGlue::Extractor::Vertex │ │ │ │ │ -GV::Traits::template Codim< dim >::Entity Vertex │ │ │ │ │ -Definition extractor.hh:63 │ │ │ │ │ -Dune::GridGlue::Extractor::vtxInfo_ │ │ │ │ │ -VertexInfoMap vtxInfo_ │ │ │ │ │ -a map enabling faster access to vertices and coordinates │ │ │ │ │ -Definition extractor.hh:206 │ │ │ │ │ -Dune::GridGlue::Extractor::grid │ │ │ │ │ -const Grid & grid() const │ │ │ │ │ -Definition extractor.hh:349 │ │ │ │ │ -Dune::GridGlue::Extractor::element │ │ │ │ │ -Element element(unsigned int index) const │ │ │ │ │ -gets the parent element for a given face index, throws an exception if index │ │ │ │ │ -not valid │ │ │ │ │ -Definition extractor.hh:361 │ │ │ │ │ -Dune::GridGlue::Extractor::indexInInside │ │ │ │ │ -int indexInInside(unsigned int index) const │ │ │ │ │ -gets the number face in the parent element │ │ │ │ │ -Definition extractor.hh:326 │ │ │ │ │ -Dune::GridGlue::Extractor::LocalCoords │ │ │ │ │ -Dune::FieldVector< ctype, dim > LocalCoords │ │ │ │ │ -Definition extractor.hh:61 │ │ │ │ │ -Dune::GridGlue::Extractor::geometryLocal │ │ │ │ │ -LocalGeometry geometryLocal(unsigned int index) const │ │ │ │ │ -Get geometry of the extracted face in element coordinates. │ │ │ │ │ -Definition extractor.hh:409 │ │ │ │ │ -Dune::GridGlue::Extractor::dimworld │ │ │ │ │ +Dune::GridGlue::Extractor<_GV,_1_>::dimworld │ │ │ │ │ static constexpr auto dimworld │ │ │ │ │ Definition extractor.hh:50 │ │ │ │ │ -Dune::GridGlue::Extractor::Geometry │ │ │ │ │ -Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry │ │ │ │ │ -Definition extractor.hh:77 │ │ │ │ │ Dune::GridGlue::Extractor::IndexType │ │ │ │ │ int IndexType │ │ │ │ │ Definition extractor.hh:73 │ │ │ │ │ -Dune::GridGlue::Extractor::coords_ │ │ │ │ │ -std::vector< CoordinateInfo > coords_ │ │ │ │ │ -all information about the corner vertices of the extracted │ │ │ │ │ -Definition extractor.hh:196 │ │ │ │ │ -Dune::GridGlue::Extractor::Element │ │ │ │ │ -GV::Traits::template Codim< 0 >::Entity Element │ │ │ │ │ -Definition extractor.hh:66 │ │ │ │ │ -Dune::GridGlue::Extractor::gridView │ │ │ │ │ -const GridView & gridView() const │ │ │ │ │ -give access to the Dune::GridView where this Patch belongs to │ │ │ │ │ -Definition extractor.hh:344 │ │ │ │ │ -Dune::GridGlue::Extractor::getFaces │ │ │ │ │ -void getFaces(std::vector< VertexVector > &faces) const │ │ │ │ │ -Get the corners of the extracted subentities. │ │ │ │ │ -Definition extractor.hh:285 │ │ │ │ │ -Dune::GridGlue::Extractor::VertexVector │ │ │ │ │ -std::vector< unsigned int > VertexVector │ │ │ │ │ -Definition extractor.hh:69 │ │ │ │ │ -Dune::GridGlue::Extractor::gv_ │ │ │ │ │ -const GridView gv_ │ │ │ │ │ -the grid object to extract the surface from │ │ │ │ │ -Definition extractor.hh:191 │ │ │ │ │ -Dune::GridGlue::Extractor::subEntities_ │ │ │ │ │ -std::vector< SubEntityInfo > subEntities_ │ │ │ │ │ -all information about the extracted subEntities │ │ │ │ │ -Definition extractor.hh:199 │ │ │ │ │ -Dune::GridGlue::Extractor::cube_corners │ │ │ │ │ +Dune::GridGlue::Extractor<_GV,_1_>::cube_corners │ │ │ │ │ static constexpr int cube_corners │ │ │ │ │ Definition extractor.hh:54 │ │ │ │ │ -Dune::GridGlue::Extractor::vertex │ │ │ │ │ -Vertex vertex(unsigned int index) const │ │ │ │ │ -gets the vertex for a given coordinate index throws an exception if index not │ │ │ │ │ -valid │ │ │ │ │ -Definition extractor.hh:377 │ │ │ │ │ -Dune::GridGlue::Extractor::codim │ │ │ │ │ +Dune::GridGlue::Extractor<_GV,_1_>::codim │ │ │ │ │ static constexpr auto codim │ │ │ │ │ Definition extractor.hh:52 │ │ │ │ │ -Dune::GridGlue::Extractor::Coords │ │ │ │ │ -Dune::FieldVector< ctype, dimworld > Coords │ │ │ │ │ -Definition extractor.hh:60 │ │ │ │ │ -Dune::GridGlue::Extractor::getGeometryTypes │ │ │ │ │ -void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const │ │ │ │ │ -Get the list of geometry types. │ │ │ │ │ -Definition extractor.hh:274 │ │ │ │ │ -Dune::GridGlue::Extractor::CellMapper │ │ │ │ │ -MultipleCodimMultipleGeomTypeMapper< GridView > CellMapper │ │ │ │ │ -Definition extractor.hh:70 │ │ │ │ │ Dune::GridGlue::Extractor::VertexInfoMap │ │ │ │ │ std::map< IndexType, VertexInfo > VertexInfoMap │ │ │ │ │ Definition extractor.hh:186 │ │ │ │ │ -Dune::GridGlue::Extractor::Grid │ │ │ │ │ -GridView::Grid Grid │ │ │ │ │ -Definition extractor.hh:57 │ │ │ │ │ -Dune::GridGlue::Extractor::faceIndices │ │ │ │ │ -bool faceIndices(const Element &e, int &first, int &count) const │ │ │ │ │ -gets index of first subentity as well as the total number of subentities that │ │ │ │ │ -were extracted from thi... │ │ │ │ │ -Definition extractor.hh:304 │ │ │ │ │ -Dune::GridGlue::Extractor::geometry │ │ │ │ │ -Geometry geometry(unsigned int index) const │ │ │ │ │ -Get world geometry of the extracted face. │ │ │ │ │ -Definition extractor.hh:397 │ │ │ │ │ -Dune::GridGlue::Extractor::GridView │ │ │ │ │ -GV GridView │ │ │ │ │ -Definition extractor.hh:56 │ │ │ │ │ -Dune::GridGlue::Extractor::nCoords │ │ │ │ │ -unsigned int nCoords() const │ │ │ │ │ -getter for the count of coordinates │ │ │ │ │ -Definition extractor.hh:268 │ │ │ │ │ -Dune::GridGlue::Extractor::ctype │ │ │ │ │ -GV::Grid::ctype ctype │ │ │ │ │ -Definition extractor.hh:59 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementInfoMap │ │ │ │ │ -std::map< IndexType, ElementInfo > ElementInfoMap │ │ │ │ │ -Definition extractor.hh:185 │ │ │ │ │ -Dune::GridGlue::Extractor::Extractor │ │ │ │ │ -Extractor(const GV &gv) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition extractor.hh:225 │ │ │ │ │ -Dune::GridGlue::Extractor::getCoords │ │ │ │ │ -void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) │ │ │ │ │ -const │ │ │ │ │ -getter for the coordinates array │ │ │ │ │ -Definition extractor.hh:256 │ │ │ │ │ -Dune::GridGlue::Extractor::cellMapper_ │ │ │ │ │ -CellMapper cellMapper_ │ │ │ │ │ -Definition extractor.hh:215 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementSeed │ │ │ │ │ -Element::EntitySeed ElementSeed │ │ │ │ │ -Definition extractor.hh:67 │ │ │ │ │ -Dune::GridGlue::Extractor::VertexSeed │ │ │ │ │ -Vertex::EntitySeed VertexSeed │ │ │ │ │ -Definition extractor.hh:64 │ │ │ │ │ -Dune::GridGlue::Extractor::elmtInfo_ │ │ │ │ │ -ElementInfoMap elmtInfo_ │ │ │ │ │ -a map enabling faster access to elements and faces │ │ │ │ │ -Definition extractor.hh:213 │ │ │ │ │ -Dune::GridGlue::Extractor::clear │ │ │ │ │ -void clear() │ │ │ │ │ -delete everything build up so far and free the memory │ │ │ │ │ -Definition extractor.hh:235 │ │ │ │ │ -Dune::GridGlue::Extractor::dim │ │ │ │ │ +Dune::GridGlue::Extractor<_GV,_1_>::dim │ │ │ │ │ static constexpr auto dim │ │ │ │ │ Definition extractor.hh:51 │ │ │ │ │ -Dune::GridGlue::Extractor::LocalGeometry │ │ │ │ │ -Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry │ │ │ │ │ -Definition extractor.hh:78 │ │ │ │ │ -Dune::GridGlue::Extractor::CornerInfo │ │ │ │ │ -Helpful struct holding one index for the coordinate (vertex) to which it is │ │ │ │ │ -associated and the elemen... │ │ │ │ │ -Definition extractor.hh:88 │ │ │ │ │ -Dune::GridGlue::Extractor::CornerInfo::idx │ │ │ │ │ -unsigned int idx │ │ │ │ │ -index of the vertex │ │ │ │ │ -Definition extractor.hh:89 │ │ │ │ │ -Dune::GridGlue::Extractor::CornerInfo::num │ │ │ │ │ -unsigned int num │ │ │ │ │ -element corner │ │ │ │ │ -Definition extractor.hh:90 │ │ │ │ │ Dune::GridGlue::Extractor::CoordinateInfo │ │ │ │ │ Definition extractor.hh:94 │ │ │ │ │ -Dune::GridGlue::Extractor::CoordinateInfo::CoordinateInfo │ │ │ │ │ -CoordinateInfo(unsigned int index_, IndexType vtxindex_) │ │ │ │ │ -Definition extractor.hh:98 │ │ │ │ │ -Dune::GridGlue::Extractor::CoordinateInfo::index │ │ │ │ │ -unsigned int index │ │ │ │ │ -the index of this coordinate (in internal storage scheme) // NEEDED?? │ │ │ │ │ -Definition extractor.hh:109 │ │ │ │ │ -Dune::GridGlue::Extractor::CoordinateInfo::CoordinateInfo │ │ │ │ │ -CoordinateInfo() │ │ │ │ │ -Definition extractor.hh:95 │ │ │ │ │ -Dune::GridGlue::Extractor::CoordinateInfo::coord │ │ │ │ │ -Coords coord │ │ │ │ │ -the coordinate │ │ │ │ │ -Definition extractor.hh:106 │ │ │ │ │ -Dune::GridGlue::Extractor::CoordinateInfo::vtxindex │ │ │ │ │ -IndexType vtxindex │ │ │ │ │ -the index of the parent element (from index set) │ │ │ │ │ -Definition extractor.hh:103 │ │ │ │ │ Dune::GridGlue::Extractor::VertexInfo │ │ │ │ │ simple struct holding a vertex pointer and an index │ │ │ │ │ Definition extractor.hh:116 │ │ │ │ │ -Dune::GridGlue::Extractor::VertexInfo::idx │ │ │ │ │ -unsigned int idx │ │ │ │ │ -Definition extractor.hh:119 │ │ │ │ │ -Dune::GridGlue::Extractor::VertexInfo::VertexInfo │ │ │ │ │ -VertexInfo(unsigned int idx_, const Vertex &p_) │ │ │ │ │ -Definition extractor.hh:117 │ │ │ │ │ -Dune::GridGlue::Extractor::VertexInfo::p │ │ │ │ │ -VertexSeed p │ │ │ │ │ -Definition extractor.hh:120 │ │ │ │ │ Dune::GridGlue::Extractor::ElementInfo │ │ │ │ │ simple struct holding an element seed and an index │ │ │ │ │ Definition extractor.hh:128 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementInfo::idx │ │ │ │ │ -unsigned int idx │ │ │ │ │ -the index of this element's first face in the internal list of extracted faces │ │ │ │ │ -Definition extractor.hh:133 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementInfo::faces │ │ │ │ │ -unsigned int faces │ │ │ │ │ -the number of extracted faces for this element │ │ │ │ │ -Definition extractor.hh:136 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementInfo::ElementInfo │ │ │ │ │ -ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_) │ │ │ │ │ -Definition extractor.hh:129 │ │ │ │ │ -Dune::GridGlue::Extractor::ElementInfo::p │ │ │ │ │ -ElementSeed p │ │ │ │ │ -the entity seed for the element │ │ │ │ │ -Definition extractor.hh:139 │ │ │ │ │ Dune::GridGlue::Extractor::SubEntityInfo │ │ │ │ │ Holds some information about an element's subentity involved in a coupling. │ │ │ │ │ Definition extractor.hh:147 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::nCorners │ │ │ │ │ -unsigned int nCorners() const │ │ │ │ │ -Definition extractor.hh:161 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::corners │ │ │ │ │ -CornerInfo corners[cube_corners] │ │ │ │ │ -the corner indices plus the numbers of the vertices in the parent element │ │ │ │ │ -Definition extractor.hh:181 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::parent │ │ │ │ │ -IndexType parent │ │ │ │ │ -the index of the parent element (from index set) │ │ │ │ │ -Definition extractor.hh:167 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::SubEntityInfo │ │ │ │ │ -SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune:: │ │ │ │ │ -GeometryType &geometryType) │ │ │ │ │ -Definition extractor.hh:156 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::num_in_parent │ │ │ │ │ -unsigned int num_in_parent │ │ │ │ │ -the number of the face in the parent element │ │ │ │ │ -Definition extractor.hh:170 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::geometryType_ │ │ │ │ │ -Dune::GeometryType geometryType_ │ │ │ │ │ -The GeometryType of the subentity. │ │ │ │ │ -Definition extractor.hh:173 │ │ │ │ │ -Dune::GridGlue::Extractor::SubEntityInfo::SubEntityInfo │ │ │ │ │ -SubEntityInfo() │ │ │ │ │ -Definition extractor.hh:148 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: codim1extractor.hh File Reference │ │ │ │ +dune-grid-glue: extractor.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,44 +72,62 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
codim1extractor.hh File Reference
│ │ │ │ +
extractor.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Grid extractor class for codim 1 subgrids. │ │ │ │ +

extractor base class │ │ │ │ More...

│ │ │ │ -
#include "extractor.hh"
│ │ │ │ -#include <array>
│ │ │ │ -#include <deque>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <dune/common/deprecated.hh>
│ │ │ │ +
#include <vector>
│ │ │ │ +#include <map>
│ │ │ │ +#include <algorithm>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ #include <dune/common/version.hh>
│ │ │ │ -#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ +#include <dune/grid/common/geometry.hh>
│ │ │ │ +#include <dune/grid/common/grid.hh>
│ │ │ │ +#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +#include <dune/geometry/multilineargeometry.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ Classes

class  Dune::GridGlue::Codim1Extractor< GV >
class  Dune::GridGlue::Extractor< GV, cd >
 Provides codimension-independent methods for grid extraction. More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::CornerInfo
 Helpful struct holding one index for the coordinate (vertex) to which it is associated and the element's corner index;. More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::CoordinateInfo
 
struct  Dune::GridGlue::Extractor< GV, cd >::VertexInfo
 simple struct holding a vertex pointer and an index More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::ElementInfo
 simple struct holding an element seed and an index More...
 
struct  Dune::GridGlue::Extractor< GV, cd >::SubEntityInfo
 Holds some information about an element's subentity involved in a coupling. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 
namespace  Dune::GridGlue
 
│ │ │ │

Detailed Description

│ │ │ │ -

Grid extractor class for codim 1 subgrids.

│ │ │ │ +

extractor base class

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,29 +2,49 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * extractors │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -codim1extractor.hh File Reference │ │ │ │ │ -Grid extractor class for codim 1 subgrids. More... │ │ │ │ │ -#include "extractor.hh" │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +extractor.hh File Reference │ │ │ │ │ +extractor base class More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::GridGlue::Codim1Extractor<_GV_> │ │ │ │ │ + class   Dune::GridGlue::Extractor<_GV,_cd_> │ │ │ │ │ +  Provides codimension-independent methods for grid extraction. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Extractor<_GV,_cd_>::CornerInfo │ │ │ │ │ +  Helpful struct holding one index for the coordinate (vertex) to which │ │ │ │ │ + it is associated and the element's corner index;. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Extractor<_GV,_cd_>::CoordinateInfo │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Extractor<_GV,_cd_>::VertexInfo │ │ │ │ │ +  simple struct holding a vertex pointer and an index More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Extractor<_GV,_cd_>::ElementInfo │ │ │ │ │ +  simple struct holding an element seed and an index More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::GridGlue::Extractor<_GV,_cd_>::SubEntityInfo │ │ │ │ │ +  Holds some information about an element's subentity involved in a │ │ │ │ │ + coupling. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Grid extractor class for codim 1 subgrids. │ │ │ │ │ +extractor base class │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00059_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: codim1extractor.hh Source File │ │ │ │ +dune-grid-glue: extractor.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,400 +74,471 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
codim1extractor.hh
│ │ │ │ +
extractor.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/*
│ │ │ │ -
6 * Filename: codim1extractor.hh
│ │ │ │ +
6 * Filename: extractor.hh
│ │ │ │
7 * Version: 1.0
│ │ │ │ -
8 * Created on: Jun 23, 2009
│ │ │ │ -
9 * Author: Oliver Sander, Christian Engwer
│ │ │ │ +
8 * Created on: Oct 05, 2009
│ │ │ │ +
9 * Author: Christian Engwer
│ │ │ │
10 * ---------------------------------
│ │ │ │
11 * Project: dune-grid-glue
│ │ │ │ -
12 * Description: class for grid extractors extracting surface grids
│ │ │ │ +
12 * Description: base class for all grid extractors
│ │ │ │
13 *
│ │ │ │
14 */
│ │ │ │ -
20#ifndef DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │ -
21#define DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │ +
20#ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │ +
21#define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │
22
│ │ │ │ -
23#include "extractor.hh"
│ │ │ │ -
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>
│ │ │ │ -
42{
│ │ │ │ -
43public:
│ │ │ │ -
44
│ │ │ │ -
45 /* 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 */
│ │ │ │ -
46
│ │ │ │ -
47 using Extractor<GV,1>::dimworld;
│ │ │ │ -
48 using Extractor<GV,1>::dim;
│ │ │ │ -
49 using Extractor<GV,1>::codim;
│ │ │ │ -
50 using Extractor<GV,1>::cube_corners;
│ │ │ │ - │ │ │ │ -
52
│ │ │ │ -
54 static constexpr int simplex_corners = dim;
│ │ │ │ +
23#include <vector>
│ │ │ │ +
24#include <map>
│ │ │ │ +
25#include <algorithm>
│ │ │ │ +
26#include <dune/common/exceptions.hh>
│ │ │ │ +
27#include <dune/common/fvector.hh>
│ │ │ │ +
28#include <dune/common/version.hh>
│ │ │ │ +
29#include <dune/grid/common/geometry.hh>
│ │ │ │ +
30#include <dune/grid/common/grid.hh>
│ │ │ │ +
31#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ +
32#include <dune/geometry/multilineargeometry.hh>
│ │ │ │ +
33
│ │ │ │ +
34namespace Dune {
│ │ │ │ +
35
│ │ │ │ +
36 namespace GridGlue {
│ │ │ │ +
37
│ │ │ │ +
44template<typename GV, int cd>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
46{
│ │ │ │ +
47
│ │ │ │ +
48public:
│ │ │ │ +
49
│ │ │ │ +
50 static constexpr auto dimworld = GV::dimensionworld;
│ │ │ │ +
51 static constexpr auto dim = GV::dimension;
│ │ │ │ +
52 static constexpr auto codim = cd;
│ │ │ │ +
53
│ │ │ │ +
54 static constexpr int cube_corners = 1 << (dim-codim);
│ │ │ │
55
│ │ │ │ -
56 typedef GV GridView;
│ │ │ │ -
57
│ │ │ │ -
58 typedef typename GV::Grid::ctype ctype;
│ │ │ │ -
59 typedef Dune::FieldVector<ctype, dimworld> Coords;
│ │ │ │ -
60
│ │ │ │ -
61 typedef typename GV::Traits::template Codim<dim>::Entity Vertex;
│ │ │ │ -
62 typedef typename GV::Traits::template Codim<0>::Entity Element;
│ │ │ │ -
63 typedef std::function<bool(const Element&, unsigned int subentity)> Predicate;
│ │ │ │ -
64
│ │ │ │ -
65 // import typedefs from base class
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
56 typedef GV GridView;
│ │ │ │ +
57 typedef typename GridView::Grid Grid;
│ │ │ │ +
58
│ │ │ │ +
59 typedef typename GV::Grid::ctype ctype;
│ │ │ │ +
60 typedef Dune::FieldVector<ctype, dimworld> Coords;
│ │ │ │ +
61 typedef Dune::FieldVector<ctype, dim> LocalCoords;
│ │ │ │ +
62
│ │ │ │ +
63 typedef typename GV::Traits::template Codim<dim>::Entity Vertex;
│ │ │ │ +
64 typedef typename Vertex::EntitySeed VertexSeed;
│ │ │ │ +
65
│ │ │ │ +
66 typedef typename GV::Traits::template Codim<0>::Entity Element;
│ │ │ │ +
67 typedef typename Element::EntitySeed ElementSeed;
│ │ │ │ +
68
│ │ │ │ +
69 typedef std::vector<unsigned int> VertexVector;
│ │ │ │ +
70 using CellMapper = MultipleCodimMultipleGeomTypeMapper<GridView>;
│ │ │ │
71
│ │ │ │ -
72public:
│ │ │ │ -
73
│ │ │ │ -
74 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */
│ │ │ │ +
72 // typedef typename CellMapper::IndexType IndexType;
│ │ │ │ +
73 typedef int IndexType;
│ │ │ │ +
74public:
│ │ │ │
75
│ │ │ │ -
│ │ │ │ -
81 Codim1Extractor(const GV& gv, const Predicate& predicate)
│ │ │ │ -
82 : Extractor<GV,1>(gv)
│ │ │ │ -
83 {
│ │ │ │ -
84 std::cout << "This is Codim1Extractor on a <" << dim
│ │ │ │ -
85 << "," << dimworld << "> grid!"
│ │ │ │ -
86 << std::endl;
│ │ │ │ -
87 update(predicate);
│ │ │ │ -
88 }
│ │ │ │ -
│ │ │ │ -
89
│ │ │ │ -
90private:
│ │ │ │ -
91
│ │ │ │ -
105 void update(const Predicate& predicate);
│ │ │ │ -
106
│ │ │ │ -
107};
│ │ │ │ -
│ │ │ │ -
108
│ │ │ │ -
109
│ │ │ │ -
110template<typename GV>
│ │ │ │ -
111void Codim1Extractor<GV>::update(const Predicate& predicate)
│ │ │ │ -
112{
│ │ │ │ -
113 // free everything there is in this object
│ │ │ │ -
114 this->clear();
│ │ │ │ -
115
│ │ │ │ -
116 // In this first pass iterate over all entities of codim 0.
│ │ │ │ -
117 // For each codim 1 intersection check if it is part of the boundary and if so,
│ │ │ │ -
118 // get its corner vertices, find resp. store them together with their associated index,
│ │ │ │ -
119 // and remember the indices of the boundary faces' corners.
│ │ │ │ -
120 {
│ │ │ │ -
121 // several counter for consecutive indexing are needed
│ │ │ │ -
122 int simplex_index = 0;
│ │ │ │ -
123 int vertex_index = 0;
│ │ │ │ -
124 IndexType eindex = 0; // suppress warning
│ │ │ │ -
125
│ │ │ │ -
126 // needed later for insertion into a std::set which only
│ │ │ │ -
127 // works with const references
│ │ │ │ -
128
│ │ │ │ -
129 // a temporary container where newly acquired face
│ │ │ │ -
130 // information can be stored at first
│ │ │ │ -
131 std::deque<SubEntityInfo> temp_faces;
│ │ │ │ -
132
│ │ │ │ -
133 // iterate over interior codim 0 elements on the grid
│ │ │ │ -
134 for (const auto& elmt : elements(this->gv_, Partitions::interior))
│ │ │ │ -
135 {
│ │ │ │ -
136 Dune::GeometryType gt = elmt.type();
│ │ │ │ +
76 // transformations
│ │ │ │ +
77 typedef Dune::MultiLinearGeometry<ctype, dim-codim, dimworld> Geometry;
│ │ │ │ +
78 typedef Dune::MultiLinearGeometry<ctype, dim-codim, dim> LocalGeometry;
│ │ │ │ +
79
│ │ │ │ +
80protected:
│ │ │ │ +
81 /************************** PRIVATE SUBCLASSES **********************/
│ │ │ │ +
82
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
88 {
│ │ │ │ +
89 unsigned int idx : 28;
│ │ │ │ +
90 unsigned int num : 4;
│ │ │ │ +
91 };
│ │ │ │ +
│ │ │ │ +
92
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
94 {
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
96 {}
│ │ │ │ +
│ │ │ │ +
97
│ │ │ │ +
│ │ │ │ +
98 CoordinateInfo(unsigned int index_, IndexType vtxindex_)
│ │ │ │ +
99 : vtxindex(vtxindex_), index(index_)
│ │ │ │ +
100 {}
│ │ │ │ +
│ │ │ │ +
101
│ │ │ │ + │ │ │ │ +
104
│ │ │ │ + │ │ │ │ +
107
│ │ │ │ +
109 unsigned int index;
│ │ │ │ +
110 };
│ │ │ │ +
│ │ │ │ +
111
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
116 {
│ │ │ │ +
│ │ │ │ +
117 VertexInfo(unsigned int idx_, const Vertex& p_) : idx(idx_), p(p_.seed())
│ │ │ │ +
118 {}
│ │ │ │ +
│ │ │ │ +
119 unsigned int idx;
│ │ │ │ + │ │ │ │ +
121 };
│ │ │ │ +
│ │ │ │ +
122
│ │ │ │ +
123
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
128 {
│ │ │ │ +
│ │ │ │ +
129 ElementInfo(unsigned int idx_, const Element& p_, unsigned int f_) : idx(idx_), faces(f_), p(p_.seed())
│ │ │ │ +
130 {}
│ │ │ │ +
│ │ │ │ +
131
│ │ │ │ +
133 unsigned int idx : 28;
│ │ │ │ +
134
│ │ │ │ +
136 unsigned int faces : 4;
│ │ │ │
137
│ │ │ │ -
138 // if some face is part of the surface add it!
│ │ │ │ -
139 if (elmt.hasBoundaryIntersections())
│ │ │ │ -
140 {
│ │ │ │ -
141 // add an entry to the element info map, the index will be set properly later,
│ │ │ │ -
142 // whereas the number of faces is already known
│ │ │ │ -
143 eindex = this->cellMapper_.index(elmt);
│ │ │ │ -
144 this->elmtInfo_.emplace(eindex, ElementInfo(simplex_index, elmt, 0));
│ │ │ │ -
145
│ │ │ │ -
146 // now add the faces in ascending order of their indices
│ │ │ │ -
147 // (we are only talking about 1-4 faces here, so O(n^2) is ok!)
│ │ │ │ -
148 for (const auto& in : intersections(this->gv_, elmt))
│ │ │ │ -
149 {
│ │ │ │ -
150 // Stop only at selected boundary faces
│ │ │ │ -
151 if (!in.boundary() or !predicate(elmt, in.indexInInside()))
│ │ │ │ -
152 continue;
│ │ │ │ -
153
│ │ │ │ -
154 const auto& refElement = Dune::ReferenceElements<ctype, dim>::general(gt);
│ │ │ │ -
155 // get the corner count of this face
│ │ │ │ -
156 const int face_corners = refElement.size(in.indexInInside(), 1, dim);
│ │ │ │ -
157
│ │ │ │ -
158 // now we only have to care about the 3D case, i.e. a triangle face can be
│ │ │ │ -
159 // inserted directly whereas a quadrilateral face has to be divided into two triangles
│ │ │ │ -
160 switch (face_corners)
│ │ │ │ -
161 {
│ │ │ │ -
162 case 2 :
│ │ │ │ -
163 case 3:
│ │ │ │ -
164 {
│ │ │ │ -
165 // we have a simplex here
│ │ │ │ -
166
│ │ │ │ -
167 // register the additional face(s)
│ │ │ │ -
168 this->elmtInfo_.at(eindex).faces++;
│ │ │ │ -
169
│ │ │ │ -
170 // add a new face to the temporary collection
│ │ │ │ -
171 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ -
172 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ -
173
│ │ │ │ -
174 std::vector<FieldVector<ctype,dimworld> > cornerCoords(face_corners);
│ │ │ │ -
175
│ │ │ │ -
176 // try for each of the faces vertices whether it is already inserted or not
│ │ │ │ -
177 for (int i = 0; i < face_corners; ++i)
│ │ │ │ -
178 {
│ │ │ │ -
179 // get the number of the vertex in the parent element
│ │ │ │ -
180 int vertex_number = refElement.subEntity(in.indexInInside(), 1, i, dim);
│ │ │ │ -
181
│ │ │ │ -
182 // get the vertex pointer and the index from the index set
│ │ │ │ -
183 const Vertex vertex = elmt.template subEntity<dim>(vertex_number);
│ │ │ │ -
184 cornerCoords[i] = vertex.geometry().corner(0);
│ │ │ │ -
185
│ │ │ │ -
186 IndexType vindex = this->gv_.indexSet().template index<dim>(vertex);
│ │ │ │ + │ │ │ │ +
140 };
│ │ │ │ +
│ │ │ │ +
141
│ │ │ │ +
142
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
147 {
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
149 /*
│ │ │ │ +
150 * TODO: move default value of `geometryType_` to member declaration
│ │ │ │ +
151 * when removing support for older dune-geometry
│ │ │ │ +
152 */
│ │ │ │ +
153 : geometryType_(GeometryTypes::simplex(dim-codim))
│ │ │ │ +
154 {}
│ │ │ │ +
│ │ │ │ +
155
│ │ │ │ +
│ │ │ │ +
156 SubEntityInfo(IndexType parent_, unsigned int num_in_parent_,
│ │ │ │ +
157 const Dune::GeometryType& geometryType)
│ │ │ │ +
158 : parent(parent_), num_in_parent(num_in_parent_), geometryType_(geometryType)
│ │ │ │ +
159 {}
│ │ │ │ +
│ │ │ │ +
160
│ │ │ │ +
│ │ │ │ +
161 unsigned int nCorners() const
│ │ │ │ +
162 {
│ │ │ │ +
163 return Dune::ReferenceElements<ctype, dim-codim>::general(geometryType_).size(dim-codim);
│ │ │ │ +
164 }
│ │ │ │ +
│ │ │ │ +
165
│ │ │ │ + │ │ │ │ +
168
│ │ │ │ +
170 unsigned int num_in_parent : 3;
│ │ │ │ +
171
│ │ │ │ +
173 Dune::GeometryType geometryType_;
│ │ │ │ +
174
│ │ │ │ +
181 CornerInfo corners[cube_corners]; // sim = number of vertices in a simplex
│ │ │ │ +
182 };
│ │ │ │ +
│ │ │ │ +
183
│ │ │ │ +
184
│ │ │ │ +
185 typedef std::map<IndexType, ElementInfo> ElementInfoMap;
│ │ │ │ +
186 typedef std::map<IndexType, VertexInfo> VertexInfoMap;
│ │ │ │
187
│ │ │ │ -
188 // remember the vertex' number in parent element's vertices
│ │ │ │ -
189 temp_faces.back().corners[i].num = vertex_number;
│ │ │ │ -
190
│ │ │ │ -
191 // if the vertex is not yet inserted in the vertex info map
│ │ │ │ -
192 // it is a new one -> it will be inserted now!
│ │ │ │ -
193 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex);
│ │ │ │ -
194 if (vimit == this->vtxInfo_.end())
│ │ │ │ -
195 {
│ │ │ │ -
196 // insert into the map
│ │ │ │ -
197 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex));
│ │ │ │ -
198 // remember the vertex as a corner of the current face in temp_faces
│ │ │ │ -
199 temp_faces.back().corners[i].idx = vertex_index;
│ │ │ │ -
200 // increase the current index
│ │ │ │ -
201 vertex_index++;
│ │ │ │ -
202 }
│ │ │ │ -
203 else
│ │ │ │ -
204 {
│ │ │ │ -
205 // only insert the index into the simplices array
│ │ │ │ -
206 temp_faces.back().corners[i].idx = vimit->second.idx;
│ │ │ │ -
207 }
│ │ │ │ -
208 }
│ │ │ │ -
209
│ │ │ │ -
210 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ -
211 // have the wrong orientation. We want them to be oriented such that all boundary edges
│ │ │ │ -
212 // point in the counterclockwise direction. Therefore, we check the orientation of the
│ │ │ │ -
213 // new face and possibly switch the two vertices.
│ │ │ │ -
214 FieldVector<ctype,dimworld> realNormal = in.centerUnitOuterNormal();
│ │ │ │ -
215
│ │ │ │ -
216 // Compute segment normal
│ │ │ │ -
217 FieldVector<ctype,dimworld> reconstructedNormal;
│ │ │ │ -
218 if (dim==2) // boundary face is a line segment
│ │ │ │ -
219 {
│ │ │ │ -
220 reconstructedNormal[0] = cornerCoords[1][1] - cornerCoords[0][1];
│ │ │ │ -
221 reconstructedNormal[1] = cornerCoords[0][0] - cornerCoords[1][0];
│ │ │ │ -
222 } else { // boundary face is a triangle
│ │ │ │ -
223 FieldVector<ctype,dimworld> segment1 = cornerCoords[1] - cornerCoords[0];
│ │ │ │ -
224 FieldVector<ctype,dimworld> segment2 = cornerCoords[2] - cornerCoords[0];
│ │ │ │ -
225 reconstructedNormal = crossProduct(segment1, segment2);
│ │ │ │ -
226 }
│ │ │ │ -
227 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ -
228
│ │ │ │ -
229 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ -
230 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │ +
188 /************************** MEMBER VARIABLES ************************/
│ │ │ │ +
189
│ │ │ │ + │ │ │ │ +
192
│ │ │ │ +
193 /* Geometrical and Topological Information */
│ │ │ │ +
194
│ │ │ │ +
196 std::vector<CoordinateInfo> coords_;
│ │ │ │ +
197
│ │ │ │ +
199 std::vector<SubEntityInfo> subEntities_;
│ │ │ │ +
200
│ │ │ │ + │ │ │ │ +
207
│ │ │ │ + │ │ │ │ +
214
│ │ │ │ + │ │ │ │ +
216
│ │ │ │ +
217public:
│ │ │ │ +
218
│ │ │ │ +
219 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */
│ │ │ │ +
220
│ │ │ │ +
│ │ │ │ +
225 Extractor(const GV& gv)
│ │ │ │ +
226 : gv_(gv)
│ │ │ │ +
227 , cellMapper_(gv, mcmgElementLayout())
│ │ │ │ +
228 {}
│ │ │ │ +
│ │ │ │ +
229
│ │ │ │ +
230 /* F U N C T I O N A L I T Y */
│ │ │ │
231
│ │ │ │ -
232 // now increase the current face index
│ │ │ │ -
233 simplex_index++;
│ │ │ │ -
234 break;
│ │ │ │ -
235 }
│ │ │ │ -
236 case 4 :
│ │ │ │ -
237 {
│ │ │ │ -
238 assert(dim == 3 && cube_corners == 4);
│ │ │ │ -
239 // we have a quadrilateral here
│ │ │ │ -
240 std::array<unsigned int, 4> vertex_indices;
│ │ │ │ -
241 std::array<unsigned int, 4> vertex_numbers;
│ │ │ │ +
│ │ │ │ +
235 void clear()
│ │ │ │ +
236 {
│ │ │ │ +
237 coords_.clear();
│ │ │ │ +
238 coords_.shrink_to_fit();
│ │ │ │ +
239
│ │ │ │ +
240 subEntities_.clear();
│ │ │ │ +
241 subEntities_.shrink_to_fit();
│ │ │ │
242
│ │ │ │ -
243 // register the additional face(s) (2 simplices)
│ │ │ │ -
244 this->elmtInfo_.at(eindex).faces += 2;
│ │ │ │ -
245
│ │ │ │ -
246 std::array<FieldVector<ctype,dimworld>, 4> cornerCoords;
│ │ │ │ +
243 // ...then clear the maps themselves, too
│ │ │ │ +
244 vtxInfo_.clear();
│ │ │ │ +
245 elmtInfo_.clear();
│ │ │ │ +
246 }
│ │ │ │ +
│ │ │ │
247
│ │ │ │ -
248 // get the vertex pointers for the quadrilateral's corner vertices
│ │ │ │ -
249 // and try for each of them whether it is already inserted or not
│ │ │ │ -
250 for (int i = 0; i < cube_corners; ++i)
│ │ │ │ -
251 {
│ │ │ │ -
252 // get the number of the vertex in the parent element
│ │ │ │ -
253 vertex_numbers[i] = refElement.subEntity(in.indexInInside(), 1, i, dim);
│ │ │ │ -
254
│ │ │ │ -
255 // get the vertex pointer and the index from the index set
│ │ │ │ -
256 const Vertex vertex = elmt.template subEntity<dim>(vertex_numbers[i]);
│ │ │ │ -
257 cornerCoords[i] = vertex.geometry().corner(0);
│ │ │ │ -
258
│ │ │ │ -
259 IndexType vindex = this->gv_.indexSet().template index<dim>(vertex);
│ │ │ │ -
260
│ │ │ │ -
261 // if the vertex is not yet inserted in the vertex info map
│ │ │ │ -
262 // it is a new one -> it will be inserted now!
│ │ │ │ -
263 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex);
│ │ │ │ -
264 if (vimit == this->vtxInfo_.end())
│ │ │ │ -
265 {
│ │ │ │ -
266 // insert into the map
│ │ │ │ -
267 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex));
│ │ │ │ -
268 // remember this vertex' index
│ │ │ │ -
269 vertex_indices[i] = vertex_index;
│ │ │ │ -
270 // increase the current index
│ │ │ │ -
271 vertex_index++;
│ │ │ │ -
272 }
│ │ │ │ -
273 else
│ │ │ │ -
274 {
│ │ │ │ -
275 // only remember the vertex' index
│ │ │ │ -
276 vertex_indices[i] = vimit->second.idx;
│ │ │ │ -
277 }
│ │ │ │ -
278 }
│ │ │ │ -
279
│ │ │ │ -
280 // now introduce the two triangles subdividing the quadrilateral
│ │ │ │ -
281 // ATTENTION: the order of vertices given by "orientedSubface" corresponds to the order
│ │ │ │ -
282 // of a Dune quadrilateral, i.e. the triangles are given by 0 1 2 and 3 2 1
│ │ │ │ -
283
│ │ │ │ -
284 // add a new face to the temporary collection for the first tri
│ │ │ │ -
285 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ -
286 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ -
287 temp_faces.back().corners[0].idx = vertex_indices[0];
│ │ │ │ -
288 temp_faces.back().corners[1].idx = vertex_indices[1];
│ │ │ │ -
289 temp_faces.back().corners[2].idx = vertex_indices[2];
│ │ │ │ -
290 // remember the vertices' numbers in parent element's vertices
│ │ │ │ -
291 temp_faces.back().corners[0].num = vertex_numbers[0];
│ │ │ │ -
292 temp_faces.back().corners[1].num = vertex_numbers[1];
│ │ │ │ -
293 temp_faces.back().corners[2].num = vertex_numbers[2];
│ │ │ │ +
248
│ │ │ │ +
249 /* G E T T E R S */
│ │ │ │ +
250
│ │ │ │ +
│ │ │ │ +
256 void getCoords(std::vector<Dune::FieldVector<ctype, dimworld> >& coords) const
│ │ │ │ +
257 {
│ │ │ │ +
258 coords.resize(coords_.size());
│ │ │ │ +
259 for (unsigned int i = 0; i < coords_.size(); ++i)
│ │ │ │ +
260 coords[i] = coords_[i].coord;
│ │ │ │ +
261 }
│ │ │ │ +
│ │ │ │ +
262
│ │ │ │ +
263
│ │ │ │ +
│ │ │ │ +
268 unsigned int nCoords() const
│ │ │ │ +
269 {
│ │ │ │ +
270 return coords_.size();
│ │ │ │ +
271 }
│ │ │ │ +
│ │ │ │ +
272
│ │ │ │ +
│ │ │ │ +
274 void getGeometryTypes(std::vector<Dune::GeometryType>& geometryTypes) const
│ │ │ │ +
275 {
│ │ │ │ +
276 geometryTypes.resize(subEntities_.size());
│ │ │ │ +
277 for (size_t i=0; i<subEntities_.size(); i++)
│ │ │ │ +
278 geometryTypes[i] = subEntities_[i].geometryType_;
│ │ │ │ +
279 }
│ │ │ │ +
│ │ │ │ +
280
│ │ │ │ +
281
│ │ │ │ +
│ │ │ │ +
285 void getFaces(std::vector<VertexVector>& faces) const
│ │ │ │ +
286 {
│ │ │ │ +
287 faces.resize(subEntities_.size());
│ │ │ │ +
288 for (unsigned int i = 0; i < subEntities_.size(); ++i) {
│ │ │ │ +
289 faces[i].resize(subEntities_[i].nCorners());
│ │ │ │ +
290 for (unsigned int j = 0; j < subEntities_[i].nCorners(); ++j)
│ │ │ │ +
291 faces[i][j] = subEntities_[i].corners[j].idx;
│ │ │ │ +
292 }
│ │ │ │ +
293 }
│ │ │ │ +
│ │ │ │
294
│ │ │ │ -
295 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ -
296 // have the wrong orientation. We want the triangle vertices on counterclockwise order,
│ │ │ │ -
297 // when viewed from the outside of the grid. Therefore, we check the orientation of the
│ │ │ │ -
298 // new face and possibly switch two vertices.
│ │ │ │ -
299 FieldVector<ctype,dimworld> realNormal = in.centerUnitOuterNormal();
│ │ │ │ -
300
│ │ │ │ -
301 // Compute segment normal
│ │ │ │ -
302 FieldVector<ctype,dimworld> reconstructedNormal = crossProduct(cornerCoords[1] - cornerCoords[0],
│ │ │ │ -
303 cornerCoords[2] - cornerCoords[0]);
│ │ │ │ -
304 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ -
305
│ │ │ │ -
306 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ -
307 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │ -
308
│ │ │ │ -
309
│ │ │ │ -
310 // add a new face to the temporary collection for the second tri
│ │ │ │ -
311 temp_faces.emplace_back(eindex, in.indexInInside(),
│ │ │ │ -
312 Dune::GeometryTypes::simplex(dim-codim));
│ │ │ │ -
313 temp_faces.back().corners[0].idx = vertex_indices[3];
│ │ │ │ -
314 temp_faces.back().corners[1].idx = vertex_indices[2];
│ │ │ │ -
315 temp_faces.back().corners[2].idx = vertex_indices[1];
│ │ │ │ -
316 // remember the vertices' numbers in parent element's vertices
│ │ │ │ -
317 temp_faces.back().corners[0].num = vertex_numbers[3];
│ │ │ │ -
318 temp_faces.back().corners[1].num = vertex_numbers[2];
│ │ │ │ -
319 temp_faces.back().corners[2].num = vertex_numbers[1];
│ │ │ │ +
295
│ │ │ │ +
│ │ │ │ +
304 bool faceIndices(const Element& e, int& first, int& count) const
│ │ │ │ +
305 {
│ │ │ │ +
306 typename ElementInfoMap::const_iterator it =
│ │ │ │ +
307 elmtInfo_.find(cellMapper_.map(e));
│ │ │ │ +
308 if (it == elmtInfo_.end())
│ │ │ │ +
309 {
│ │ │ │ +
310 first = -1;
│ │ │ │ +
311 count = 0;
│ │ │ │ +
312 return false;
│ │ │ │ +
313 }
│ │ │ │ +
314 // the iterator is valid, fill the out params
│ │ │ │ +
315 first = it->second.idx;
│ │ │ │ +
316 count = it->second.faces;
│ │ │ │ +
317 return true;
│ │ │ │ +
318 }
│ │ │ │ +
│ │ │ │ +
319
│ │ │ │
320
│ │ │ │ -
321 // Now we have the correct vertices in the last entries of temp_faces, but they may
│ │ │ │ -
322 // have the wrong orientation. We want the triangle vertices on counterclockwise order,
│ │ │ │ -
323 // when viewed from the outside of the grid. Therefore, we check the orientation of the
│ │ │ │ -
324 // new face and possibly switch two vertices.
│ │ │ │ -
325 // Compute segment normal
│ │ │ │ -
326 reconstructedNormal = crossProduct(cornerCoords[2] - cornerCoords[3],
│ │ │ │ -
327 cornerCoords[1] - cornerCoords[3]);
│ │ │ │ -
328 reconstructedNormal /= reconstructedNormal.two_norm();
│ │ │ │ -
329
│ │ │ │ -
330 if (realNormal * reconstructedNormal < 0.0)
│ │ │ │ -
331 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]);
│ │ │ │ -
332
│ │ │ │ -
333 simplex_index+=2;
│ │ │ │ -
334 break;
│ │ │ │ -
335 }
│ │ │ │ -
336 default :
│ │ │ │ -
337 DUNE_THROW(Dune::NotImplemented, "the extractor does only work for triangle and quadrilateral faces (" << face_corners << " corners)");
│ │ │ │ -
338 break;
│ │ │ │ -
339 }
│ │ │ │ -
340 } // end loop over found surface parts
│ │ │ │ -
341 }
│ │ │ │ -
342 } // end loop over elements
│ │ │ │ -
343
│ │ │ │ -
344 std::cout << "added " << simplex_index << " subfaces\n";
│ │ │ │ -
345
│ │ │ │ -
346 // allocate the array for the face specific information...
│ │ │ │ -
347 this->subEntities_.resize(simplex_index);
│ │ │ │ -
348 // ...and fill in the data from the temporary containers
│ │ │ │ -
349 copy(temp_faces.begin(), temp_faces.end(), this->subEntities_.begin());
│ │ │ │ -
350 }
│ │ │ │ -
351
│ │ │ │ -
352
│ │ │ │ -
353 // now first write the array with the coordinates...
│ │ │ │ -
354 this->coords_.resize(this->vtxInfo_.size());
│ │ │ │ -
355 for (const auto& vinfo : this->vtxInfo_)
│ │ │ │ -
356 {
│ │ │ │ -
357 // get a pointer to the associated info object
│ │ │ │ -
358 CoordinateInfo* current = &this->coords_[vinfo.second.idx];
│ │ │ │ -
359 // store this coordinates index // NEEDED?
│ │ │ │ -
360 current->index = vinfo.second.idx;
│ │ │ │ -
361 // store the vertex' index for the index2vertex mapping
│ │ │ │ -
362 current->vtxindex = vinfo.first;
│ │ │ │ -
363 // store the vertex' coordinates under the associated index
│ │ │ │ -
364 // in the coordinates array
│ │ │ │ -
365 const auto vtx = this->grid().entity(vinfo.second.p);
│ │ │ │ -
366 current->coord = vtx.geometry().corner(0);
│ │ │ │ +
│ │ │ │ +
326 int indexInInside(unsigned int index) const
│ │ │ │ +
327 {
│ │ │ │ +
328 return index < subEntities_.size() ? subEntities_[index].num_in_parent : -1;
│ │ │ │ +
329 }
│ │ │ │ +
│ │ │ │ +
330
│ │ │ │ +
331 // /**
│ │ │ │ +
332 // * @brief tests that a given entry in the extraction set does have local couplings
│ │ │ │ +
333 // * @todo parallel interface
│ │ │ │ +
334 // */
│ │ │ │ +
335 // bool contains (unsigned int global, unsigned int & local) const
│ │ │ │ +
336 // {
│ │ │ │ +
337 // local = global;
│ │ │ │ +
338 // return true;
│ │ │ │ +
339 // }
│ │ │ │ +
340
│ │ │ │ +
│ │ │ │ +
344 const GridView & gridView() const
│ │ │ │ +
345 {
│ │ │ │ +
346 return gv_;
│ │ │ │ +
347 }
│ │ │ │ +
│ │ │ │ +
348
│ │ │ │ +
│ │ │ │ +
349 const Grid& grid() const
│ │ │ │ +
350 {
│ │ │ │ +
351 return gv_.grid();
│ │ │ │ +
352 }
│ │ │ │ +
│ │ │ │ +
353
│ │ │ │ +
360 Element
│ │ │ │ +
│ │ │ │ +
361 element(unsigned int index) const
│ │ │ │ +
362 {
│ │ │ │ +
363 if (index >= subEntities_.size())
│ │ │ │ +
364 DUNE_THROW(Dune::GridError, "invalid face index");
│ │ │ │ +
365 const ElementSeed seed = elmtInfo_.at(subEntities_[index].parent).p;
│ │ │ │ +
366 return grid().entity(seed);
│ │ │ │
367 }
│ │ │ │ +
│ │ │ │
368
│ │ │ │ -
369}
│ │ │ │ -
370
│ │ │ │ -
371} // namespace GridGlue
│ │ │ │ -
372
│ │ │ │ -
373} // namespace Dune
│ │ │ │ -
374
│ │ │ │ -
375#endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH
│ │ │ │ - │ │ │ │ -
extractor base class
│ │ │ │ +
369#if 1
│ │ │ │ +
376 Vertex
│ │ │ │ +
│ │ │ │ +
377 vertex(unsigned int index) const
│ │ │ │ +
378 {
│ │ │ │ +
379 if (index >= coords_.size())
│ │ │ │ +
380 DUNE_THROW(Dune::GridError, "invalid coordinate index");
│ │ │ │ +
381 const VertexSeed seed = vtxInfo_.at(coords_[index].vtxindex).p;
│ │ │ │ +
382 return grid().entity(seed);
│ │ │ │ +
383 }
│ │ │ │ +
│ │ │ │ +
384#endif
│ │ │ │ +
385
│ │ │ │ +
│ │ │ │ +
387 Geometry geometry(unsigned int index) const;
│ │ │ │ +
388
│ │ │ │ +
│ │ │ │ +
390 LocalGeometry geometryLocal(unsigned int index) const;
│ │ │ │ +
391
│ │ │ │ +
392};
│ │ │ │ +
393
│ │ │ │ +
394
│ │ │ │ +
396template<typename GV, int cd>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
398{
│ │ │ │ +
399 std::vector<Coords> corners(subEntities_[index].nCorners());
│ │ │ │ +
400 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
│ │ │ │ +
401 corners[i] = coords_[subEntities_[index].corners[i].idx].coord;
│ │ │ │ +
402
│ │ │ │ +
403 return Geometry(subEntities_[index].geometryType_, corners);
│ │ │ │ +
404}
│ │ │ │ +
│ │ │ │ +
405
│ │ │ │ +
406
│ │ │ │ +
408template<typename GV, int cd>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
410{
│ │ │ │ +
411 std::vector<LocalCoords> corners(subEntities_[index].nCorners());
│ │ │ │ +
412
│ │ │ │ +
413 // get face info
│ │ │ │ +
414 const SubEntityInfo & face = subEntities_[index];
│ │ │ │ +
415 Dune::GeometryType facetype = subEntities_[index].geometryType_;
│ │ │ │ +
416
│ │ │ │ +
417 // get reference element
│ │ │ │ +
418 const auto elmtseed = elmtInfo_.at(face.parent).p;
│ │ │ │ +
419 const auto elmt = grid().entity(elmtseed);
│ │ │ │ +
420 const Dune::GeometryType celltype = elmt.type();
│ │ │ │ +
421 const auto& re = Dune::ReferenceElements<ctype, dim>::general(celltype);
│ │ │ │ +
422 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i)
│ │ │ │ +
423 corners[i] = re.position(face.corners[i].num,dim);
│ │ │ │ +
424
│ │ │ │ +
425 return LocalGeometry(facetype, corners);
│ │ │ │ +
426}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
427
│ │ │ │ +
428} // namespace GridGlue
│ │ │ │ +
429
│ │ │ │ +
430} // namespace Dune
│ │ │ │ +
431
│ │ │ │ +
432#endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH
│ │ │ │ +
│ │ │ │ +
│ │ │ │
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
│ │ │ │ -
GV::Traits::template Codim< 0 >::Entity Element
Definition codim1extractor.hh:62
│ │ │ │ -
Dune::FieldVector< ctype, dimworld > Coords
Definition codim1extractor.hh:59
│ │ │ │ -
GV::Grid::ctype ctype
Definition codim1extractor.hh:58
│ │ │ │ -
Codim1Extractor(const GV &gv, const Predicate &predicate)
Constructor.
Definition codim1extractor.hh:81
│ │ │ │ -
static constexpr int simplex_corners
compile time number of corners of surface simplices
Definition codim1extractor.hh:54
│ │ │ │ -
Extractor< GV, 1 >::VertexInfo VertexInfo
Definition codim1extractor.hh:68
│ │ │ │ -
Extractor< GV, 1 >::CoordinateInfo CoordinateInfo
Definition codim1extractor.hh:69
│ │ │ │ -
Extractor< GV, 1 >::ElementInfo ElementInfo
Definition codim1extractor.hh:67
│ │ │ │ -
Extractor< GV, 1 >::SubEntityInfo SubEntityInfo
Definition codim1extractor.hh:66
│ │ │ │ -
Extractor< GV, 1 >::VertexInfoMap VertexInfoMap
Definition codim1extractor.hh:70
│ │ │ │ -
std::function< bool(const Element &, unsigned int subentity)> Predicate
Definition codim1extractor.hh:63
│ │ │ │ -
GV::Traits::template Codim< dim >::Entity Vertex
Definition codim1extractor.hh:61
│ │ │ │
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
│ │ │ │ -
static constexpr auto dimworld
Definition extractor.hh:50
│ │ │ │ +
GV::Traits::template Codim< dim >::Entity Vertex
Definition extractor.hh:63
│ │ │ │ +
VertexInfoMap vtxInfo_
a map enabling faster access to vertices and coordinates
Definition extractor.hh:206
│ │ │ │ +
const Grid & grid() const
Definition extractor.hh:349
│ │ │ │ +
Element element(unsigned int index) const
gets the parent element for a given face index, throws an exception if index not valid
Definition extractor.hh:361
│ │ │ │ +
int indexInInside(unsigned int index) const
gets the number face in the parent element
Definition extractor.hh:326
│ │ │ │ +
Dune::FieldVector< ctype, dim > LocalCoords
Definition extractor.hh:61
│ │ │ │ +
LocalGeometry geometryLocal(unsigned int index) const
Get geometry of the extracted face in element coordinates.
Definition extractor.hh:409
│ │ │ │ +
static constexpr auto dimworld
Definition extractor.hh:50
│ │ │ │ +
Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry
Definition extractor.hh:77
│ │ │ │
int IndexType
Definition extractor.hh:73
│ │ │ │ -
static constexpr int cube_corners
Definition extractor.hh:54
│ │ │ │ -
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │ +
std::vector< CoordinateInfo > coords_
all information about the corner vertices of the extracted
Definition extractor.hh:196
│ │ │ │ +
GV::Traits::template Codim< 0 >::Entity Element
Definition extractor.hh:66
│ │ │ │ +
const GridView & gridView() const
give access to the Dune::GridView where this Patch belongs to
Definition extractor.hh:344
│ │ │ │ +
void getFaces(std::vector< VertexVector > &faces) const
Get the corners of the extracted subentities.
Definition extractor.hh:285
│ │ │ │ +
std::vector< unsigned int > VertexVector
Definition extractor.hh:69
│ │ │ │ +
const GridView gv_
the grid object to extract the surface from
Definition extractor.hh:191
│ │ │ │ +
std::vector< SubEntityInfo > subEntities_
all information about the extracted subEntities
Definition extractor.hh:199
│ │ │ │ +
static constexpr int cube_corners
Definition extractor.hh:54
│ │ │ │ +
Vertex vertex(unsigned int index) const
gets the vertex for a given coordinate index throws an exception if index not valid
Definition extractor.hh:377
│ │ │ │ +
static constexpr auto codim
Definition extractor.hh:52
│ │ │ │ +
Dune::FieldVector< ctype, dimworld > Coords
Definition extractor.hh:60
│ │ │ │ +
void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const
Get the list of geometry types.
Definition extractor.hh:274
│ │ │ │ +
MultipleCodimMultipleGeomTypeMapper< GridView > CellMapper
Definition extractor.hh:70
│ │ │ │
std::map< IndexType, VertexInfo > VertexInfoMap
Definition extractor.hh:186
│ │ │ │ -
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │ +
GridView::Grid Grid
Definition extractor.hh:57
│ │ │ │ +
bool faceIndices(const Element &e, int &first, int &count) const
gets index of first subentity as well as the total number of subentities that were extracted from thi...
Definition extractor.hh:304
│ │ │ │ +
Geometry geometry(unsigned int index) const
Get world geometry of the extracted face.
Definition extractor.hh:397
│ │ │ │ +
GV GridView
Definition extractor.hh:56
│ │ │ │ +
unsigned int nCoords() const
getter for the count of coordinates
Definition extractor.hh:268
│ │ │ │ +
GV::Grid::ctype ctype
Definition extractor.hh:59
│ │ │ │ +
std::map< IndexType, ElementInfo > ElementInfoMap
Definition extractor.hh:185
│ │ │ │ +
Extractor(const GV &gv)
Constructor.
Definition extractor.hh:225
│ │ │ │ +
void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) const
getter for the coordinates array
Definition extractor.hh:256
│ │ │ │ +
CellMapper cellMapper_
Definition extractor.hh:215
│ │ │ │ +
Element::EntitySeed ElementSeed
Definition extractor.hh:67
│ │ │ │ +
Vertex::EntitySeed VertexSeed
Definition extractor.hh:64
│ │ │ │ +
ElementInfoMap elmtInfo_
a map enabling faster access to elements and faces
Definition extractor.hh:213
│ │ │ │ +
void clear()
delete everything build up so far and free the memory
Definition extractor.hh:235
│ │ │ │ +
static constexpr auto dim
Definition extractor.hh:51
│ │ │ │ +
Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry
Definition extractor.hh:78
│ │ │ │ +
Helpful struct holding one index for the coordinate (vertex) to which it is associated and the elemen...
Definition extractor.hh:88
│ │ │ │ +
unsigned int idx
index of the vertex
Definition extractor.hh:89
│ │ │ │ +
unsigned int num
element corner
Definition extractor.hh:90
│ │ │ │ │ │ │ │ +
CoordinateInfo(unsigned int index_, IndexType vtxindex_)
Definition extractor.hh:98
│ │ │ │ +
unsigned int index
the index of this coordinate (in internal storage scheme) // NEEDED??
Definition extractor.hh:109
│ │ │ │ +
CoordinateInfo()
Definition extractor.hh:95
│ │ │ │ +
Coords coord
the coordinate
Definition extractor.hh:106
│ │ │ │ +
IndexType vtxindex
the index of the parent element (from index set)
Definition extractor.hh:103
│ │ │ │
simple struct holding a vertex pointer and an index
Definition extractor.hh:116
│ │ │ │ +
unsigned int idx
Definition extractor.hh:119
│ │ │ │ +
VertexInfo(unsigned int idx_, const Vertex &p_)
Definition extractor.hh:117
│ │ │ │ +
VertexSeed p
Definition extractor.hh:120
│ │ │ │
simple struct holding an element seed and an index
Definition extractor.hh:128
│ │ │ │ +
unsigned int idx
the index of this element's first face in the internal list of extracted faces
Definition extractor.hh:133
│ │ │ │ +
unsigned int faces
the number of extracted faces for this element
Definition extractor.hh:136
│ │ │ │ +
ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_)
Definition extractor.hh:129
│ │ │ │ +
ElementSeed p
the entity seed for the element
Definition extractor.hh:139
│ │ │ │
Holds some information about an element's subentity involved in a coupling.
Definition extractor.hh:147
│ │ │ │ +
unsigned int nCorners() const
Definition extractor.hh:161
│ │ │ │ +
CornerInfo corners[cube_corners]
the corner indices plus the numbers of the vertices in the parent element
Definition extractor.hh:181
│ │ │ │ +
IndexType parent
the index of the parent element (from index set)
Definition extractor.hh:167
│ │ │ │ +
SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
Definition extractor.hh:156
│ │ │ │ +
unsigned int num_in_parent
the number of the face in the parent element
Definition extractor.hh:170
│ │ │ │ +
Dune::GeometryType geometryType_
The GeometryType of the subentity.
Definition extractor.hh:173
│ │ │ │ +
SubEntityInfo()
Definition extractor.hh:148
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,470 +1,587 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * extractors │ │ │ │ │ -codim1extractor.hh │ │ │ │ │ +extractor.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/* │ │ │ │ │ -6 * Filename: codim1extractor.hh │ │ │ │ │ +6 * Filename: extractor.hh │ │ │ │ │ 7 * Version: 1.0 │ │ │ │ │ -8 * Created on: Jun 23, 2009 │ │ │ │ │ -9 * Author: Oliver Sander, Christian Engwer │ │ │ │ │ +8 * Created on: Oct 05, 2009 │ │ │ │ │ +9 * Author: Christian Engwer │ │ │ │ │ 10 * --------------------------------- │ │ │ │ │ 11 * Project: dune-grid-glue │ │ │ │ │ -12 * Description: class for grid extractors extracting surface grids │ │ │ │ │ +12 * Description: base class for all grid extractors │ │ │ │ │ 13 * │ │ │ │ │ 14 */ │ │ │ │ │ -20#ifndef DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ -21#define DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ +20#ifndef DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH │ │ │ │ │ +21#define DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_HH │ │ │ │ │ 22 │ │ │ │ │ -23#include "extractor.hh" │ │ │ │ │ -24 │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28 │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32 │ │ │ │ │ -33namespace Dune { │ │ │ │ │ -34 │ │ │ │ │ -35 namespace GridGlue { │ │ │ │ │ -36 │ │ │ │ │ -40template │ │ │ │ │ -41class Codim1Extractor : public Extractor │ │ │ │ │ -42{ │ │ │ │ │ -43public: │ │ │ │ │ -44 │ │ │ │ │ -45 /* 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 */ │ │ │ │ │ -46 │ │ │ │ │ -47 using Extractor::dimworld; │ │ │ │ │ -48 using Extractor::dim; │ │ │ │ │ -49 using Extractor::codim; │ │ │ │ │ -50 using Extractor::cube_corners; │ │ │ │ │ -51 typedef typename Extractor::IndexType IndexType; │ │ │ │ │ -52 │ │ │ │ │ -54 static constexpr int simplex_corners = dim; │ │ │ │ │ +23#include │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28#include │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32#include │ │ │ │ │ +33 │ │ │ │ │ +34namespace Dune { │ │ │ │ │ +35 │ │ │ │ │ +36 namespace GridGlue { │ │ │ │ │ +37 │ │ │ │ │ +44template │ │ │ │ │ +45class Extractor │ │ │ │ │ +46{ │ │ │ │ │ +47 │ │ │ │ │ +48public: │ │ │ │ │ +49 │ │ │ │ │ +50 static constexpr auto dimworld = GV::dimensionworld; │ │ │ │ │ +51 static constexpr auto dim = GV::dimension; │ │ │ │ │ +52 static constexpr auto codim = cd; │ │ │ │ │ +53 │ │ │ │ │ +54 static constexpr int cube_corners = 1 << (dim-codim); │ │ │ │ │ 55 │ │ │ │ │ 56 typedef GV GridView; │ │ │ │ │ -57 │ │ │ │ │ -58 typedef typename GV::Grid::ctype ctype; │ │ │ │ │ -59 typedef Dune::FieldVector Coords; │ │ │ │ │ -60 │ │ │ │ │ -61 typedef typename GV::Traits::template Codim::Entity Vertex; │ │ │ │ │ -62 typedef typename GV::Traits::template Codim<0>::Entity Element; │ │ │ │ │ -63 typedef std::function │ │ │ │ │ -Predicate; │ │ │ │ │ -64 │ │ │ │ │ -65 // import typedefs from base class │ │ │ │ │ -66 typedef typename Extractor::SubEntityInfo SubEntityInfo; │ │ │ │ │ -67 typedef typename Extractor::ElementInfo ElementInfo; │ │ │ │ │ -68 typedef typename Extractor::VertexInfo VertexInfo; │ │ │ │ │ -69 typedef typename Extractor::CoordinateInfo CoordinateInfo; │ │ │ │ │ -70 typedef typename Extractor::VertexInfoMap VertexInfoMap; │ │ │ │ │ +57 typedef typename GridView::Grid Grid; │ │ │ │ │ +58 │ │ │ │ │ +59 typedef typename GV::Grid::ctype ctype; │ │ │ │ │ +60 typedef Dune::FieldVector Coords; │ │ │ │ │ +61 typedef Dune::FieldVector LocalCoords; │ │ │ │ │ +62 │ │ │ │ │ +63 typedef typename GV::Traits::template Codim::Entity Vertex; │ │ │ │ │ +64 typedef typename Vertex::EntitySeed VertexSeed; │ │ │ │ │ +65 │ │ │ │ │ +66 typedef typename GV::Traits::template Codim<0>::Entity Element; │ │ │ │ │ +67 typedef typename Element::EntitySeed ElementSeed; │ │ │ │ │ +68 │ │ │ │ │ +69 typedef std::vector VertexVector; │ │ │ │ │ +70 using CellMapper = MultipleCodimMultipleGeomTypeMapper; │ │ │ │ │ 71 │ │ │ │ │ -72public: │ │ │ │ │ -73 │ │ │ │ │ -74 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */ │ │ │ │ │ +72 // typedef typename CellMapper::IndexType IndexType; │ │ │ │ │ +73 typedef int IndexType; │ │ │ │ │ +74public: │ │ │ │ │ 75 │ │ │ │ │ -81 Codim1Extractor(const GV& gv, const Predicate& predicate) │ │ │ │ │ -82 : Extractor(gv) │ │ │ │ │ -83 { │ │ │ │ │ -84 std::cout << "This is Codim1Extractor on a <" << dim │ │ │ │ │ -85 << "," << dimworld << "> grid!" │ │ │ │ │ -86 << std::endl; │ │ │ │ │ -87 update(predicate); │ │ │ │ │ -88 } │ │ │ │ │ -89 │ │ │ │ │ -90private: │ │ │ │ │ -91 │ │ │ │ │ -105 void update(const Predicate& predicate); │ │ │ │ │ -106 │ │ │ │ │ -107}; │ │ │ │ │ -108 │ │ │ │ │ -109 │ │ │ │ │ -110template │ │ │ │ │ -111void Codim1Extractor::update(const Predicate& predicate) │ │ │ │ │ -112{ │ │ │ │ │ -113 // free everything there is in this object │ │ │ │ │ -114 this->clear(); │ │ │ │ │ -115 │ │ │ │ │ -116 // In this first pass iterate over all entities of codim 0. │ │ │ │ │ -117 // For each codim 1 intersection check if it is part of the boundary and if │ │ │ │ │ -so, │ │ │ │ │ -118 // get its corner vertices, find resp. store them together with their │ │ │ │ │ -associated index, │ │ │ │ │ -119 // and remember the indices of the boundary faces' corners. │ │ │ │ │ -120 { │ │ │ │ │ -121 // several counter for consecutive indexing are needed │ │ │ │ │ -122 int simplex_index = 0; │ │ │ │ │ -123 int vertex_index = 0; │ │ │ │ │ -124 IndexType eindex = 0; // suppress warning │ │ │ │ │ -125 │ │ │ │ │ -126 // needed later for insertion into a std::set which only │ │ │ │ │ -127 // works with const references │ │ │ │ │ -128 │ │ │ │ │ -129 // a temporary container where newly acquired face │ │ │ │ │ -130 // information can be stored at first │ │ │ │ │ -131 std::deque temp_faces; │ │ │ │ │ -132 │ │ │ │ │ -133 // iterate over interior codim 0 elements on the grid │ │ │ │ │ -134 for (const auto& elmt : elements(this->gv_, Partitions::interior)) │ │ │ │ │ -135 { │ │ │ │ │ -136 Dune::GeometryType gt = elmt.type(); │ │ │ │ │ +76 // transformations │ │ │ │ │ +77 typedef Dune::MultiLinearGeometry Geometry; │ │ │ │ │ +78 typedef Dune::MultiLinearGeometry LocalGeometry; │ │ │ │ │ +79 │ │ │ │ │ +80protected: │ │ │ │ │ +81 /************************** PRIVATE SUBCLASSES **********************/ │ │ │ │ │ +82 │ │ │ │ │ +87 struct CornerInfo │ │ │ │ │ +88 { │ │ │ │ │ +89 unsigned int idx : 28; │ │ │ │ │ +90 unsigned int num : 4; │ │ │ │ │ +91 }; │ │ │ │ │ +92 │ │ │ │ │ +93 struct CoordinateInfo │ │ │ │ │ +94 { │ │ │ │ │ +95 CoordinateInfo() │ │ │ │ │ +96 {} │ │ │ │ │ +97 │ │ │ │ │ +98 CoordinateInfo(unsigned int index_, IndexType vtxindex_) │ │ │ │ │ +99 : vtxindex(vtxindex_), index(index_) │ │ │ │ │ +100 {} │ │ │ │ │ +101 │ │ │ │ │ +103 IndexType vtxindex; │ │ │ │ │ +104 │ │ │ │ │ +106 Coords coord; │ │ │ │ │ +107 │ │ │ │ │ +109 unsigned int index; │ │ │ │ │ +110 }; │ │ │ │ │ +111 │ │ │ │ │ +115 struct VertexInfo │ │ │ │ │ +116 { │ │ │ │ │ +117 VertexInfo(unsigned int idx_, const Vertex& p_) : idx(idx_), p(p_.seed()) │ │ │ │ │ +118 {} │ │ │ │ │ +119 unsigned int idx; │ │ │ │ │ +120 VertexSeed p; │ │ │ │ │ +121 }; │ │ │ │ │ +122 │ │ │ │ │ +123 │ │ │ │ │ +127 struct ElementInfo │ │ │ │ │ +128 { │ │ │ │ │ +129 ElementInfo(unsigned int idx_, const Element& p_, unsigned int f_) : idx │ │ │ │ │ +(idx_), faces(f_), p(p_.seed()) │ │ │ │ │ +130 {} │ │ │ │ │ +131 │ │ │ │ │ +133 unsigned int idx : 28; │ │ │ │ │ +134 │ │ │ │ │ +136 unsigned int faces : 4; │ │ │ │ │ 137 │ │ │ │ │ -138 // if some face is part of the surface add it! │ │ │ │ │ -139 if (elmt.hasBoundaryIntersections()) │ │ │ │ │ -140 { │ │ │ │ │ -141 // add an entry to the element info map, the index will be set properly │ │ │ │ │ -later, │ │ │ │ │ -142 // whereas the number of faces is already known │ │ │ │ │ -143 eindex = this->cellMapper_.index(elmt); │ │ │ │ │ -144 this->elmtInfo_.emplace(eindex, ElementInfo(simplex_index, elmt, 0)); │ │ │ │ │ -145 │ │ │ │ │ -146 // now add the faces in ascending order of their indices │ │ │ │ │ -147 // (we are only talking about 1-4 faces here, so O(n^2) is ok!) │ │ │ │ │ -148 for (const auto& in : intersections(this->gv_, elmt)) │ │ │ │ │ -149 { │ │ │ │ │ -150 // Stop only at selected boundary faces │ │ │ │ │ -151 if (!in.boundary() or !predicate(elmt, in.indexInInside())) │ │ │ │ │ -152 continue; │ │ │ │ │ -153 │ │ │ │ │ -154 const auto& refElement = Dune::ReferenceElements::general(gt); │ │ │ │ │ -155 // get the corner count of this face │ │ │ │ │ -156 const int face_corners = refElement.size(in.indexInInside(), 1, dim); │ │ │ │ │ -157 │ │ │ │ │ -158 // now we only have to care about the 3D case, i.e. a triangle face can be │ │ │ │ │ -159 // inserted directly whereas a quadrilateral face has to be divided into │ │ │ │ │ -two triangles │ │ │ │ │ -160 switch (face_corners) │ │ │ │ │ -161 { │ │ │ │ │ -162 case 2 : │ │ │ │ │ -163 case 3: │ │ │ │ │ -164 { │ │ │ │ │ -165 // we have a simplex here │ │ │ │ │ -166 │ │ │ │ │ -167 // register the additional face(s) │ │ │ │ │ -168 this->elmtInfo_.at(eindex).faces++; │ │ │ │ │ -169 │ │ │ │ │ -170 // add a new face to the temporary collection │ │ │ │ │ -171 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ -172 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ -173 │ │ │ │ │ -174 std::vector > cornerCoords(face_corners); │ │ │ │ │ -175 │ │ │ │ │ -176 // try for each of the faces vertices whether it is already inserted or not │ │ │ │ │ -177 for (int i = 0; i < face_corners; ++i) │ │ │ │ │ -178 { │ │ │ │ │ -179 // get the number of the vertex in the parent element │ │ │ │ │ -180 int vertex_number = refElement.subEntity(in.indexInInside(), 1, i, dim); │ │ │ │ │ -181 │ │ │ │ │ -182 // get the vertex pointer and the index from the index set │ │ │ │ │ -183 const Vertex vertex = elmt.template subEntity(vertex_number); │ │ │ │ │ -184 cornerCoords[i] = vertex.geometry().corner(0); │ │ │ │ │ -185 │ │ │ │ │ -186 IndexType vindex = this->gv_.indexSet().template index(vertex); │ │ │ │ │ +139 ElementSeed p; │ │ │ │ │ +140 }; │ │ │ │ │ +141 │ │ │ │ │ +142 │ │ │ │ │ +146 struct SubEntityInfo │ │ │ │ │ +147 { │ │ │ │ │ +148 SubEntityInfo() │ │ │ │ │ +149 /* │ │ │ │ │ +150 * TODO: move default value of `geometryType_` to member declaration │ │ │ │ │ +151 * when removing support for older dune-geometry │ │ │ │ │ +152 */ │ │ │ │ │ +153 : geometryType_(GeometryTypes::simplex(dim-codim)) │ │ │ │ │ +154 {} │ │ │ │ │ +155 │ │ │ │ │ +156 SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, │ │ │ │ │ +157 const Dune::GeometryType& geometryType) │ │ │ │ │ +158 : parent(parent_), num_in_parent(num_in_parent_), geometryType_ │ │ │ │ │ +(geometryType) │ │ │ │ │ +159 {} │ │ │ │ │ +160 │ │ │ │ │ +161 unsigned int nCorners() const │ │ │ │ │ +162 { │ │ │ │ │ +163 return Dune::ReferenceElements::general(geometryType_ │ │ │ │ │ +).size(dim-codim); │ │ │ │ │ +164 } │ │ │ │ │ +165 │ │ │ │ │ +167 IndexType parent; │ │ │ │ │ +168 │ │ │ │ │ +170 unsigned int num_in_parent : 3; │ │ │ │ │ +171 │ │ │ │ │ +173 Dune::GeometryType geometryType_; │ │ │ │ │ +174 │ │ │ │ │ +181 CornerInfo corners[cube_corners]; // sim = number of vertices in a simplex │ │ │ │ │ +182 }; │ │ │ │ │ +183 │ │ │ │ │ +184 │ │ │ │ │ +185 typedef std::map ElementInfoMap; │ │ │ │ │ +186 typedef std::map VertexInfoMap; │ │ │ │ │ 187 │ │ │ │ │ -188 // remember the vertex' number in parent element's vertices │ │ │ │ │ -189 temp_faces.back().corners[i].num = vertex_number; │ │ │ │ │ -190 │ │ │ │ │ -191 // if the vertex is not yet inserted in the vertex info map │ │ │ │ │ -192 // it is a new one -> it will be inserted now! │ │ │ │ │ -193 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex); │ │ │ │ │ -194 if (vimit == this->vtxInfo_.end()) │ │ │ │ │ -195 { │ │ │ │ │ -196 // insert into the map │ │ │ │ │ -197 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex)); │ │ │ │ │ -198 // remember the vertex as a corner of the current face in temp_faces │ │ │ │ │ -199 temp_faces.back().corners[i].idx = vertex_index; │ │ │ │ │ -200 // increase the current index │ │ │ │ │ -201 vertex_index++; │ │ │ │ │ -202 } │ │ │ │ │ -203 else │ │ │ │ │ -204 { │ │ │ │ │ -205 // only insert the index into the simplices array │ │ │ │ │ -206 temp_faces.back().corners[i].idx = vimit->second.idx; │ │ │ │ │ -207 } │ │ │ │ │ -208 } │ │ │ │ │ -209 │ │ │ │ │ -210 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ -they may │ │ │ │ │ -211 // have the wrong orientation. We want them to be oriented such that all │ │ │ │ │ -boundary edges │ │ │ │ │ -212 // point in the counterclockwise direction. Therefore, we check the │ │ │ │ │ -orientation of the │ │ │ │ │ -213 // new face and possibly switch the two vertices. │ │ │ │ │ -214 FieldVector realNormal = in.centerUnitOuterNormal(); │ │ │ │ │ -215 │ │ │ │ │ -216 // Compute segment normal │ │ │ │ │ -217 FieldVector reconstructedNormal; │ │ │ │ │ -218 if (dim==2) // boundary face is a line segment │ │ │ │ │ -219 { │ │ │ │ │ -220 reconstructedNormal[0] = cornerCoords[1][1] - cornerCoords[0][1]; │ │ │ │ │ -221 reconstructedNormal[1] = cornerCoords[0][0] - cornerCoords[1][0]; │ │ │ │ │ -222 } else { // boundary face is a triangle │ │ │ │ │ -223 FieldVector segment1 = cornerCoords[1] - cornerCoords[0]; │ │ │ │ │ -224 FieldVector segment2 = cornerCoords[2] - cornerCoords[0]; │ │ │ │ │ -225 reconstructedNormal = crossProduct(segment1, segment2); │ │ │ │ │ -226 } │ │ │ │ │ -227 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ -228 │ │ │ │ │ -229 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ -230 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ +188 /************************** MEMBER VARIABLES ************************/ │ │ │ │ │ +189 │ │ │ │ │ +191 const GridView gv_; │ │ │ │ │ +192 │ │ │ │ │ +193 /* Geometrical and Topological Information */ │ │ │ │ │ +194 │ │ │ │ │ +196 std::vector coords_; │ │ │ │ │ +197 │ │ │ │ │ +199 std::vector subEntities_; │ │ │ │ │ +200 │ │ │ │ │ +206 VertexInfoMap vtxInfo_; │ │ │ │ │ +207 │ │ │ │ │ +213 ElementInfoMap elmtInfo_; │ │ │ │ │ +214 │ │ │ │ │ +215 CellMapper cellMapper_; │ │ │ │ │ +216 │ │ │ │ │ +217public: │ │ │ │ │ +218 │ │ │ │ │ +219 /* C O N S T R U C T O R S A N D D E S T R U C T O R S */ │ │ │ │ │ +220 │ │ │ │ │ +225 Extractor(const GV& gv) │ │ │ │ │ +226 : gv_(gv) │ │ │ │ │ +227 , cellMapper_(gv, mcmgElementLayout()) │ │ │ │ │ +228 {} │ │ │ │ │ +229 │ │ │ │ │ +230 /* F U N C T I O N A L I T Y */ │ │ │ │ │ 231 │ │ │ │ │ -232 // now increase the current face index │ │ │ │ │ -233 simplex_index++; │ │ │ │ │ -234 break; │ │ │ │ │ -235 } │ │ │ │ │ -236 case 4 : │ │ │ │ │ -237 { │ │ │ │ │ -238 assert(dim == 3 && cube_corners == 4); │ │ │ │ │ -239 // we have a quadrilateral here │ │ │ │ │ -240 std::array vertex_indices; │ │ │ │ │ -241 std::array vertex_numbers; │ │ │ │ │ +235 void clear() │ │ │ │ │ +236 { │ │ │ │ │ +237 coords_.clear(); │ │ │ │ │ +238 coords_.shrink_to_fit(); │ │ │ │ │ +239 │ │ │ │ │ +240 subEntities_.clear(); │ │ │ │ │ +241 subEntities_.shrink_to_fit(); │ │ │ │ │ 242 │ │ │ │ │ -243 // register the additional face(s) (2 simplices) │ │ │ │ │ -244 this->elmtInfo_.at(eindex).faces += 2; │ │ │ │ │ -245 │ │ │ │ │ -246 std::array, 4> cornerCoords; │ │ │ │ │ +243 // ...then clear the maps themselves, too │ │ │ │ │ +244 vtxInfo_.clear(); │ │ │ │ │ +245 elmtInfo_.clear(); │ │ │ │ │ +246 } │ │ │ │ │ 247 │ │ │ │ │ -248 // get the vertex pointers for the quadrilateral's corner vertices │ │ │ │ │ -249 // and try for each of them whether it is already inserted or not │ │ │ │ │ -250 for (int i = 0; i < cube_corners; ++i) │ │ │ │ │ -251 { │ │ │ │ │ -252 // get the number of the vertex in the parent element │ │ │ │ │ -253 vertex_numbers[i] = refElement.subEntity(in.indexInInside(), 1, i, dim); │ │ │ │ │ -254 │ │ │ │ │ -255 // get the vertex pointer and the index from the index set │ │ │ │ │ -256 const Vertex vertex = elmt.template subEntity(vertex_numbers[i]); │ │ │ │ │ -257 cornerCoords[i] = vertex.geometry().corner(0); │ │ │ │ │ -258 │ │ │ │ │ -259 IndexType vindex = this->gv_.indexSet().template index(vertex); │ │ │ │ │ -260 │ │ │ │ │ -261 // if the vertex is not yet inserted in the vertex info map │ │ │ │ │ -262 // it is a new one -> it will be inserted now! │ │ │ │ │ -263 typename VertexInfoMap::iterator vimit = this->vtxInfo_.find(vindex); │ │ │ │ │ -264 if (vimit == this->vtxInfo_.end()) │ │ │ │ │ -265 { │ │ │ │ │ -266 // insert into the map │ │ │ │ │ -267 this->vtxInfo_.emplace(vindex, VertexInfo(vertex_index, vertex)); │ │ │ │ │ -268 // remember this vertex' index │ │ │ │ │ -269 vertex_indices[i] = vertex_index; │ │ │ │ │ -270 // increase the current index │ │ │ │ │ -271 vertex_index++; │ │ │ │ │ -272 } │ │ │ │ │ -273 else │ │ │ │ │ -274 { │ │ │ │ │ -275 // only remember the vertex' index │ │ │ │ │ -276 vertex_indices[i] = vimit->second.idx; │ │ │ │ │ -277 } │ │ │ │ │ -278 } │ │ │ │ │ -279 │ │ │ │ │ -280 // now introduce the two triangles subdividing the quadrilateral │ │ │ │ │ -281 // ATTENTION: the order of vertices given by "orientedSubface" corresponds │ │ │ │ │ -to the order │ │ │ │ │ -282 // of a Dune quadrilateral, i.e. the triangles are given by 0 1 2 and 3 2 1 │ │ │ │ │ -283 │ │ │ │ │ -284 // add a new face to the temporary collection for the first tri │ │ │ │ │ -285 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ -286 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ -287 temp_faces.back().corners[0].idx = vertex_indices[0]; │ │ │ │ │ -288 temp_faces.back().corners[1].idx = vertex_indices[1]; │ │ │ │ │ -289 temp_faces.back().corners[2].idx = vertex_indices[2]; │ │ │ │ │ -290 // remember the vertices' numbers in parent element's vertices │ │ │ │ │ -291 temp_faces.back().corners[0].num = vertex_numbers[0]; │ │ │ │ │ -292 temp_faces.back().corners[1].num = vertex_numbers[1]; │ │ │ │ │ -293 temp_faces.back().corners[2].num = vertex_numbers[2]; │ │ │ │ │ +248 │ │ │ │ │ +249 /* G E T T E R S */ │ │ │ │ │ +250 │ │ │ │ │ +256 void getCoords(std::vector >& coords) │ │ │ │ │ +const │ │ │ │ │ +257 { │ │ │ │ │ +258 coords.resize(coords_.size()); │ │ │ │ │ +259 for (unsigned int i = 0; i < coords_.size(); ++i) │ │ │ │ │ +260 coords[i] = coords_[i].coord; │ │ │ │ │ +261 } │ │ │ │ │ +262 │ │ │ │ │ +263 │ │ │ │ │ +268 unsigned int nCoords() const │ │ │ │ │ +269 { │ │ │ │ │ +270 return coords_.size(); │ │ │ │ │ +271 } │ │ │ │ │ +272 │ │ │ │ │ +274 void getGeometryTypes(std::vector& geometryTypes) const │ │ │ │ │ +275 { │ │ │ │ │ +276 geometryTypes.resize(subEntities_.size()); │ │ │ │ │ +277 for (size_t i=0; i& faces) const │ │ │ │ │ +286 { │ │ │ │ │ +287 faces.resize(subEntities_.size()); │ │ │ │ │ +288 for (unsigned int i = 0; i < subEntities_.size(); ++i) { │ │ │ │ │ +289 faces[i].resize(subEntities_[i].nCorners()); │ │ │ │ │ +290 for (unsigned int j = 0; j < subEntities_[i].nCorners(); ++j) │ │ │ │ │ +291 faces[i][j] = subEntities_[i].corners[j].idx; │ │ │ │ │ +292 } │ │ │ │ │ +293 } │ │ │ │ │ 294 │ │ │ │ │ -295 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ -they may │ │ │ │ │ -296 // have the wrong orientation. We want the triangle vertices on │ │ │ │ │ -counterclockwise order, │ │ │ │ │ -297 // when viewed from the outside of the grid. Therefore, we check the │ │ │ │ │ -orientation of the │ │ │ │ │ -298 // new face and possibly switch two vertices. │ │ │ │ │ -299 FieldVector realNormal = in.centerUnitOuterNormal(); │ │ │ │ │ -300 │ │ │ │ │ -301 // Compute segment normal │ │ │ │ │ -302 FieldVector reconstructedNormal = crossProduct(cornerCoords │ │ │ │ │ -[1] - cornerCoords[0], │ │ │ │ │ -303 cornerCoords[2] - cornerCoords[0]); │ │ │ │ │ -304 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ -305 │ │ │ │ │ -306 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ -307 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ -308 │ │ │ │ │ -309 │ │ │ │ │ -310 // add a new face to the temporary collection for the second tri │ │ │ │ │ -311 temp_faces.emplace_back(eindex, in.indexInInside(), │ │ │ │ │ -312 Dune::GeometryTypes::simplex(dim-codim)); │ │ │ │ │ -313 temp_faces.back().corners[0].idx = vertex_indices[3]; │ │ │ │ │ -314 temp_faces.back().corners[1].idx = vertex_indices[2]; │ │ │ │ │ -315 temp_faces.back().corners[2].idx = vertex_indices[1]; │ │ │ │ │ -316 // remember the vertices' numbers in parent element's vertices │ │ │ │ │ -317 temp_faces.back().corners[0].num = vertex_numbers[3]; │ │ │ │ │ -318 temp_faces.back().corners[1].num = vertex_numbers[2]; │ │ │ │ │ -319 temp_faces.back().corners[2].num = vertex_numbers[1]; │ │ │ │ │ +295 │ │ │ │ │ +304 bool faceIndices(const Element& e, int& first, int& count) const │ │ │ │ │ +305 { │ │ │ │ │ +306 typename ElementInfoMap::const_iterator it = │ │ │ │ │ +307 elmtInfo_.find(cellMapper_.map(e)); │ │ │ │ │ +308 if (it == elmtInfo_.end()) │ │ │ │ │ +309 { │ │ │ │ │ +310 first = -1; │ │ │ │ │ +311 count = 0; │ │ │ │ │ +312 return false; │ │ │ │ │ +313 } │ │ │ │ │ +314 // the iterator is valid, fill the out params │ │ │ │ │ +315 first = it->second.idx; │ │ │ │ │ +316 count = it->second.faces; │ │ │ │ │ +317 return true; │ │ │ │ │ +318 } │ │ │ │ │ +319 │ │ │ │ │ 320 │ │ │ │ │ -321 // Now we have the correct vertices in the last entries of temp_faces, but │ │ │ │ │ -they may │ │ │ │ │ -322 // have the wrong orientation. We want the triangle vertices on │ │ │ │ │ -counterclockwise order, │ │ │ │ │ -323 // when viewed from the outside of the grid. Therefore, we check the │ │ │ │ │ -orientation of the │ │ │ │ │ -324 // new face and possibly switch two vertices. │ │ │ │ │ -325 // Compute segment normal │ │ │ │ │ -326 reconstructedNormal = crossProduct(cornerCoords[2] - cornerCoords[3], │ │ │ │ │ -327 cornerCoords[1] - cornerCoords[3]); │ │ │ │ │ -328 reconstructedNormal /= reconstructedNormal.two_norm(); │ │ │ │ │ -329 │ │ │ │ │ -330 if (realNormal * reconstructedNormal < 0.0) │ │ │ │ │ -331 std::swap(temp_faces.back().corners[0], temp_faces.back().corners[1]); │ │ │ │ │ -332 │ │ │ │ │ -333 simplex_index+=2; │ │ │ │ │ -334 break; │ │ │ │ │ -335 } │ │ │ │ │ -336 default : │ │ │ │ │ -337 DUNE_THROW(Dune::NotImplemented, "the extractor does only work for triangle │ │ │ │ │ -and quadrilateral faces (" << face_corners << " corners)"); │ │ │ │ │ -338 break; │ │ │ │ │ -339 } │ │ │ │ │ -340 } // end loop over found surface parts │ │ │ │ │ -341 } │ │ │ │ │ -342 } // end loop over elements │ │ │ │ │ -343 │ │ │ │ │ -344 std::cout << "added " << simplex_index << " subfaces\n"; │ │ │ │ │ -345 │ │ │ │ │ -346 // allocate the array for the face specific information... │ │ │ │ │ -347 this->subEntities_.resize(simplex_index); │ │ │ │ │ -348 // ...and fill in the data from the temporary containers │ │ │ │ │ -349 copy(temp_faces.begin(), temp_faces.end(), this->subEntities_.begin()); │ │ │ │ │ -350 } │ │ │ │ │ -351 │ │ │ │ │ -352 │ │ │ │ │ -353 // now first write the array with the coordinates... │ │ │ │ │ -354 this->coords_.resize(this->vtxInfo_.size()); │ │ │ │ │ -355 for (const auto& vinfo : this->vtxInfo_) │ │ │ │ │ -356 { │ │ │ │ │ -357 // get a pointer to the associated info object │ │ │ │ │ -358 CoordinateInfo* current = &this->coords_[vinfo.second.idx]; │ │ │ │ │ -359 // store this coordinates index // NEEDED? │ │ │ │ │ -360 current->index = vinfo.second.idx; │ │ │ │ │ -361 // store the vertex' index for the index2vertex mapping │ │ │ │ │ -362 current->vtxindex = vinfo.first; │ │ │ │ │ -363 // store the vertex' coordinates under the associated index │ │ │ │ │ -364 // in the coordinates array │ │ │ │ │ -365 const auto vtx = this->grid().entity(vinfo.second.p); │ │ │ │ │ -366 current->coord = vtx.geometry().corner(0); │ │ │ │ │ +326 int indexInInside(unsigned int index) const │ │ │ │ │ +327 { │ │ │ │ │ +328 return index < subEntities_.size() ? subEntities_[index].num_in_parent : - │ │ │ │ │ +1; │ │ │ │ │ +329 } │ │ │ │ │ +330 │ │ │ │ │ +331 // /** │ │ │ │ │ +332 // * @brief tests that a given entry in the extraction set does have local │ │ │ │ │ +couplings │ │ │ │ │ +333 // * @todo parallel interface │ │ │ │ │ +334 // */ │ │ │ │ │ +335 // bool contains (unsigned int global, unsigned int & local) const │ │ │ │ │ +336 // { │ │ │ │ │ +337 // local = global; │ │ │ │ │ +338 // return true; │ │ │ │ │ +339 // } │ │ │ │ │ +340 │ │ │ │ │ +344 const GridView & gridView() const │ │ │ │ │ +345 { │ │ │ │ │ +346 return gv_; │ │ │ │ │ +347 } │ │ │ │ │ +348 │ │ │ │ │ +349 const Grid& grid() const │ │ │ │ │ +350 { │ │ │ │ │ +351 return gv_.grid(); │ │ │ │ │ +352 } │ │ │ │ │ +353 │ │ │ │ │ +360 Element │ │ │ │ │ +361 element(unsigned int index) const │ │ │ │ │ +362 { │ │ │ │ │ +363 if (index >= subEntities_.size()) │ │ │ │ │ +364 DUNE_THROW(Dune::GridError, "invalid face index"); │ │ │ │ │ +365 const ElementSeed seed = elmtInfo_.at(subEntities_[index].parent).p; │ │ │ │ │ +366 return grid().entity(seed); │ │ │ │ │ 367 } │ │ │ │ │ 368 │ │ │ │ │ -369} │ │ │ │ │ -370 │ │ │ │ │ -371} // namespace GridGlue │ │ │ │ │ -372 │ │ │ │ │ -373} // namespace Dune │ │ │ │ │ -374 │ │ │ │ │ -375#endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM1EXTRACTOR_HH │ │ │ │ │ -crossproduct.hh │ │ │ │ │ -extractor.hh │ │ │ │ │ -extractor base class │ │ │ │ │ +369#if 1 │ │ │ │ │ +376 Vertex │ │ │ │ │ +377 vertex(unsigned int index) const │ │ │ │ │ +378 { │ │ │ │ │ +379 if (index >= coords_.size()) │ │ │ │ │ +380 DUNE_THROW(Dune::GridError, "invalid coordinate index"); │ │ │ │ │ +381 const VertexSeed seed = vtxInfo_.at(coords_[index].vtxindex).p; │ │ │ │ │ +382 return grid().entity(seed); │ │ │ │ │ +383 } │ │ │ │ │ +384#endif │ │ │ │ │ +385 │ │ │ │ │ +387 Geometry geometry(unsigned int index) const; │ │ │ │ │ +388 │ │ │ │ │ +390 LocalGeometry geometryLocal(unsigned int index) const; │ │ │ │ │ +391 │ │ │ │ │ +392}; │ │ │ │ │ +393 │ │ │ │ │ +394 │ │ │ │ │ +396template │ │ │ │ │ +397typename Extractor::Geometry Extractor::geometry(unsigned int │ │ │ │ │ +index) const │ │ │ │ │ +398{ │ │ │ │ │ +399 std::vector corners(subEntities_[index].nCorners()); │ │ │ │ │ +400 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i) │ │ │ │ │ +401 corners[i] = coords_[subEntities_[index].corners[i].idx].coord; │ │ │ │ │ +402 │ │ │ │ │ +403 return Geometry(subEntities_[index].geometryType_, corners); │ │ │ │ │ +404} │ │ │ │ │ +405 │ │ │ │ │ +406 │ │ │ │ │ +408template │ │ │ │ │ +409typename Extractor::LocalGeometry Extractor::geometryLocal │ │ │ │ │ +(unsigned int index) const │ │ │ │ │ +410{ │ │ │ │ │ +411 std::vector corners(subEntities_[index].nCorners()); │ │ │ │ │ +412 │ │ │ │ │ +413 // get face info │ │ │ │ │ +414 const SubEntityInfo & face = subEntities_[index]; │ │ │ │ │ +415 Dune::GeometryType facetype = subEntities_[index].geometryType_; │ │ │ │ │ +416 │ │ │ │ │ +417 // get reference element │ │ │ │ │ +418 const auto elmtseed = elmtInfo_.at(face.parent).p; │ │ │ │ │ +419 const auto elmt = grid().entity(elmtseed); │ │ │ │ │ +420 const Dune::GeometryType celltype = elmt.type(); │ │ │ │ │ +421 const auto& re = Dune::ReferenceElements::general(celltype); │ │ │ │ │ +422 for (unsigned int i = 0; i < subEntities_[index].nCorners(); ++i) │ │ │ │ │ +423 corners[i] = re.position(face.corners[i].num,dim); │ │ │ │ │ +424 │ │ │ │ │ +425 return LocalGeometry(facetype, corners); │ │ │ │ │ +426} │ │ │ │ │ +427 │ │ │ │ │ +428} // namespace GridGlue │ │ │ │ │ +429 │ │ │ │ │ +430} // namespace Dune │ │ │ │ │ +431 │ │ │ │ │ +432#endif // DUNE_GRIDGLUE_EXTRACTORS_EXTRACTOR_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::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::Codim1Extractor │ │ │ │ │ -Definition codim1extractor.hh:42 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::IndexType │ │ │ │ │ -Extractor< GV, 1 >::IndexType IndexType │ │ │ │ │ -Definition codim1extractor.hh:51 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::GridView │ │ │ │ │ -GV GridView │ │ │ │ │ -Definition codim1extractor.hh:56 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::Element │ │ │ │ │ -GV::Traits::template Codim< 0 >::Entity Element │ │ │ │ │ -Definition codim1extractor.hh:62 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::Coords │ │ │ │ │ -Dune::FieldVector< ctype, dimworld > Coords │ │ │ │ │ -Definition codim1extractor.hh:59 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::ctype │ │ │ │ │ -GV::Grid::ctype ctype │ │ │ │ │ -Definition codim1extractor.hh:58 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::Codim1Extractor │ │ │ │ │ -Codim1Extractor(const GV &gv, const Predicate &predicate) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition codim1extractor.hh:81 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::simplex_corners │ │ │ │ │ -static constexpr int simplex_corners │ │ │ │ │ -compile time number of corners of surface simplices │ │ │ │ │ -Definition codim1extractor.hh:54 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::VertexInfo │ │ │ │ │ -Extractor< GV, 1 >::VertexInfo VertexInfo │ │ │ │ │ -Definition codim1extractor.hh:68 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::CoordinateInfo │ │ │ │ │ -Extractor< GV, 1 >::CoordinateInfo CoordinateInfo │ │ │ │ │ -Definition codim1extractor.hh:69 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::ElementInfo │ │ │ │ │ -Extractor< GV, 1 >::ElementInfo ElementInfo │ │ │ │ │ -Definition codim1extractor.hh:67 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::SubEntityInfo │ │ │ │ │ -Extractor< GV, 1 >::SubEntityInfo SubEntityInfo │ │ │ │ │ -Definition codim1extractor.hh:66 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::VertexInfoMap │ │ │ │ │ -Extractor< GV, 1 >::VertexInfoMap VertexInfoMap │ │ │ │ │ -Definition codim1extractor.hh:70 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::Predicate │ │ │ │ │ -std::function< bool(const Element &, unsigned int subentity)> Predicate │ │ │ │ │ -Definition codim1extractor.hh:63 │ │ │ │ │ -Dune::GridGlue::Codim1Extractor::Vertex │ │ │ │ │ -GV::Traits::template Codim< dim >::Entity Vertex │ │ │ │ │ -Definition codim1extractor.hh:61 │ │ │ │ │ Dune::GridGlue::Extractor │ │ │ │ │ Provides codimension-independent methods for grid extraction. │ │ │ │ │ Definition extractor.hh:46 │ │ │ │ │ -Dune::GridGlue::Extractor<_GV,_1_>::dimworld │ │ │ │ │ +Dune::GridGlue::Extractor::Vertex │ │ │ │ │ +GV::Traits::template Codim< dim >::Entity Vertex │ │ │ │ │ +Definition extractor.hh:63 │ │ │ │ │ +Dune::GridGlue::Extractor::vtxInfo_ │ │ │ │ │ +VertexInfoMap vtxInfo_ │ │ │ │ │ +a map enabling faster access to vertices and coordinates │ │ │ │ │ +Definition extractor.hh:206 │ │ │ │ │ +Dune::GridGlue::Extractor::grid │ │ │ │ │ +const Grid & grid() const │ │ │ │ │ +Definition extractor.hh:349 │ │ │ │ │ +Dune::GridGlue::Extractor::element │ │ │ │ │ +Element element(unsigned int index) const │ │ │ │ │ +gets the parent element for a given face index, throws an exception if index │ │ │ │ │ +not valid │ │ │ │ │ +Definition extractor.hh:361 │ │ │ │ │ +Dune::GridGlue::Extractor::indexInInside │ │ │ │ │ +int indexInInside(unsigned int index) const │ │ │ │ │ +gets the number face in the parent element │ │ │ │ │ +Definition extractor.hh:326 │ │ │ │ │ +Dune::GridGlue::Extractor::LocalCoords │ │ │ │ │ +Dune::FieldVector< ctype, dim > LocalCoords │ │ │ │ │ +Definition extractor.hh:61 │ │ │ │ │ +Dune::GridGlue::Extractor::geometryLocal │ │ │ │ │ +LocalGeometry geometryLocal(unsigned int index) const │ │ │ │ │ +Get geometry of the extracted face in element coordinates. │ │ │ │ │ +Definition extractor.hh:409 │ │ │ │ │ +Dune::GridGlue::Extractor::dimworld │ │ │ │ │ static constexpr auto dimworld │ │ │ │ │ Definition extractor.hh:50 │ │ │ │ │ +Dune::GridGlue::Extractor::Geometry │ │ │ │ │ +Dune::MultiLinearGeometry< ctype, dim-codim, dimworld > Geometry │ │ │ │ │ +Definition extractor.hh:77 │ │ │ │ │ Dune::GridGlue::Extractor::IndexType │ │ │ │ │ int IndexType │ │ │ │ │ Definition extractor.hh:73 │ │ │ │ │ -Dune::GridGlue::Extractor<_GV,_1_>::cube_corners │ │ │ │ │ +Dune::GridGlue::Extractor::coords_ │ │ │ │ │ +std::vector< CoordinateInfo > coords_ │ │ │ │ │ +all information about the corner vertices of the extracted │ │ │ │ │ +Definition extractor.hh:196 │ │ │ │ │ +Dune::GridGlue::Extractor::Element │ │ │ │ │ +GV::Traits::template Codim< 0 >::Entity Element │ │ │ │ │ +Definition extractor.hh:66 │ │ │ │ │ +Dune::GridGlue::Extractor::gridView │ │ │ │ │ +const GridView & gridView() const │ │ │ │ │ +give access to the Dune::GridView where this Patch belongs to │ │ │ │ │ +Definition extractor.hh:344 │ │ │ │ │ +Dune::GridGlue::Extractor::getFaces │ │ │ │ │ +void getFaces(std::vector< VertexVector > &faces) const │ │ │ │ │ +Get the corners of the extracted subentities. │ │ │ │ │ +Definition extractor.hh:285 │ │ │ │ │ +Dune::GridGlue::Extractor::VertexVector │ │ │ │ │ +std::vector< unsigned int > VertexVector │ │ │ │ │ +Definition extractor.hh:69 │ │ │ │ │ +Dune::GridGlue::Extractor::gv_ │ │ │ │ │ +const GridView gv_ │ │ │ │ │ +the grid object to extract the surface from │ │ │ │ │ +Definition extractor.hh:191 │ │ │ │ │ +Dune::GridGlue::Extractor::subEntities_ │ │ │ │ │ +std::vector< SubEntityInfo > subEntities_ │ │ │ │ │ +all information about the extracted subEntities │ │ │ │ │ +Definition extractor.hh:199 │ │ │ │ │ +Dune::GridGlue::Extractor::cube_corners │ │ │ │ │ static constexpr int cube_corners │ │ │ │ │ Definition extractor.hh:54 │ │ │ │ │ -Dune::GridGlue::Extractor<_GV,_1_>::codim │ │ │ │ │ +Dune::GridGlue::Extractor::vertex │ │ │ │ │ +Vertex vertex(unsigned int index) const │ │ │ │ │ +gets the vertex for a given coordinate index throws an exception if index not │ │ │ │ │ +valid │ │ │ │ │ +Definition extractor.hh:377 │ │ │ │ │ +Dune::GridGlue::Extractor::codim │ │ │ │ │ static constexpr auto codim │ │ │ │ │ Definition extractor.hh:52 │ │ │ │ │ +Dune::GridGlue::Extractor::Coords │ │ │ │ │ +Dune::FieldVector< ctype, dimworld > Coords │ │ │ │ │ +Definition extractor.hh:60 │ │ │ │ │ +Dune::GridGlue::Extractor::getGeometryTypes │ │ │ │ │ +void getGeometryTypes(std::vector< Dune::GeometryType > &geometryTypes) const │ │ │ │ │ +Get the list of geometry types. │ │ │ │ │ +Definition extractor.hh:274 │ │ │ │ │ +Dune::GridGlue::Extractor::CellMapper │ │ │ │ │ +MultipleCodimMultipleGeomTypeMapper< GridView > CellMapper │ │ │ │ │ +Definition extractor.hh:70 │ │ │ │ │ Dune::GridGlue::Extractor::VertexInfoMap │ │ │ │ │ std::map< IndexType, VertexInfo > VertexInfoMap │ │ │ │ │ Definition extractor.hh:186 │ │ │ │ │ -Dune::GridGlue::Extractor<_GV,_1_>::dim │ │ │ │ │ +Dune::GridGlue::Extractor::Grid │ │ │ │ │ +GridView::Grid Grid │ │ │ │ │ +Definition extractor.hh:57 │ │ │ │ │ +Dune::GridGlue::Extractor::faceIndices │ │ │ │ │ +bool faceIndices(const Element &e, int &first, int &count) const │ │ │ │ │ +gets index of first subentity as well as the total number of subentities that │ │ │ │ │ +were extracted from thi... │ │ │ │ │ +Definition extractor.hh:304 │ │ │ │ │ +Dune::GridGlue::Extractor::geometry │ │ │ │ │ +Geometry geometry(unsigned int index) const │ │ │ │ │ +Get world geometry of the extracted face. │ │ │ │ │ +Definition extractor.hh:397 │ │ │ │ │ +Dune::GridGlue::Extractor::GridView │ │ │ │ │ +GV GridView │ │ │ │ │ +Definition extractor.hh:56 │ │ │ │ │ +Dune::GridGlue::Extractor::nCoords │ │ │ │ │ +unsigned int nCoords() const │ │ │ │ │ +getter for the count of coordinates │ │ │ │ │ +Definition extractor.hh:268 │ │ │ │ │ +Dune::GridGlue::Extractor::ctype │ │ │ │ │ +GV::Grid::ctype ctype │ │ │ │ │ +Definition extractor.hh:59 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementInfoMap │ │ │ │ │ +std::map< IndexType, ElementInfo > ElementInfoMap │ │ │ │ │ +Definition extractor.hh:185 │ │ │ │ │ +Dune::GridGlue::Extractor::Extractor │ │ │ │ │ +Extractor(const GV &gv) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition extractor.hh:225 │ │ │ │ │ +Dune::GridGlue::Extractor::getCoords │ │ │ │ │ +void getCoords(std::vector< Dune::FieldVector< ctype, dimworld > > &coords) │ │ │ │ │ +const │ │ │ │ │ +getter for the coordinates array │ │ │ │ │ +Definition extractor.hh:256 │ │ │ │ │ +Dune::GridGlue::Extractor::cellMapper_ │ │ │ │ │ +CellMapper cellMapper_ │ │ │ │ │ +Definition extractor.hh:215 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementSeed │ │ │ │ │ +Element::EntitySeed ElementSeed │ │ │ │ │ +Definition extractor.hh:67 │ │ │ │ │ +Dune::GridGlue::Extractor::VertexSeed │ │ │ │ │ +Vertex::EntitySeed VertexSeed │ │ │ │ │ +Definition extractor.hh:64 │ │ │ │ │ +Dune::GridGlue::Extractor::elmtInfo_ │ │ │ │ │ +ElementInfoMap elmtInfo_ │ │ │ │ │ +a map enabling faster access to elements and faces │ │ │ │ │ +Definition extractor.hh:213 │ │ │ │ │ +Dune::GridGlue::Extractor::clear │ │ │ │ │ +void clear() │ │ │ │ │ +delete everything build up so far and free the memory │ │ │ │ │ +Definition extractor.hh:235 │ │ │ │ │ +Dune::GridGlue::Extractor::dim │ │ │ │ │ static constexpr auto dim │ │ │ │ │ Definition extractor.hh:51 │ │ │ │ │ +Dune::GridGlue::Extractor::LocalGeometry │ │ │ │ │ +Dune::MultiLinearGeometry< ctype, dim-codim, dim > LocalGeometry │ │ │ │ │ +Definition extractor.hh:78 │ │ │ │ │ +Dune::GridGlue::Extractor::CornerInfo │ │ │ │ │ +Helpful struct holding one index for the coordinate (vertex) to which it is │ │ │ │ │ +associated and the elemen... │ │ │ │ │ +Definition extractor.hh:88 │ │ │ │ │ +Dune::GridGlue::Extractor::CornerInfo::idx │ │ │ │ │ +unsigned int idx │ │ │ │ │ +index of the vertex │ │ │ │ │ +Definition extractor.hh:89 │ │ │ │ │ +Dune::GridGlue::Extractor::CornerInfo::num │ │ │ │ │ +unsigned int num │ │ │ │ │ +element corner │ │ │ │ │ +Definition extractor.hh:90 │ │ │ │ │ Dune::GridGlue::Extractor::CoordinateInfo │ │ │ │ │ Definition extractor.hh:94 │ │ │ │ │ +Dune::GridGlue::Extractor::CoordinateInfo::CoordinateInfo │ │ │ │ │ +CoordinateInfo(unsigned int index_, IndexType vtxindex_) │ │ │ │ │ +Definition extractor.hh:98 │ │ │ │ │ +Dune::GridGlue::Extractor::CoordinateInfo::index │ │ │ │ │ +unsigned int index │ │ │ │ │ +the index of this coordinate (in internal storage scheme) // NEEDED?? │ │ │ │ │ +Definition extractor.hh:109 │ │ │ │ │ +Dune::GridGlue::Extractor::CoordinateInfo::CoordinateInfo │ │ │ │ │ +CoordinateInfo() │ │ │ │ │ +Definition extractor.hh:95 │ │ │ │ │ +Dune::GridGlue::Extractor::CoordinateInfo::coord │ │ │ │ │ +Coords coord │ │ │ │ │ +the coordinate │ │ │ │ │ +Definition extractor.hh:106 │ │ │ │ │ +Dune::GridGlue::Extractor::CoordinateInfo::vtxindex │ │ │ │ │ +IndexType vtxindex │ │ │ │ │ +the index of the parent element (from index set) │ │ │ │ │ +Definition extractor.hh:103 │ │ │ │ │ Dune::GridGlue::Extractor::VertexInfo │ │ │ │ │ simple struct holding a vertex pointer and an index │ │ │ │ │ Definition extractor.hh:116 │ │ │ │ │ +Dune::GridGlue::Extractor::VertexInfo::idx │ │ │ │ │ +unsigned int idx │ │ │ │ │ +Definition extractor.hh:119 │ │ │ │ │ +Dune::GridGlue::Extractor::VertexInfo::VertexInfo │ │ │ │ │ +VertexInfo(unsigned int idx_, const Vertex &p_) │ │ │ │ │ +Definition extractor.hh:117 │ │ │ │ │ +Dune::GridGlue::Extractor::VertexInfo::p │ │ │ │ │ +VertexSeed p │ │ │ │ │ +Definition extractor.hh:120 │ │ │ │ │ Dune::GridGlue::Extractor::ElementInfo │ │ │ │ │ simple struct holding an element seed and an index │ │ │ │ │ Definition extractor.hh:128 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementInfo::idx │ │ │ │ │ +unsigned int idx │ │ │ │ │ +the index of this element's first face in the internal list of extracted faces │ │ │ │ │ +Definition extractor.hh:133 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementInfo::faces │ │ │ │ │ +unsigned int faces │ │ │ │ │ +the number of extracted faces for this element │ │ │ │ │ +Definition extractor.hh:136 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementInfo::ElementInfo │ │ │ │ │ +ElementInfo(unsigned int idx_, const Element &p_, unsigned int f_) │ │ │ │ │ +Definition extractor.hh:129 │ │ │ │ │ +Dune::GridGlue::Extractor::ElementInfo::p │ │ │ │ │ +ElementSeed p │ │ │ │ │ +the entity seed for the element │ │ │ │ │ +Definition extractor.hh:139 │ │ │ │ │ Dune::GridGlue::Extractor::SubEntityInfo │ │ │ │ │ Holds some information about an element's subentity involved in a coupling. │ │ │ │ │ Definition extractor.hh:147 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::nCorners │ │ │ │ │ +unsigned int nCorners() const │ │ │ │ │ +Definition extractor.hh:161 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::corners │ │ │ │ │ +CornerInfo corners[cube_corners] │ │ │ │ │ +the corner indices plus the numbers of the vertices in the parent element │ │ │ │ │ +Definition extractor.hh:181 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::parent │ │ │ │ │ +IndexType parent │ │ │ │ │ +the index of the parent element (from index set) │ │ │ │ │ +Definition extractor.hh:167 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::SubEntityInfo │ │ │ │ │ +SubEntityInfo(IndexType parent_, unsigned int num_in_parent_, const Dune:: │ │ │ │ │ +GeometryType &geometryType) │ │ │ │ │ +Definition extractor.hh:156 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::num_in_parent │ │ │ │ │ +unsigned int num_in_parent │ │ │ │ │ +the number of the face in the parent element │ │ │ │ │ +Definition extractor.hh:170 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::geometryType_ │ │ │ │ │ +Dune::GeometryType geometryType_ │ │ │ │ │ +The GeometryType of the subentity. │ │ │ │ │ +Definition extractor.hh:173 │ │ │ │ │ +Dune::GridGlue::Extractor::SubEntityInfo::SubEntityInfo │ │ │ │ │ +SubEntityInfo() │ │ │ │ │ +Definition extractor.hh:148 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062.html │ │ │ │ @@ -82,15 +82,15 @@ │ │ │ │ │ │ │ │

Mesh grid extractor base class. │ │ │ │ More...

│ │ │ │
#include <deque>
│ │ │ │ #include <functional>
│ │ │ │ #include <dune/common/deprecated.hh>
│ │ │ │ #include <dune/grid/common/mcmgmapper.hh>
│ │ │ │ -#include "extractor.hh"
│ │ │ │ +#include "extractor.hh"
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00062_source.html │ │ │ │ @@ -100,15 +100,15 @@ │ │ │ │
22
│ │ │ │
23#include <deque>
│ │ │ │
24#include <functional>
│ │ │ │
25
│ │ │ │
26#include <dune/common/deprecated.hh>
│ │ │ │
27#include <dune/grid/common/mcmgmapper.hh>
│ │ │ │
28
│ │ │ │ -
29#include "extractor.hh"
│ │ │ │ +
29#include "extractor.hh"
│ │ │ │
30
│ │ │ │
31namespace Dune {
│ │ │ │
32
│ │ │ │
33 namespace GridGlue {
│ │ │ │
34
│ │ │ │
38template<typename GV>
│ │ │ │
│ │ │ │ @@ -308,15 +308,15 @@ │ │ │ │
234}
│ │ │ │
235
│ │ │ │
236} // namespace GridGlue
│ │ │ │
237
│ │ │ │
238} // namespace Dune
│ │ │ │
239
│ │ │ │
240#endif // DUNE_GRIDGLUE_EXTRACTORS_CODIM0EXTRACTOR_HH
│ │ │ │ -
extractor base class
│ │ │ │ +
extractor base class
│ │ │ │
Definition gridglue.hh:37
│ │ │ │
Definition codim0extractor.hh:40
│ │ │ │
bool & positiveNormalDirection()
Definition codim0extractor.hh:75
│ │ │ │
Extractor< GV, 0 >::IndexType IndexType
Definition codim0extractor.hh:49
│ │ │ │
const bool & positiveNormalDirection() const
Definition codim0extractor.hh:76
│ │ │ │
GV::Traits::template Codim< dim >::Entity Vertex
Definition codim0extractor.hh:51
│ │ │ │
Extractor< GV, 0 >::CoordinateInfo CoordinateInfo
Definition codim0extractor.hh:59
│ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: standardmerge.hh File Reference │ │ │ │ +dune-grid-glue: overlappingmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,139 +71,46 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
standardmerge.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
overlappingmerge.hh 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/fmatrix.hh>
│ │ │ │ #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/geometry/multilineargeometry.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>
│ │ │ │ +#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::Codim0Extractor< GV >
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::GridGlue::StandardMerge< T, grid1Dim, grid2Dim, dimworld >
 Common base class for many merger implementations: produce pairs of entities that may intersect. 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
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define DECL   extern
 
#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

│ │ │ │ - │ │ │ │ -

◆ DECL

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

◆ 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> >& grid1Coords, \
│ │ │ │ -
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<unsigned int>& grid2_elements, \
│ │ │ │ -
const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │ -
)
│ │ │ │ -
#define DECL
Definition standardmerge.hh:827
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,79 +1,34 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces | Macros | Functions │ │ │ │ │ -standardmerge.hh File Reference │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. More... │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +overlappingmerge.hh File Reference │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include "overlappingmerge.cc" │ │ │ │ │ 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... │ │ │ │ │ +class   Dune::GridGlue::OverlappingMerge<_dim1,_dim2,_dimworld,_T_> │ │ │ │ │ +  Computing overlapping grid intersections for grids of different │ │ │ │ │ + dimensions. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  DECL   extern │ │ │ │ │ -  │ │ │ │ │ -#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 ***** │ │ │ │ │ -***** ◆ DECL ***** │ │ │ │ │ -#define DECL   extern │ │ │ │ │ -***** ◆ STANDARD_MERGE_INSTANTIATE ***** │ │ │ │ │ -#define STANDARD_MERGE_INSTANTIATE (   T, │ │ │ │ │ -   A, │ │ │ │ │ -   B, │ │ │ │ │ -   C  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -DECL template \ │ │ │ │ │ -void StandardMerge::build(const std::vector >& │ │ │ │ │ -grid1Coords, \ │ │ │ │ │ -const std::vector& grid1_elements, \ │ │ │ │ │ -const std::vector& grid1_element_types, \ │ │ │ │ │ -const std::vector >& grid2Coords, \ │ │ │ │ │ -const std::vector& grid2_elements, \ │ │ │ │ │ -const std::vector& grid2_element_types \ │ │ │ │ │ -) │ │ │ │ │ -DECL │ │ │ │ │ -#define DECL │ │ │ │ │ -Definition standardmerge.hh:827 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00068_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: standardmerge.hh Source File │ │ │ │ +dune-grid-glue: overlappingmerge.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,857 +74,102 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
standardmerge.hh
│ │ │ │ +
overlappingmerge.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_STANDARDMERGE_HH
│ │ │ │ -
11#define DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
│ │ │ │ +
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
│ │ │ │ -
14#include <iostream>
│ │ │ │ -
15#include <iomanip>
│ │ │ │ -
16#include <vector>
│ │ │ │ -
17#include <stack>
│ │ │ │ -
18#include <set>
│ │ │ │ -
19#include <utility>
│ │ │ │ -
20#include <map>
│ │ │ │ -
21#include <memory>
│ │ │ │ -
22#include <algorithm>
│ │ │ │ +
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
│ │ │ │ -
24#include <dune/common/fvector.hh>
│ │ │ │ -
25#include <dune/common/bitsetvector.hh>
│ │ │ │ -
26#include <dune/common/stdstreams.hh>
│ │ │ │ -
27#include <dune/common/timer.hh>
│ │ │ │ -
28
│ │ │ │ -
29#include <dune/geometry/referenceelements.hh>
│ │ │ │ -
30#include <dune/grid/common/grid.hh>
│ │ │ │ -
31
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
35
│ │ │ │ -
36namespace Dune {
│ │ │ │ -
37namespace GridGlue {
│ │ │ │ +
24namespace Dune {
│ │ │ │ +
25namespace GridGlue {
│ │ │ │ +
26
│ │ │ │ +
34template<int dim1, int dim2, int dimworld, typename T = double>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
36 : public StandardMerge<T,dim1,dim2,dimworld>
│ │ │ │ +
37{
│ │ │ │
38
│ │ │ │ -
55template<class T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
57 : public Merger<T,grid1Dim,grid2Dim,dimworld>
│ │ │ │ -
58{
│ │ │ │ - │ │ │ │ -
60
│ │ │ │ -
61public:
│ │ │ │ -
62
│ │ │ │ -
63 /* 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 */
│ │ │ │ -
64
│ │ │ │ -
66 typedef T ctype;
│ │ │ │ -
67
│ │ │ │ - │ │ │ │ -
70
│ │ │ │ - │ │ │ │ -
73
│ │ │ │ - │ │ │ │ -
76
│ │ │ │ - │ │ │ │ +
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
│ │ │ │ -
79protected:
│ │ │ │ -
80
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
85
│ │ │ │ -
86 bool valid = false;
│ │ │ │ -
87
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
91 {}
│ │ │ │ -
│ │ │ │ -
92
│ │ │ │ -
93 virtual ~StandardMerge() = default;
│ │ │ │ -
94
│ │ │ │ -
99 virtual void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
100 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
101 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ -
102 unsigned int grid1Index,
│ │ │ │ -
103 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
104 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
105 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ -
106 unsigned int grid2Index,
│ │ │ │ -
107 std::vector<SimplicialIntersection>& intersections) = 0;
│ │ │ │ -
108
│ │ │ │ -
│ │ │ │ -
112 bool computeIntersection(unsigned int candidate0, unsigned int candidate1,
│ │ │ │ -
113 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
114 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
115 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ -
116 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
117 const std::vector<Dune::GeometryType>& grid2_element_types,
│ │ │ │ -
118 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ -
119 bool insert = true);
│ │ │ │ -
120
│ │ │ │ -
121 /* M E M B E R V A R I A B L E S */
│ │ │ │ -
122
│ │ │ │ -
123 std::shared_ptr<IntersectionListProvider> intersectionListProvider_;
│ │ │ │ -
124 std::shared_ptr<IntersectionList> intersectionList_;
│ │ │ │ -
125
│ │ │ │ -
127 std::vector<std::vector<unsigned int> > grid1ElementCorners_;
│ │ │ │ -
128 std::vector<std::vector<unsigned int> > grid2ElementCorners_;
│ │ │ │ -
129
│ │ │ │ -
130 std::vector<std::vector<int> > elementNeighbors1_;
│ │ │ │ -
131 std::vector<std::vector<int> > elementNeighbors2_;
│ │ │ │ -
132
│ │ │ │ -
133public:
│ │ │ │ -
134
│ │ │ │ -
135 /* C O N C E P T I M P L E M E N T I N G I N T E R F A C E */
│ │ │ │ -
136
│ │ │ │ -
│ │ │ │ -
140 void build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ -
141 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
142 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
143 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ -
144 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
145 const std::vector<Dune::GeometryType>& grid2_element_types) override;
│ │ │ │ -
146
│ │ │ │ -
147
│ │ │ │ -
148 /* P R O B I N G T H E M E R G E D G R I D */
│ │ │ │ -
149
│ │ │ │ -
│ │ │ │ -
150 void clear() override
│ │ │ │ -
151 {
│ │ │ │ -
152 // Delete old internal data, from a possible previous run
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
156
│ │ │ │ -
157 valid = false;
│ │ │ │ -
158 }
│ │ │ │ -
│ │ │ │ -
159
│ │ │ │ -
│ │ │ │ -
160 std::shared_ptr<IntersectionList> intersectionList() const final
│ │ │ │ -
161 {
│ │ │ │ -
162 assert(valid);
│ │ │ │ -
163 return intersectionList_;
│ │ │ │ -
164 }
│ │ │ │ -
│ │ │ │ -
165
│ │ │ │ -
│ │ │ │ -
166 void enableFallback(bool fallback)
│ │ │ │ -
167 {
│ │ │ │ -
168 m_enableFallback = fallback;
│ │ │ │ -
169 }
│ │ │ │ -
│ │ │ │ -
170
│ │ │ │ -
│ │ │ │ -
171 void enableBruteForce(bool bruteForce)
│ │ │ │ -
172 {
│ │ │ │ -
173 m_enableBruteForce = bruteForce;
│ │ │ │ -
174 }
│ │ │ │ -
│ │ │ │ -
175
│ │ │ │ -
176private:
│ │ │ │ -
180 bool m_enableFallback = false;
│ │ │ │ -
181
│ │ │ │ -
185 bool m_enableBruteForce = false;
│ │ │ │ -
186
│ │ │ │ -
187 auto& intersections()
│ │ │ │ -
188 { return intersectionListProvider_->intersections(); }
│ │ │ │ -
189
│ │ │ │ -
191 template<typename V>
│ │ │ │ -
192 static void purge(V & v)
│ │ │ │ -
193 {
│ │ │ │ -
194 v.clear();
│ │ │ │ -
195 V v2(v);
│ │ │ │ -
196 v.swap(v2);
│ │ │ │ -
197 }
│ │ │ │ -
198
│ │ │ │ -
203 void generateSeed(std::vector<int>& seeds,
│ │ │ │ -
204 Dune::BitSetVector<1>& isHandled2,
│ │ │ │ -
205 std::stack<unsigned>& candidates2,
│ │ │ │ -
206 const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords,
│ │ │ │ -
207 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
208 const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords,
│ │ │ │ -
209 const std::vector<Dune::GeometryType>& grid2_element_types);
│ │ │ │ -
210
│ │ │ │ -
214 int insertIntersections(unsigned int candidate1, unsigned int candidate2,std::vector<SimplicialIntersection>& intersections);
│ │ │ │ -
215
│ │ │ │ -
219 int bruteForceSearch(int candidate1,
│ │ │ │ -
220 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
221 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
222 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
223 const std::vector<Dune::GeometryType>& grid2_element_types);
│ │ │ │ -
224
│ │ │ │ -
228 std::pair<bool, unsigned int>
│ │ │ │ -
229 intersectionIndex(unsigned int grid1Index, unsigned int grid2Index,
│ │ │ │ -
230 SimplicialIntersection& intersection);
│ │ │ │ -
231
│ │ │ │ -
235 template <int gridDim>
│ │ │ │ -
236 void computeNeighborsPerElement(const std::vector<Dune::GeometryType>& gridElementTypes,
│ │ │ │ -
237 const std::vector<std::vector<unsigned int> >& gridElementCorners,
│ │ │ │ -
238 std::vector<std::vector<int> >& elementNeighbors);
│ │ │ │ -
239
│ │ │ │ -
240 void buildAdvancingFront(
│ │ │ │ -
241 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ -
242 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
243 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
244 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ -
245 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
246 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ -
247 );
│ │ │ │ -
248
│ │ │ │ -
249 void buildBruteForce(
│ │ │ │ -
250 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ -
251 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
252 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
253 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ -
254 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
255 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ -
256 );
│ │ │ │ -
257};
│ │ │ │ -
258
│ │ │ │ -
259
│ │ │ │ -
260/* IMPLEMENTATION */
│ │ │ │ -
261
│ │ │ │ -
262template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
│ │ │ │ -
263bool StandardMerge<T,grid1Dim,grid2Dim,dimworld>::computeIntersection(unsigned int candidate0, unsigned int candidate1,
│ │ │ │ -
264 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
265 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
266 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ -
267 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
268 const std::vector<Dune::GeometryType>& grid2_element_types,
│ │ │ │ -
269 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ -
270 bool insert)
│ │ │ │ -
271{
│ │ │ │ -
272 // Select vertices of the grid1 element
│ │ │ │ -
273 int grid1NumVertices = grid1ElementCorners_[candidate0].size();
│ │ │ │ -
274 std::vector<Dune::FieldVector<T,dimworld> > grid1ElementCorners(grid1NumVertices);
│ │ │ │ -
275 for (int i=0; i<grid1NumVertices; i++)
│ │ │ │ -
276 grid1ElementCorners[i] = grid1Coords[grid1ElementCorners_[candidate0][i]];
│ │ │ │ -
277
│ │ │ │ -
278 // Select vertices of the grid2 element
│ │ │ │ -
279 int grid2NumVertices = grid2ElementCorners_[candidate1].size();
│ │ │ │ -
280 std::vector<Dune::FieldVector<T,dimworld> > grid2ElementCorners(grid2NumVertices);
│ │ │ │ -
281 for (int i=0; i<grid2NumVertices; i++)
│ │ │ │ -
282 grid2ElementCorners[i] = grid2Coords[grid2ElementCorners_[candidate1][i]];
│ │ │ │ -
283
│ │ │ │ -
284 // ///////////////////////////////////////////////////////
│ │ │ │ -
285 // Compute the intersection between the two elements
│ │ │ │ -
286 // ///////////////////////////////////////////////////////
│ │ │ │ -
287
│ │ │ │ -
288 std::vector<SimplicialIntersection> intersections(0);
│ │ │ │ -
289
│ │ │ │ -
290 // compute the intersections
│ │ │ │ -
291 computeIntersections(grid1_element_types[candidate0], grid1ElementCorners,
│ │ │ │ -
292 neighborIntersects1, candidate0,
│ │ │ │ -
293 grid2_element_types[candidate1], grid2ElementCorners,
│ │ │ │ -
294 neighborIntersects2, candidate1,
│ │ │ │ - │ │ │ │ -
296
│ │ │ │ -
297 // insert intersections if needed
│ │ │ │ -
298 if(insert && !intersections.empty())
│ │ │ │ -
299 insertIntersections(candidate0,candidate1,intersections);
│ │ │ │ -
300
│ │ │ │ -
301 // Have we found an intersection?
│ │ │ │ -
302 return !intersections.empty() || neighborIntersects1.any() || neighborIntersects2.any();
│ │ │ │ -
303
│ │ │ │ -
304}
│ │ │ │ -
│ │ │ │ -
305
│ │ │ │ -
306template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ - │ │ │ │ -
308 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
309 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
310 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
311 const std::vector<Dune::GeometryType>& grid2_element_types)
│ │ │ │ -
312{
│ │ │ │ -
313 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ -
314 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ -
315 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
│ │ │ │ -
316
│ │ │ │ -
317 bool intersectionFound = computeIntersection(i, candidate1,
│ │ │ │ -
318 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ -
319 grid2Coords, grid2_element_types, neighborIntersects2,
│ │ │ │ -
320 false);
│ │ │ │ -
321
│ │ │ │ -
322 // if there is an intersection, i is our new seed candidate on the grid1 side
│ │ │ │ -
323 if (intersectionFound)
│ │ │ │ -
324 return i;
│ │ │ │ -
325
│ │ │ │ -
326 }
│ │ │ │ -
327
│ │ │ │ -
328 return -1;
│ │ │ │ -
329}
│ │ │ │ -
330
│ │ │ │ -
331
│ │ │ │ -
332template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
333template<int gridDim>
│ │ │ │ -
334void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::
│ │ │ │ -
335computeNeighborsPerElement(const std::vector<Dune::GeometryType>& gridElementTypes,
│ │ │ │ -
336 const std::vector<std::vector<unsigned int> >& gridElementCorners,
│ │ │ │ -
337 std::vector<std::vector<int> >& elementNeighbors)
│ │ │ │ -
338{
│ │ │ │ -
339 typedef std::vector<unsigned int> FaceType;
│ │ │ │ -
340 typedef std::map<FaceType, std::pair<unsigned int, unsigned int> > FaceSetType;
│ │ │ │ -
341
│ │ │ │ -
343 // First: grid 1
│ │ │ │ -
345 FaceSetType faces;
│ │ │ │ -
346 elementNeighbors.resize(gridElementTypes.size());
│ │ │ │ -
347
│ │ │ │ -
348 for (size_t i=0; i<gridElementTypes.size(); i++)
│ │ │ │ -
349 elementNeighbors[i].resize(Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]).size(1), -1);
│ │ │ │ -
350
│ │ │ │ -
351 for (size_t i=0; i<gridElementTypes.size(); i++) { //iterate over all elements
│ │ │ │ -
352 const auto& refElement = Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]);
│ │ │ │ -
353
│ │ │ │ -
354 for (size_t j=0; j<(size_t)refElement.size(1); j++) { // iterate over all faces of the element
│ │ │ │ -
355
│ │ │ │ -
356 FaceType face;
│ │ │ │ -
357 // extract element face
│ │ │ │ -
358 for (size_t k=0; k<(size_t)refElement.size(j,1,gridDim); k++)
│ │ │ │ -
359 face.push_back(gridElementCorners[i][refElement.subEntity(j,1,k,gridDim)]);
│ │ │ │ -
360
│ │ │ │ -
361 // sort the face vertices to get rid of twists and other permutations
│ │ │ │ -
362 std::sort(face.begin(), face.end());
│ │ │ │ -
363
│ │ │ │ -
364 typename FaceSetType::iterator faceHandle = faces.find(face);
│ │ │ │ -
365
│ │ │ │ -
366 if (faceHandle == faces.end()) {
│ │ │ │ -
367
│ │ │ │ -
368 // face has not been visited before
│ │ │ │ -
369 faces.insert(std::make_pair(face, std::make_pair(i,j)));
│ │ │ │ -
370
│ │ │ │ -
371 } else {
│ │ │ │ -
372
│ │ │ │ -
373 // face has been visited before: store the mutual neighbor information
│ │ │ │ -
374 elementNeighbors[i][j] = faceHandle->second.first;
│ │ │ │ -
375 elementNeighbors[faceHandle->second.first][faceHandle->second.second] = i;
│ │ │ │ -
376
│ │ │ │ -
377 faces.erase(faceHandle);
│ │ │ │ -
378
│ │ │ │ -
379 }
│ │ │ │ -
380
│ │ │ │ -
381 }
│ │ │ │ -
382
│ │ │ │ -
383 }
│ │ │ │ -
384}
│ │ │ │ -
385
│ │ │ │ -
386// /////////////////////////////////////////////////////////////////////
│ │ │ │ -
387// Compute the intersection of all pairs of elements
│ │ │ │ -
388// Linear algorithm by Gander and Japhet, Proc. of DD18
│ │ │ │ -
389// /////////////////////////////////////////////////////////////////////
│ │ │ │ -
390
│ │ │ │ -
391template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
│ │ │ │ -
392void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
393 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
394 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
395 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
396 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
397 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ -
398 )
│ │ │ │ -
399{
│ │ │ │ -
400
│ │ │ │ -
401 std::cout << "StandardMerge building merged grid..." << std::endl;
│ │ │ │ -
402 Dune::Timer watch;
│ │ │ │ -
403
│ │ │ │ -
404 clear();
│ │ │ │ -
405 // clear global intersection list
│ │ │ │ -
406 intersectionListProvider_->clear();
│ │ │ │ -
407 this->counter = 0;
│ │ │ │ -
408
│ │ │ │ -
409 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
410 // Copy element corners into a data structure with block-structure.
│ │ │ │ -
411 // This is not as efficient but a lot easier to use.
│ │ │ │ -
412 // We may think about efficiency later.
│ │ │ │ -
413 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
414
│ │ │ │ -
415 // first the grid1 side
│ │ │ │ -
416 grid1ElementCorners_.resize(grid1_element_types.size());
│ │ │ │ -
417
│ │ │ │ -
418 unsigned int grid1CornerCounter = 0;
│ │ │ │ -
419
│ │ │ │ -
420 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
│ │ │ │ -
421
│ │ │ │ -
422 // Select vertices of the grid1 element
│ │ │ │ -
423 int numVertices = Dune::ReferenceElements<T,grid1Dim>::general(grid1_element_types[i]).size(grid1Dim);
│ │ │ │ -
424 grid1ElementCorners_[i].resize(numVertices);
│ │ │ │ -
425 for (int j=0; j<numVertices; j++)
│ │ │ │ -
426 grid1ElementCorners_[i][j] = grid1_elements[grid1CornerCounter++];
│ │ │ │ -
427
│ │ │ │ -
428 }
│ │ │ │ -
429
│ │ │ │ -
430 // then the grid2 side
│ │ │ │ -
431 grid2ElementCorners_.resize(grid2_element_types.size());
│ │ │ │ -
432
│ │ │ │ -
433 unsigned int grid2CornerCounter = 0;
│ │ │ │ -
434
│ │ │ │ -
435 for (std::size_t i=0; i<grid2_element_types.size(); i++) {
│ │ │ │ -
436
│ │ │ │ -
437 // Select vertices of the grid2 element
│ │ │ │ -
438 int numVertices = Dune::ReferenceElements<T,grid2Dim>::general(grid2_element_types[i]).size(grid2Dim);
│ │ │ │ -
439 grid2ElementCorners_[i].resize(numVertices);
│ │ │ │ -
440 for (int j=0; j<numVertices; j++)
│ │ │ │ -
441 grid2ElementCorners_[i][j] = grid2_elements[grid2CornerCounter++];
│ │ │ │ -
442
│ │ │ │ -
443 }
│ │ │ │ -
444
│ │ │ │ -
446 // Compute the face neighbors for each element
│ │ │ │ -
448
│ │ │ │ -
449 computeNeighborsPerElement<grid1Dim>(grid1_element_types, grid1ElementCorners_, elementNeighbors1_);
│ │ │ │ -
450 computeNeighborsPerElement<grid2Dim>(grid2_element_types, grid2ElementCorners_, elementNeighbors2_);
│ │ │ │ -
451
│ │ │ │ -
452 std::cout << "setup took " << watch.elapsed() << " seconds." << std::endl;
│ │ │ │ -
453
│ │ │ │ -
454 if (m_enableBruteForce)
│ │ │ │ -
455 buildBruteForce(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
│ │ │ │ -
456 else
│ │ │ │ -
457 buildAdvancingFront(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
│ │ │ │ -
458
│ │ │ │ -
459 valid = true;
│ │ │ │ -
460 std::cout << "intersection construction took " << watch.elapsed() << " seconds." << std::endl;
│ │ │ │ -
461}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
462
│ │ │ │ -
463template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ - │ │ │ │ -
465 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
466 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
467 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
468 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
469 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
470 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ -
471 )
│ │ │ │ -
472{
│ │ │ │ -
474 // Data structures for the advancing-front algorithm
│ │ │ │ -
476
│ │ │ │ -
477 std::stack<unsigned int> candidates1;
│ │ │ │ -
478 std::stack<unsigned int> candidates2;
│ │ │ │ -
479
│ │ │ │ -
480 std::vector<int> seeds(grid2_element_types.size(), -1);
│ │ │ │ -
481
│ │ │ │ -
482 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
483 // Do a brute-force search to find one pair of intersecting elements
│ │ │ │ -
484 // to start the advancing-front type algorithm with.
│ │ │ │ -
485 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
486
│ │ │ │ -
487 // Set flag if element has been handled
│ │ │ │ -
488 Dune::BitSetVector<1> isHandled2(grid2_element_types.size());
│ │ │ │ -
489
│ │ │ │ -
490 // Set flag if the element has been entered in the queue
│ │ │ │ -
491 Dune::BitSetVector<1> isCandidate2(grid2_element_types.size());
│ │ │ │ -
492
│ │ │ │ -
493 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
│ │ │ │ -
494
│ │ │ │ -
495 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
496 // Main loop
│ │ │ │ -
497 // /////////////////////////////////////////////////////////////////////
│ │ │ │ -
498
│ │ │ │ -
499 std::set<unsigned int> isHandled1;
│ │ │ │ -
500
│ │ │ │ -
501 std::set<unsigned int> isCandidate1;
│ │ │ │ -
502
│ │ │ │ -
503 while (!candidates2.empty()) {
│ │ │ │ -
504
│ │ │ │ -
505 // Get the next element on the grid2 side
│ │ │ │ -
506 unsigned int currentCandidate2 = candidates2.top();
│ │ │ │ -
507 int seed = seeds[currentCandidate2];
│ │ │ │ -
508 assert(seed >= 0);
│ │ │ │ -
509
│ │ │ │ -
510 candidates2.pop();
│ │ │ │ -
511 isHandled2[currentCandidate2] = true;
│ │ │ │ -
512
│ │ │ │ -
513 // Start advancing front algorithm on the grid1 side from the 'seed' element that
│ │ │ │ -
514 // we stored along with the current grid2 element
│ │ │ │ -
515 candidates1.push(seed);
│ │ │ │ -
516
│ │ │ │ -
517 isHandled1.clear();
│ │ │ │ -
518 isCandidate1.clear();
│ │ │ │ -
519
│ │ │ │ -
520 while (!candidates1.empty()) {
│ │ │ │ -
521
│ │ │ │ -
522 unsigned int currentCandidate1 = candidates1.top();
│ │ │ │ -
523 candidates1.pop();
│ │ │ │ -
524 isHandled1.insert(currentCandidate1);
│ │ │ │ -
525
│ │ │ │ -
526 // Test whether there is an intersection between currentCandidate0 and currentCandidate1
│ │ │ │ -
527 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ -
528 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ -
529 bool intersectionFound = computeIntersection(currentCandidate1, currentCandidate2,
│ │ │ │ -
530 grid1Coords,grid1_element_types, neighborIntersects1,
│ │ │ │ -
531 grid2Coords,grid2_element_types, neighborIntersects2);
│ │ │ │ -
532
│ │ │ │ -
533 for (size_t i=0; i<neighborIntersects2.size(); i++)
│ │ │ │ -
534 if (neighborIntersects2[i] && elementNeighbors2_[currentCandidate2][i] != -1)
│ │ │ │ -
535 seeds[elementNeighbors2_[currentCandidate2][i]] = currentCandidate1;
│ │ │ │ -
536
│ │ │ │ -
537 // add neighbors of candidate0 to the list of elements to be checked
│ │ │ │ -
538 if (intersectionFound) {
│ │ │ │ -
539
│ │ │ │ -
540 for (size_t i=0; i<elementNeighbors1_[currentCandidate1].size(); i++) {
│ │ │ │ -
541
│ │ │ │ -
542 int neighbor = elementNeighbors1_[currentCandidate1][i];
│ │ │ │ -
543
│ │ │ │ -
544 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ -
545 continue;
│ │ │ │ -
546
│ │ │ │ -
547 if (isHandled1.find(neighbor) == isHandled1.end()
│ │ │ │ -
548 && isCandidate1.find(neighbor) == isCandidate1.end()) {
│ │ │ │ -
549 candidates1.push(neighbor);
│ │ │ │ -
550 isCandidate1.insert(neighbor);
│ │ │ │ -
551 }
│ │ │ │ -
552
│ │ │ │ -
553 }
│ │ │ │ -
554
│ │ │ │ -
555 }
│ │ │ │ -
556
│ │ │ │ -
557 }
│ │ │ │ -
558
│ │ │ │ -
559 // We have now found all intersections of elements in the grid1 side with currentCandidate2
│ │ │ │ -
560 // Now we add all neighbors of currentCandidate2 that have not been treated yet as new
│ │ │ │ -
561 // candidates.
│ │ │ │ -
562
│ │ │ │ -
563 // Do we have an unhandled neighbor with a seed?
│ │ │ │ -
564 bool seedFound = !candidates2.empty();
│ │ │ │ -
565 for (size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
│ │ │ │ -
566
│ │ │ │ -
567 int neighbor = elementNeighbors2_[currentCandidate2][i];
│ │ │ │ -
568
│ │ │ │ -
569 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ -
570 continue;
│ │ │ │ -
571
│ │ │ │ -
572 // Add all unhandled intersecting neighbors to the queue
│ │ │ │ -
573 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0] && seeds[neighbor]>-1) {
│ │ │ │ -
574
│ │ │ │ -
575 isCandidate2[neighbor][0] = true;
│ │ │ │ -
576 candidates2.push(neighbor);
│ │ │ │ -
577 seedFound = true;
│ │ │ │ -
578 }
│ │ │ │ -
579 }
│ │ │ │ -
580
│ │ │ │ -
581 if (seedFound || !m_enableFallback)
│ │ │ │ -
582 continue;
│ │ │ │ -
583
│ │ │ │ -
584 // There is no neighbor with a seed, so we need to be a bit more aggressive...
│ │ │ │ -
585 // get all neighbors of currentCandidate2, but not currentCandidate2 itself
│ │ │ │ -
586 for (size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
│ │ │ │ -
587
│ │ │ │ -
588 int neighbor = elementNeighbors2_[currentCandidate2][i];
│ │ │ │ -
589
│ │ │ │ -
590 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ -
591 continue;
│ │ │ │ -
592
│ │ │ │ -
593 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0]) {
│ │ │ │ -
594
│ │ │ │ -
595 // Get a seed element for the new grid2 element
│ │ │ │ -
596 // Look for an element on the grid1 side that intersects the new grid2 element.
│ │ │ │ -
597 int seed = -1;
│ │ │ │ -
598
│ │ │ │ -
599 // Look among the ones that have been tested during the last iteration.
│ │ │ │ -
600 for (typename std::set<unsigned int>::iterator seedIt = isHandled1.begin();
│ │ │ │ -
601 seedIt != isHandled1.end(); ++seedIt) {
│ │ │ │ -
602
│ │ │ │ -
603 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ -
604 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ -
605 bool intersectionFound = computeIntersection(*seedIt, neighbor,
│ │ │ │ -
606 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ -
607 grid2Coords, grid2_element_types, neighborIntersects2,
│ │ │ │ -
608 false);
│ │ │ │ -
609
│ │ │ │ -
610 // if the intersection is nonempty, *seedIt is our new seed candidate on the grid1 side
│ │ │ │ -
611 if (intersectionFound) {
│ │ │ │ -
612 seed = *seedIt;
│ │ │ │ -
613 Dune::dwarn << "Algorithm entered first fallback method and found a new seed in the build algorithm." <<
│ │ │ │ -
614 "Probably, the neighborIntersects bitsets computed in computeIntersection specialization is wrong." << std::endl;
│ │ │ │ -
615 break;
│ │ │ │ -
616 }
│ │ │ │ -
617
│ │ │ │ -
618 }
│ │ │ │ -
619
│ │ │ │ -
620 if (seed < 0) {
│ │ │ │ -
621 // The fast method didn't find a grid1 element that intersects with
│ │ │ │ -
622 // the new grid2 candidate. We have to do a brute-force search.
│ │ │ │ -
623 seed = bruteForceSearch(neighbor,
│ │ │ │ -
624 grid1Coords,grid1_element_types,
│ │ │ │ -
625 grid2Coords,grid2_element_types);
│ │ │ │ -
626 Dune::dwarn << "Algorithm entered second fallback method. This probably should not happen." << std::endl;
│ │ │ │ -
627
│ │ │ │ -
628 }
│ │ │ │ -
629
│ │ │ │ -
630 // We have tried all we could: the candidate is 'handled' now
│ │ │ │ -
631 isCandidate2[neighbor] = true;
│ │ │ │ -
632
│ │ │ │ -
633 // still no seed? Then the new grid2 candidate isn't overlapped by anything
│ │ │ │ -
634 if (seed < 0)
│ │ │ │ -
635 continue;
│ │ │ │ -
636
│ │ │ │ -
637 // we have a seed now
│ │ │ │ -
638 candidates2.push(neighbor);
│ │ │ │ -
639 seeds[neighbor] = seed;
│ │ │ │ -
640 seedFound = true;
│ │ │ │ -
641
│ │ │ │ -
642 }
│ │ │ │ -
643
│ │ │ │ -
644 }
│ │ │ │ -
645
│ │ │ │ -
646 /* Do a brute-force search if there is still no seed:
│ │ │ │ -
647 * There might still be a disconnected region out there.
│ │ │ │ -
648 */
│ │ │ │ -
649 if (!seedFound && candidates2.empty()) {
│ │ │ │ -
650 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
│ │ │ │ -
651 }
│ │ │ │ -
652 }
│ │ │ │ -
653}
│ │ │ │ -
654
│ │ │ │ -
655template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
656void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::buildBruteForce(
│ │ │ │ -
657 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ -
658 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ -
659 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ -
660 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ -
661 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ -
662 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ -
663 )
│ │ │ │ -
664{
│ │ │ │ -
665 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ -
666 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ -
667
│ │ │ │ -
668 for (unsigned i = 0; i < grid1_element_types.size(); ++i) {
│ │ │ │ -
669 for (unsigned j = 0; j < grid2_element_types.size(); ++j) {
│ │ │ │ -
670 (void) computeIntersection(i, j,
│ │ │ │ -
671 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ -
672 grid2Coords, grid2_element_types, neighborIntersects2);
│ │ │ │ -
673 }
│ │ │ │ -
674 }
│ │ │ │ -
675}
│ │ │ │ -
676
│ │ │ │ -
677template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
678void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::generateSeed(std::vector<int>& seeds, Dune::BitSetVector<1>& isHandled2, std::stack<unsigned>& candidates2, const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords, const std::vector<Dune::GeometryType>& grid1_element_types, const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords, const std::vector<Dune::GeometryType>& grid2_element_types)
│ │ │ │ -
679{
│ │ │ │ -
680 for (std::size_t j=0; j<grid2_element_types.size(); j++) {
│ │ │ │ -
681
│ │ │ │ -
682 if (seeds[j] > 0 || isHandled2[j][0])
│ │ │ │ -
683 continue;
│ │ │ │ -
684
│ │ │ │ -
685 int seed = bruteForceSearch(j,grid1Coords,grid1_element_types,grid2Coords,grid2_element_types);
│ │ │ │ -
686
│ │ │ │ -
687 if (seed >= 0) {
│ │ │ │ -
688 candidates2.push(j); // the candidate and a seed for the candidate
│ │ │ │ -
689 seeds[j] = seed;
│ │ │ │ -
690 break;
│ │ │ │ -
691 } else // If the brute force search did not find any intersection we can skip this element
│ │ │ │ -
692 isHandled2[j] = true;
│ │ │ │ -
693 }
│ │ │ │ -
694}
│ │ │ │ -
695
│ │ │ │ -
696template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
697int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::insertIntersections(unsigned int candidate1, unsigned int candidate2,
│ │ │ │ -
698 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ -
699{
│ │ │ │ -
700 typedef typename std::vector<SimplicialIntersection>::size_type size_t;
│ │ │ │ -
701 int count = 0;
│ │ │ │ -
702
│ │ │ │ -
703 for (size_t i = 0; i < intersections.size(); ++i) {
│ │ │ │ -
704 // get the intersection index of the current intersection from intersections in this->intersections
│ │ │ │ -
705 bool found;
│ │ │ │ -
706 unsigned int index;
│ │ │ │ -
707 std::tie(found, index) = intersectionIndex(candidate1,candidate2,intersections[i]);
│ │ │ │ -
708
│ │ │ │ -
709 if (found && index >= this->intersections().size()) { //the intersection is not yet contained in this->intersections
│ │ │ │ -
710 this->intersections().push_back(intersections[i]); // insert
│ │ │ │ -
711
│ │ │ │ -
712 ++count;
│ │ │ │ -
713 } else if (found) {
│ │ │ │ -
714 auto& intersection = this->intersections()[index];
│ │ │ │ -
715
│ │ │ │ -
716 // insert each grid1 element and local representation of intersections[i] with parent candidate1
│ │ │ │ -
717 for (size_t j = 0; j < intersections[i].parents0.size(); ++j) {
│ │ │ │ -
718 intersection.parents0.push_back(candidate1);
│ │ │ │ -
719 intersection.corners0.push_back(intersections[i].corners0[j]);
│ │ │ │ -
720 }
│ │ │ │ -
721
│ │ │ │ -
722 // insert each grid2 element and local representation of intersections[i] with parent candidate2
│ │ │ │ -
723 for (size_t j = 0; j < intersections[i].parents1.size(); ++j) {
│ │ │ │ -
724 intersection.parents1.push_back(candidate2);
│ │ │ │ -
725 intersection.corners1.push_back(intersections[i].corners1[j]);
│ │ │ │ -
726 }
│ │ │ │ -
727
│ │ │ │ -
728 ++count;
│ │ │ │ -
729 } else {
│ │ │ │ -
730 Dune::dwarn << "Computed the same intersection twice!" << std::endl;
│ │ │ │ -
731 }
│ │ │ │ -
732 }
│ │ │ │ -
733 return count;
│ │ │ │ -
734}
│ │ │ │ -
735
│ │ │ │ -
736template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ -
737std::pair<bool, unsigned int>
│ │ │ │ -
738StandardMerge<T,grid1Dim,grid2Dim,dimworld>::intersectionIndex(unsigned int grid1Index, unsigned int grid2Index,
│ │ │ │ -
739 SimplicialIntersection& intersection) {
│ │ │ │ -
740
│ │ │ │ -
741
│ │ │ │ -
742 // return index in intersections_ if at least one local representation of a Simplicial Intersection (SI)
│ │ │ │ -
743 // of intersections_ is equal to the local representation of one element in intersections
│ │ │ │ -
744
│ │ │ │ -
745 std::size_t n_intersections = this->intersections().size();
│ │ │ │ -
746 if (grid1Dim == grid2Dim)
│ │ │ │ -
747 return {true, n_intersections};
│ │ │ │ -
748
│ │ │ │ -
749 T eps = 1e-10;
│ │ │ │ -
750
│ │ │ │ -
751 for (std::size_t i = 0; i < n_intersections; ++i) {
│ │ │ │ -
752
│ │ │ │ -
753 // compare the local representation of the subelements of the SI
│ │ │ │ -
754 for (std::size_t ei = 0; ei < this->intersections()[i].parents0.size(); ++ei) // merger subelement
│ │ │ │ -
755 {
│ │ │ │ -
756 if (this->intersections()[i].parents0[ei] == grid1Index)
│ │ │ │ -
757 {
│ │ │ │ -
758 for (std::size_t er = 0; er < intersection.parents0.size(); ++er) // list subelement
│ │ │ │ -
759 {
│ │ │ │ -
760 bool found_all = true;
│ │ │ │ -
761 // compare the local coordinate representations
│ │ │ │ -
762 for (std::size_t ci = 0; ci < this->intersections()[i].corners0[ei].size(); ++ci)
│ │ │ │ -
763 {
│ │ │ │ -
764 Dune::FieldVector<T,grid1Dim> ni = this->intersections()[i].corners0[ei][ci];
│ │ │ │ -
765 bool found_ni = false;
│ │ │ │ -
766 for (std::size_t cr = 0; cr < intersection.corners0[er].size(); ++cr)
│ │ │ │ -
767 {
│ │ │ │ -
768 Dune::FieldVector<T,grid1Dim> nr = intersection.corners0[er][cr];
│ │ │ │ -
769
│ │ │ │ -
770 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
│ │ │ │ -
771 if (found_ni)
│ │ │ │ -
772 break;
│ │ │ │ -
773 }
│ │ │ │ -
774 found_all = found_all && found_ni;
│ │ │ │ -
775
│ │ │ │ -
776 if (!found_ni)
│ │ │ │ -
777 break;
│ │ │ │ -
778 }
│ │ │ │ -
779
│ │ │ │ -
780 if (found_all && (this->intersections()[i].parents1[ei] != grid2Index))
│ │ │ │ -
781 return {true, i};
│ │ │ │ -
782 else if (found_all)
│ │ │ │ -
783 return {false, 0};
│ │ │ │ -
784 }
│ │ │ │ -
785 }
│ │ │ │ -
786 }
│ │ │ │ -
787
│ │ │ │ -
788 // compare the local representation of the subelements of the SI
│ │ │ │ -
789 for (std::size_t ei = 0; ei < this->intersections()[i].parents1.size(); ++ei) // merger subelement
│ │ │ │ -
790 {
│ │ │ │ -
791 if (this->intersections()[i].parents1[ei] == grid2Index)
│ │ │ │ -
792 {
│ │ │ │ -
793 for (std::size_t er = 0; er < intersection.parents1.size(); ++er) // list subelement
│ │ │ │ -
794 {
│ │ │ │ -
795 bool found_all = true;
│ │ │ │ -
796 // compare the local coordinate representations
│ │ │ │ -
797 for (std::size_t ci = 0; ci < this->intersections()[i].corners1[ei].size(); ++ci)
│ │ │ │ -
798 {
│ │ │ │ -
799 Dune::FieldVector<T,grid2Dim> ni = this->intersections()[i].corners1[ei][ci];
│ │ │ │ -
800 bool found_ni = false;
│ │ │ │ -
801 for (std::size_t cr = 0; cr < intersection.corners1[er].size(); ++cr)
│ │ │ │ -
802 {
│ │ │ │ -
803 Dune::FieldVector<T,grid2Dim> nr = intersection.corners1[er][cr];
│ │ │ │ -
804 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
│ │ │ │ -
805
│ │ │ │ -
806 if (found_ni)
│ │ │ │ -
807 break;
│ │ │ │ -
808 }
│ │ │ │ -
809 found_all = found_all && found_ni;
│ │ │ │ -
810
│ │ │ │ -
811 if (!found_ni)
│ │ │ │ -
812 break;
│ │ │ │ -
813 }
│ │ │ │ -
814
│ │ │ │ -
815 if (found_all && (this->intersections()[i].parents0[ei] != grid1Index))
│ │ │ │ -
816 return {true, i};
│ │ │ │ -
817 else if (found_all)
│ │ │ │ -
818 return {false, 0};
│ │ │ │ -
819 }
│ │ │ │ -
820 }
│ │ │ │ -
821 }
│ │ │ │ -
822 }
│ │ │ │ -
823
│ │ │ │ -
824 return {true, n_intersections};
│ │ │ │ -
825}
│ │ │ │ -
826
│ │ │ │ -
827#define DECL extern
│ │ │ │ -
│ │ │ │ -
828#define STANDARD_MERGE_INSTANTIATE(T,A,B,C) \
│ │ │ │ -
829 DECL template \
│ │ │ │ -
830 void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1Coords, \
│ │ │ │ -
831 const std::vector<unsigned int>& grid1_elements, \
│ │ │ │ -
832 const std::vector<Dune::GeometryType>& grid1_element_types, \
│ │ │ │ -
833 const std::vector<Dune::FieldVector<T,C> >& grid2Coords, \
│ │ │ │ -
834 const std::vector<unsigned int>& grid2_elements, \
│ │ │ │ -
835 const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │ -
836 )
│ │ │ │ -
│ │ │ │ -
837
│ │ │ │ -
838STANDARD_MERGE_INSTANTIATE(double,1,1,1);
│ │ │ │ -
839STANDARD_MERGE_INSTANTIATE(double,2,2,2);
│ │ │ │ -
840STANDARD_MERGE_INSTANTIATE(double,3,3,3);
│ │ │ │ -
841#undef STANDARD_MERGE_INSTANTIATE
│ │ │ │ -
842#undef DECL
│ │ │ │ -
843
│ │ │ │ -
844} /* namespace GridGlue */
│ │ │ │ -
845} /* namespace Dune */
│ │ │ │ -
846
│ │ │ │ -
847#endif // DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ -
#define STANDARD_MERGE_INSTANTIATE(T, A, B, C)
Definition standardmerge.cc:13
│ │ │ │ - │ │ │ │ +
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
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
Definition intersectionlist.hh:207
│ │ │ │ - │ │ │ │ -
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition merger.hh:27
│ │ │ │ -
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition merger.hh:37
│ │ │ │ -
Dune::GridGlue::IntersectionList< Grid1Coords, Grid2Coords > IntersectionList
Definition merger.hh:39
│ │ │ │ -
Dune::FieldVector< T, grid1Dim > Grid1Coords
the local coordinate type for the grid1 coordinates
Definition merger.hh:31
│ │ │ │ -
Dune::FieldVector< T, grid2Dim > Grid2Coords
the local coordinate type for the grid2 coordinates
Definition merger.hh:34
│ │ │ │ +
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
│ │ │ │ -
virtual void computeIntersections(const Dune::GeometryType &grid1ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std::bitset<(1<< grid1Dim)> &neighborIntersects1, unsigned int grid1Index, const Dune::GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< grid2Dim)> &neighborIntersects2, unsigned int grid2Index, std::vector< SimplicialIntersection > &intersections)=0
Compute the intersection between two overlapping elements.
│ │ │ │ -
std::shared_ptr< IntersectionList > intersectionList_
Definition standardmerge.hh:124
│ │ │ │ -
typename Base::Grid1Coords Grid1Coords
Type used for local coordinates on the grid1 side.
Definition standardmerge.hh:69
│ │ │ │ -
void enableFallback(bool fallback)
Definition standardmerge.hh:166
│ │ │ │ -
std::vector< std::vector< int > > elementNeighbors2_
Definition standardmerge.hh:131
│ │ │ │ -
std::vector< std::vector< int > > elementNeighbors1_
Definition standardmerge.hh:130
│ │ │ │ -
T ctype
the numeric type used in this interface
Definition standardmerge.hh:66
│ │ │ │ -
void clear() override
Definition standardmerge.hh:150
│ │ │ │ -
typename Base::IntersectionList IntersectionList
Definition standardmerge.hh:77
│ │ │ │ -
bool computeIntersection(unsigned int candidate0, unsigned int candidate1, const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std::vector< Dune::GeometryType > &grid1_element_types, std::bitset<(1<< grid1Dim)> &neighborIntersects1, const std::vector< Dune::FieldVector< T, dimworld > > &grid2Coords, const std::vector< Dune::GeometryType > &grid2_element_types, std::bitset<(1<< grid2Dim)> &neighborIntersects2, bool insert=true)
Compute the intersection between two overlapping elements.
Definition standardmerge.hh:263
│ │ │ │ -
void enableBruteForce(bool bruteForce)
Definition standardmerge.hh:171
│ │ │ │ -
std::shared_ptr< IntersectionListProvider > intersectionListProvider_
Definition standardmerge.hh:123
│ │ │ │ -
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 standardmerge.hh:392
│ │ │ │ -
std::vector< std::vector< unsigned int > > grid1ElementCorners_
Temporary internal data.
Definition standardmerge.hh:127
│ │ │ │ -
std::vector< std::vector< unsigned int > > grid2ElementCorners_
Definition standardmerge.hh:128
│ │ │ │ -
typename Base::Grid2Coords Grid2Coords
Type used for local coordinates on the grid2 side.
Definition standardmerge.hh:72
│ │ │ │ -
std::shared_ptr< IntersectionList > intersectionList() const final
Definition standardmerge.hh:160
│ │ │ │ -
virtual ~StandardMerge()=default
│ │ │ │ -
SimplicialIntersection RemoteSimplicialIntersection
Definition standardmerge.hh:84
│ │ │ │ -
bool valid
Definition standardmerge.hh:86
│ │ │ │ -
StandardMerge()
Definition standardmerge.hh:88
│ │ │ │
typename IntersectionListProvider::SimplicialIntersection SimplicialIntersection
Definition standardmerge.hh:83
│ │ │ │ -
typename Base::WorldCoords WorldCoords
the coordinate type used in this interface
Definition standardmerge.hh:75
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,989 +1,127 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -standardmerge.hh │ │ │ │ │ +overlappingmerge.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_STANDARDMERGE_HH │ │ │ │ │ -11#define DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH │ │ │ │ │ +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 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15 │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19#include │ │ │ │ │ +20 │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ 23 │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28 │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31 │ │ │ │ │ -32#include │ │ │ │ │ -33#include │ │ │ │ │ -34#include │ │ │ │ │ -35 │ │ │ │ │ -36namespace Dune { │ │ │ │ │ -37namespace GridGlue { │ │ │ │ │ +24namespace Dune { │ │ │ │ │ +25namespace GridGlue { │ │ │ │ │ +26 │ │ │ │ │ +34template │ │ │ │ │ +35class OverlappingMerge │ │ │ │ │ +36 : public StandardMerge │ │ │ │ │ +37{ │ │ │ │ │ 38 │ │ │ │ │ -55template │ │ │ │ │ -56class StandardMerge │ │ │ │ │ -57 : public Merger │ │ │ │ │ -58{ │ │ │ │ │ -59 using Base = Merger; │ │ │ │ │ -60 │ │ │ │ │ -61public: │ │ │ │ │ -62 │ │ │ │ │ -63 /* 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 */ │ │ │ │ │ -64 │ │ │ │ │ -66 typedef T ctype; │ │ │ │ │ -67 │ │ │ │ │ -69 using Grid1Coords = typename Base::Grid1Coords; │ │ │ │ │ -70 │ │ │ │ │ -72 using Grid2Coords = typename Base::Grid2Coords; │ │ │ │ │ -73 │ │ │ │ │ -75 using WorldCoords = typename Base::WorldCoords; │ │ │ │ │ -76 │ │ │ │ │ -77 using IntersectionList = typename Base::IntersectionList; │ │ │ │ │ -78 │ │ │ │ │ -79protected: │ │ │ │ │ -80 │ │ │ │ │ -82 using IntersectionListProvider = │ │ │ │ │ -SimplicialIntersectionListProvider; │ │ │ │ │ -83 using SimplicialIntersection = typename IntersectionListProvider:: │ │ │ │ │ +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; │ │ │ │ │ -84 using RemoteSimplicialIntersection = SimplicialIntersection; │ │ │ │ │ -85 │ │ │ │ │ -86 bool valid = false; │ │ │ │ │ -87 │ │ │ │ │ -88 StandardMerge() │ │ │ │ │ -89 : intersectionListProvider_(std::make_shared()) │ │ │ │ │ -90 , intersectionList_(std::make_shared │ │ │ │ │ -(intersectionListProvider_)) │ │ │ │ │ -91 {} │ │ │ │ │ -92 │ │ │ │ │ -93 virtual ~StandardMerge() = default; │ │ │ │ │ -94 │ │ │ │ │ -99 virtual void computeIntersections(const Dune::GeometryType& │ │ │ │ │ -grid1ElementType, │ │ │ │ │ -100 const std::vector >& grid1ElementCorners, │ │ │ │ │ -101 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -102 unsigned int grid1Index, │ │ │ │ │ -103 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ -104 const std::vector >& grid2ElementCorners, │ │ │ │ │ -105 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -106 unsigned int grid2Index, │ │ │ │ │ -107 std::vector& intersections) = 0; │ │ │ │ │ -108 │ │ │ │ │ -112 bool computeIntersection(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ -113 const std::vector >& grid1Coords, │ │ │ │ │ -114 const std::vector& grid1_element_types, │ │ │ │ │ -115 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -116 const std::vector >& grid2Coords, │ │ │ │ │ -117 const std::vector& grid2_element_types, │ │ │ │ │ -118 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -119 bool insert = true); │ │ │ │ │ -120 │ │ │ │ │ -121 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ -122 │ │ │ │ │ -123 std::shared_ptr intersectionListProvider_; │ │ │ │ │ -124 std::shared_ptr intersectionList_; │ │ │ │ │ -125 │ │ │ │ │ -127 std::vector > grid1ElementCorners_; │ │ │ │ │ -128 std::vector > grid2ElementCorners_; │ │ │ │ │ -129 │ │ │ │ │ -130 std::vector > elementNeighbors1_; │ │ │ │ │ -131 std::vector > elementNeighbors2_; │ │ │ │ │ -132 │ │ │ │ │ -133public: │ │ │ │ │ -134 │ │ │ │ │ -135 /* C O N C E P T I M P L E M E N T I N G I N T E R F A C E */ │ │ │ │ │ -136 │ │ │ │ │ -140 void build(const std::vector >& grid1_Coords, │ │ │ │ │ -141 const std::vector& grid1_elements, │ │ │ │ │ -142 const std::vector& grid1_element_types, │ │ │ │ │ -143 const std::vector >& grid2_coords, │ │ │ │ │ -144 const std::vector& grid2_elements, │ │ │ │ │ -145 const std::vector& grid2_element_types) override; │ │ │ │ │ -146 │ │ │ │ │ -147 │ │ │ │ │ -148 /* P R O B I N G T H E M E R G E D G R I D */ │ │ │ │ │ -149 │ │ │ │ │ -150 void clear() override │ │ │ │ │ -151 { │ │ │ │ │ -152 // Delete old internal data, from a possible previous run │ │ │ │ │ -153 intersectionListProvider_->clear(); │ │ │ │ │ -154 purge(grid1ElementCorners_); │ │ │ │ │ -155 purge(grid2ElementCorners_); │ │ │ │ │ -156 │ │ │ │ │ -157 valid = false; │ │ │ │ │ -158 } │ │ │ │ │ -159 │ │ │ │ │ -160 std::shared_ptr intersectionList() const final │ │ │ │ │ -161 { │ │ │ │ │ -162 assert(valid); │ │ │ │ │ -163 return intersectionList_; │ │ │ │ │ -164 } │ │ │ │ │ -165 │ │ │ │ │ -166 void enableFallback(bool fallback) │ │ │ │ │ -167 { │ │ │ │ │ -168 m_enableFallback = fallback; │ │ │ │ │ -169 } │ │ │ │ │ -170 │ │ │ │ │ -171 void enableBruteForce(bool bruteForce) │ │ │ │ │ -172 { │ │ │ │ │ -173 m_enableBruteForce = bruteForce; │ │ │ │ │ -174 } │ │ │ │ │ -175 │ │ │ │ │ -176private: │ │ │ │ │ -180 bool m_enableFallback = false; │ │ │ │ │ -181 │ │ │ │ │ -185 bool m_enableBruteForce = false; │ │ │ │ │ -186 │ │ │ │ │ -187 auto& intersections() │ │ │ │ │ -188 { return intersectionListProvider_->intersections(); } │ │ │ │ │ -189 │ │ │ │ │ -191 template │ │ │ │ │ -192 static void purge(V & v) │ │ │ │ │ -193 { │ │ │ │ │ -194 v.clear(); │ │ │ │ │ -195 V v2(v); │ │ │ │ │ -196 v.swap(v2); │ │ │ │ │ -197 } │ │ │ │ │ -198 │ │ │ │ │ -203 void generateSeed(std::vector& seeds, │ │ │ │ │ -204 Dune::BitSetVector<1>& isHandled2, │ │ │ │ │ -205 std::stack& candidates2, │ │ │ │ │ -206 const std::vector >& grid1Coords, │ │ │ │ │ -207 const std::vector& grid1_element_types, │ │ │ │ │ -208 const std::vector >& grid2Coords, │ │ │ │ │ -209 const std::vector& grid2_element_types); │ │ │ │ │ -210 │ │ │ │ │ -214 int insertIntersections(unsigned int candidate1, unsigned int │ │ │ │ │ -candidate2,std::vector& intersections); │ │ │ │ │ -215 │ │ │ │ │ -219 int bruteForceSearch(int candidate1, │ │ │ │ │ -220 const std::vector >& grid1Coords, │ │ │ │ │ -221 const std::vector& grid1_element_types, │ │ │ │ │ -222 const std::vector >& grid2Coords, │ │ │ │ │ -223 const std::vector& grid2_element_types); │ │ │ │ │ -224 │ │ │ │ │ -228 std::pair │ │ │ │ │ -229 intersectionIndex(unsigned int grid1Index, unsigned int grid2Index, │ │ │ │ │ -230 SimplicialIntersection& intersection); │ │ │ │ │ -231 │ │ │ │ │ -235 template │ │ │ │ │ -236 void computeNeighborsPerElement(const std::vector& │ │ │ │ │ -gridElementTypes, │ │ │ │ │ -237 const std::vector >& gridElementCorners, │ │ │ │ │ -238 std::vector >& elementNeighbors); │ │ │ │ │ -239 │ │ │ │ │ -240 void buildAdvancingFront( │ │ │ │ │ -241 const std::vector >& grid1_Coords, │ │ │ │ │ -242 const std::vector& grid1_elements, │ │ │ │ │ -243 const std::vector& grid1_element_types, │ │ │ │ │ -244 const std::vector >& grid2_coords, │ │ │ │ │ -245 const std::vector& grid2_elements, │ │ │ │ │ -246 const std::vector& grid2_element_types │ │ │ │ │ -247 ); │ │ │ │ │ -248 │ │ │ │ │ -249 void buildBruteForce( │ │ │ │ │ -250 const std::vector >& grid1_Coords, │ │ │ │ │ -251 const std::vector& grid1_elements, │ │ │ │ │ -252 const std::vector& grid1_element_types, │ │ │ │ │ -253 const std::vector >& grid2_coords, │ │ │ │ │ -254 const std::vector& grid2_elements, │ │ │ │ │ -255 const std::vector& grid2_element_types │ │ │ │ │ -256 ); │ │ │ │ │ -257}; │ │ │ │ │ -258 │ │ │ │ │ -259 │ │ │ │ │ -260/* IMPLEMENTATION */ │ │ │ │ │ -261 │ │ │ │ │ -262template │ │ │ │ │ -263bool StandardMerge::computeIntersection │ │ │ │ │ -(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ -264 const std::vector >& grid1Coords, │ │ │ │ │ -265 const std::vector& grid1_element_types, │ │ │ │ │ -266 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -267 const std::vector >& grid2Coords, │ │ │ │ │ -268 const std::vector& grid2_element_types, │ │ │ │ │ -269 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -270 bool insert) │ │ │ │ │ -271{ │ │ │ │ │ -272 // Select vertices of the grid1 element │ │ │ │ │ -273 int grid1NumVertices = grid1ElementCorners_[candidate0].size(); │ │ │ │ │ -274 std::vector > grid1ElementCorners │ │ │ │ │ -(grid1NumVertices); │ │ │ │ │ -275 for (int i=0; i > grid2ElementCorners │ │ │ │ │ -(grid2NumVertices); │ │ │ │ │ -281 for (int i=0; i intersections(0); │ │ │ │ │ -289 │ │ │ │ │ -290 // compute the intersections │ │ │ │ │ -291 computeIntersections(grid1_element_types[candidate0], grid1ElementCorners, │ │ │ │ │ -292 neighborIntersects1, candidate0, │ │ │ │ │ -293 grid2_element_types[candidate1], grid2ElementCorners, │ │ │ │ │ -294 neighborIntersects2, candidate1, │ │ │ │ │ -295 intersections); │ │ │ │ │ -296 │ │ │ │ │ -297 // insert intersections if needed │ │ │ │ │ -298 if(insert && !intersections.empty()) │ │ │ │ │ -299 insertIntersections(candidate0,candidate1,intersections); │ │ │ │ │ -300 │ │ │ │ │ -301 // Have we found an intersection? │ │ │ │ │ -302 return !intersections.empty() || neighborIntersects1.any() || │ │ │ │ │ -neighborIntersects2.any(); │ │ │ │ │ -303 │ │ │ │ │ -304} │ │ │ │ │ -305 │ │ │ │ │ -306template │ │ │ │ │ -307int StandardMerge::bruteForceSearch(int │ │ │ │ │ -candidate1, │ │ │ │ │ -308 const std::vector >& grid1Coords, │ │ │ │ │ -309 const std::vector& grid1_element_types, │ │ │ │ │ -310 const std::vector >& grid2Coords, │ │ │ │ │ -311 const std::vector& grid2_element_types) │ │ │ │ │ -312{ │ │ │ │ │ -313 std::bitset<(1< neighborIntersects1; │ │ │ │ │ -314 std::bitset<(1< neighborIntersects2; │ │ │ │ │ -315 for (std::size_t i=0; i │ │ │ │ │ -333template │ │ │ │ │ -334void StandardMerge:: │ │ │ │ │ -335computeNeighborsPerElement(const std::vector& │ │ │ │ │ -gridElementTypes, │ │ │ │ │ -336 const std::vector >& gridElementCorners, │ │ │ │ │ -337 std::vector >& elementNeighbors) │ │ │ │ │ -338{ │ │ │ │ │ -339 typedef std::vector FaceType; │ │ │ │ │ -340 typedef std::map > │ │ │ │ │ -FaceSetType; │ │ │ │ │ -341 │ │ │ │ │ -343 // First: grid 1 │ │ │ │ │ -345 FaceSetType faces; │ │ │ │ │ -346 elementNeighbors.resize(gridElementTypes.size()); │ │ │ │ │ -347 │ │ │ │ │ -348 for (size_t i=0; i::general │ │ │ │ │ -(gridElementTypes[i]).size(1), -1); │ │ │ │ │ -350 │ │ │ │ │ -351 for (size_t i=0; i::general │ │ │ │ │ -(gridElementTypes[i]); │ │ │ │ │ -353 │ │ │ │ │ -354 for (size_t j=0; j<(size_t)refElement.size(1); j++) { // iterate over all │ │ │ │ │ -faces of the element │ │ │ │ │ -355 │ │ │ │ │ -356 FaceType face; │ │ │ │ │ -357 // extract element face │ │ │ │ │ -358 for (size_t k=0; k<(size_t)refElement.size(j,1,gridDim); k++) │ │ │ │ │ -359 face.push_back(gridElementCorners[i][refElement.subEntity(j,1,k,gridDim)]); │ │ │ │ │ -360 │ │ │ │ │ -361 // sort the face vertices to get rid of twists and other permutations │ │ │ │ │ -362 std::sort(face.begin(), face.end()); │ │ │ │ │ -363 │ │ │ │ │ -364 typename FaceSetType::iterator faceHandle = faces.find(face); │ │ │ │ │ -365 │ │ │ │ │ -366 if (faceHandle == faces.end()) { │ │ │ │ │ -367 │ │ │ │ │ -368 // face has not been visited before │ │ │ │ │ -369 faces.insert(std::make_pair(face, std::make_pair(i,j))); │ │ │ │ │ -370 │ │ │ │ │ -371 } else { │ │ │ │ │ -372 │ │ │ │ │ -373 // face has been visited before: store the mutual neighbor information │ │ │ │ │ -374 elementNeighbors[i][j] = faceHandle->second.first; │ │ │ │ │ -375 elementNeighbors[faceHandle->second.first][faceHandle->second.second] = i; │ │ │ │ │ -376 │ │ │ │ │ -377 faces.erase(faceHandle); │ │ │ │ │ -378 │ │ │ │ │ -379 } │ │ │ │ │ -380 │ │ │ │ │ -381 } │ │ │ │ │ -382 │ │ │ │ │ -383 } │ │ │ │ │ -384} │ │ │ │ │ -385 │ │ │ │ │ -386// ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -387// Compute the intersection of all pairs of elements │ │ │ │ │ -388// Linear algorithm by Gander and Japhet, Proc. of DD18 │ │ │ │ │ -389// ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -390 │ │ │ │ │ -391template │ │ │ │ │ -392void StandardMerge::build(const std:: │ │ │ │ │ -vector >& grid1Coords, │ │ │ │ │ -393 const std::vector& grid1_elements, │ │ │ │ │ -394 const std::vector& grid1_element_types, │ │ │ │ │ -395 const std::vector >& grid2Coords, │ │ │ │ │ -396 const std::vector& grid2_elements, │ │ │ │ │ -397 const std::vector& grid2_element_types │ │ │ │ │ -398 ) │ │ │ │ │ -399{ │ │ │ │ │ -400 │ │ │ │ │ -401 std::cout << "StandardMerge building merged grid..." << std::endl; │ │ │ │ │ -402 Dune::Timer watch; │ │ │ │ │ -403 │ │ │ │ │ -404 clear(); │ │ │ │ │ -405 // clear global intersection list │ │ │ │ │ -406 intersectionListProvider_->clear(); │ │ │ │ │ -407 this->counter = 0; │ │ │ │ │ -408 │ │ │ │ │ -409 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -410 // Copy element corners into a data structure with block-structure. │ │ │ │ │ -411 // This is not as efficient but a lot easier to use. │ │ │ │ │ -412 // We may think about efficiency later. │ │ │ │ │ -413 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -414 │ │ │ │ │ -415 // first the grid1 side │ │ │ │ │ -416 grid1ElementCorners_.resize(grid1_element_types.size()); │ │ │ │ │ -417 │ │ │ │ │ -418 unsigned int grid1CornerCounter = 0; │ │ │ │ │ -419 │ │ │ │ │ -420 for (std::size_t i=0; i::general(grid1_ │ │ │ │ │ -element_types[i]).size(grid1Dim); │ │ │ │ │ -424 grid1ElementCorners_[i].resize(numVertices); │ │ │ │ │ -425 for (int j=0; j::general(grid2_ │ │ │ │ │ -element_types[i]).size(grid2Dim); │ │ │ │ │ -439 grid2ElementCorners_[i].resize(numVertices); │ │ │ │ │ -440 for (int j=0; j(grid1_element_types, │ │ │ │ │ -grid1ElementCorners_, elementNeighbors1_); │ │ │ │ │ -450 computeNeighborsPerElement(grid2_element_types, │ │ │ │ │ -grid2ElementCorners_, elementNeighbors2_); │ │ │ │ │ -451 │ │ │ │ │ -452 std::cout << "setup took " << watch.elapsed() << " seconds." << std::endl; │ │ │ │ │ -453 │ │ │ │ │ -454 if (m_enableBruteForce) │ │ │ │ │ -455 buildBruteForce(grid1Coords, grid1_elements, grid1_element_types, │ │ │ │ │ -grid2Coords, grid2_elements, grid2_element_types); │ │ │ │ │ -456 else │ │ │ │ │ -457 buildAdvancingFront(grid1Coords, grid1_elements, grid1_element_types, │ │ │ │ │ -grid2Coords, grid2_elements, grid2_element_types); │ │ │ │ │ -458 │ │ │ │ │ -459 valid = true; │ │ │ │ │ -460 std::cout << "intersection construction took " << watch.elapsed() << " │ │ │ │ │ -seconds." << std::endl; │ │ │ │ │ -461} │ │ │ │ │ -462 │ │ │ │ │ -463template │ │ │ │ │ -464void StandardMerge::buildAdvancingFront( │ │ │ │ │ -465 const std::vector >& grid1Coords, │ │ │ │ │ -466 const std::vector& grid1_elements, │ │ │ │ │ -467 const std::vector& grid1_element_types, │ │ │ │ │ -468 const std::vector >& grid2Coords, │ │ │ │ │ -469 const std::vector& grid2_elements, │ │ │ │ │ -470 const std::vector& grid2_element_types │ │ │ │ │ -471 ) │ │ │ │ │ -472{ │ │ │ │ │ -474 // Data structures for the advancing-front algorithm │ │ │ │ │ -476 │ │ │ │ │ -477 std::stack candidates1; │ │ │ │ │ -478 std::stack candidates2; │ │ │ │ │ -479 │ │ │ │ │ -480 std::vector seeds(grid2_element_types.size(), -1); │ │ │ │ │ -481 │ │ │ │ │ -482 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -483 // Do a brute-force search to find one pair of intersecting elements │ │ │ │ │ -484 // to start the advancing-front type algorithm with. │ │ │ │ │ -485 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -486 │ │ │ │ │ -487 // Set flag if element has been handled │ │ │ │ │ -488 Dune::BitSetVector<1> isHandled2(grid2_element_types.size()); │ │ │ │ │ -489 │ │ │ │ │ -490 // Set flag if the element has been entered in the queue │ │ │ │ │ -491 Dune::BitSetVector<1> isCandidate2(grid2_element_types.size()); │ │ │ │ │ -492 │ │ │ │ │ -493 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_ │ │ │ │ │ -types, grid2Coords, grid2_element_types); │ │ │ │ │ -494 │ │ │ │ │ -495 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -496 // Main loop │ │ │ │ │ -497 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ -498 │ │ │ │ │ -499 std::set isHandled1; │ │ │ │ │ -500 │ │ │ │ │ -501 std::set isCandidate1; │ │ │ │ │ -502 │ │ │ │ │ -503 while (!candidates2.empty()) { │ │ │ │ │ -504 │ │ │ │ │ -505 // Get the next element on the grid2 side │ │ │ │ │ -506 unsigned int currentCandidate2 = candidates2.top(); │ │ │ │ │ -507 int seed = seeds[currentCandidate2]; │ │ │ │ │ -508 assert(seed >= 0); │ │ │ │ │ -509 │ │ │ │ │ -510 candidates2.pop(); │ │ │ │ │ -511 isHandled2[currentCandidate2] = true; │ │ │ │ │ -512 │ │ │ │ │ -513 // Start advancing front algorithm on the grid1 side from the 'seed' │ │ │ │ │ -element that │ │ │ │ │ -514 // we stored along with the current grid2 element │ │ │ │ │ -515 candidates1.push(seed); │ │ │ │ │ -516 │ │ │ │ │ -517 isHandled1.clear(); │ │ │ │ │ -518 isCandidate1.clear(); │ │ │ │ │ -519 │ │ │ │ │ -520 while (!candidates1.empty()) { │ │ │ │ │ -521 │ │ │ │ │ -522 unsigned int currentCandidate1 = candidates1.top(); │ │ │ │ │ -523 candidates1.pop(); │ │ │ │ │ -524 isHandled1.insert(currentCandidate1); │ │ │ │ │ -525 │ │ │ │ │ -526 // Test whether there is an intersection between currentCandidate0 and │ │ │ │ │ -currentCandidate1 │ │ │ │ │ -527 std::bitset<(1< neighborIntersects1; │ │ │ │ │ -528 std::bitset<(1< neighborIntersects2; │ │ │ │ │ -529 bool intersectionFound = computeIntersection(currentCandidate1, │ │ │ │ │ -currentCandidate2, │ │ │ │ │ -530 grid1Coords,grid1_element_types, neighborIntersects1, │ │ │ │ │ -531 grid2Coords,grid2_element_types, neighborIntersects2); │ │ │ │ │ -532 │ │ │ │ │ -533 for (size_t i=0; i-1) { │ │ │ │ │ -574 │ │ │ │ │ -575 isCandidate2[neighbor][0] = true; │ │ │ │ │ -576 candidates2.push(neighbor); │ │ │ │ │ -577 seedFound = true; │ │ │ │ │ -578 } │ │ │ │ │ -579 } │ │ │ │ │ -580 │ │ │ │ │ -581 if (seedFound || !m_enableFallback) │ │ │ │ │ -582 continue; │ │ │ │ │ -583 │ │ │ │ │ -584 // There is no neighbor with a seed, so we need to be a bit more │ │ │ │ │ -aggressive... │ │ │ │ │ -585 // get all neighbors of currentCandidate2, but not currentCandidate2 itself │ │ │ │ │ -586 for (size_t i=0; i::iterator seedIt = isHandled1.begin(); │ │ │ │ │ -601 seedIt != isHandled1.end(); ++seedIt) { │ │ │ │ │ -602 │ │ │ │ │ -603 std::bitset<(1< neighborIntersects1; │ │ │ │ │ -604 std::bitset<(1< neighborIntersects2; │ │ │ │ │ -605 bool intersectionFound = computeIntersection(*seedIt, neighbor, │ │ │ │ │ -606 grid1Coords, grid1_element_types, neighborIntersects1, │ │ │ │ │ -607 grid2Coords, grid2_element_types, neighborIntersects2, │ │ │ │ │ -608 false); │ │ │ │ │ -609 │ │ │ │ │ -610 // if the intersection is nonempty, *seedIt is our new seed candidate on │ │ │ │ │ -the grid1 side │ │ │ │ │ -611 if (intersectionFound) { │ │ │ │ │ -612 seed = *seedIt; │ │ │ │ │ -613 Dune::dwarn << "Algorithm entered first fallback method and found a new │ │ │ │ │ -seed in the build algorithm." << │ │ │ │ │ -614 "Probably, the neighborIntersects bitsets computed in computeIntersection │ │ │ │ │ -specialization is wrong." << std::endl; │ │ │ │ │ -615 break; │ │ │ │ │ -616 } │ │ │ │ │ -617 │ │ │ │ │ -618 } │ │ │ │ │ -619 │ │ │ │ │ -620 if (seed < 0) { │ │ │ │ │ -621 // The fast method didn't find a grid1 element that intersects with │ │ │ │ │ -622 // the new grid2 candidate. We have to do a brute-force search. │ │ │ │ │ -623 seed = bruteForceSearch(neighbor, │ │ │ │ │ -624 grid1Coords,grid1_element_types, │ │ │ │ │ -625 grid2Coords,grid2_element_types); │ │ │ │ │ -626 Dune::dwarn << "Algorithm entered second fallback method. This probably │ │ │ │ │ -should not happen." << std::endl; │ │ │ │ │ -627 │ │ │ │ │ -628 } │ │ │ │ │ -629 │ │ │ │ │ -630 // We have tried all we could: the candidate is 'handled' now │ │ │ │ │ -631 isCandidate2[neighbor] = true; │ │ │ │ │ -632 │ │ │ │ │ -633 // still no seed? Then the new grid2 candidate isn't overlapped by anything │ │ │ │ │ -634 if (seed < 0) │ │ │ │ │ -635 continue; │ │ │ │ │ -636 │ │ │ │ │ -637 // we have a seed now │ │ │ │ │ -638 candidates2.push(neighbor); │ │ │ │ │ -639 seeds[neighbor] = seed; │ │ │ │ │ -640 seedFound = true; │ │ │ │ │ -641 │ │ │ │ │ -642 } │ │ │ │ │ -643 │ │ │ │ │ -644 } │ │ │ │ │ -645 │ │ │ │ │ -646 /* Do a brute-force search if there is still no seed: │ │ │ │ │ -647 * There might still be a disconnected region out there. │ │ │ │ │ -648 */ │ │ │ │ │ -649 if (!seedFound && candidates2.empty()) { │ │ │ │ │ -650 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_ │ │ │ │ │ -types, grid2Coords, grid2_element_types); │ │ │ │ │ -651 } │ │ │ │ │ -652 } │ │ │ │ │ -653} │ │ │ │ │ -654 │ │ │ │ │ -655template │ │ │ │ │ -656void StandardMerge::buildBruteForce( │ │ │ │ │ -657 const std::vector >& grid1Coords, │ │ │ │ │ -658 const std::vector& grid1_elements, │ │ │ │ │ -659 const std::vector& grid1_element_types, │ │ │ │ │ -660 const std::vector >& grid2Coords, │ │ │ │ │ -661 const std::vector& grid2_elements, │ │ │ │ │ -662 const std::vector& grid2_element_types │ │ │ │ │ -663 ) │ │ │ │ │ -664{ │ │ │ │ │ -665 std::bitset<(1< neighborIntersects1; │ │ │ │ │ -666 std::bitset<(1< neighborIntersects2; │ │ │ │ │ -667 │ │ │ │ │ -668 for (unsigned i = 0; i < grid1_element_types.size(); ++i) { │ │ │ │ │ -669 for (unsigned j = 0; j < grid2_element_types.size(); ++j) { │ │ │ │ │ -670 (void) computeIntersection(i, j, │ │ │ │ │ -671 grid1Coords, grid1_element_types, neighborIntersects1, │ │ │ │ │ -672 grid2Coords, grid2_element_types, neighborIntersects2); │ │ │ │ │ -673 } │ │ │ │ │ -674 } │ │ │ │ │ -675} │ │ │ │ │ -676 │ │ │ │ │ -677template │ │ │ │ │ -678void StandardMerge::generateSeed(std:: │ │ │ │ │ -vector& seeds, Dune::BitSetVector<1>& isHandled2, std::stack& │ │ │ │ │ -candidates2, const std::vector >& grid1Coords, │ │ │ │ │ -const std::vector& grid1_element_types, const std:: │ │ │ │ │ -vector >& grid2Coords, const std::vector& grid2_element_types) │ │ │ │ │ -679{ │ │ │ │ │ -680 for (std::size_t j=0; j 0 || isHandled2[j][0]) │ │ │ │ │ -683 continue; │ │ │ │ │ -684 │ │ │ │ │ -685 int seed = bruteForceSearch(j,grid1Coords,grid1_element_ │ │ │ │ │ -types,grid2Coords,grid2_element_types); │ │ │ │ │ -686 │ │ │ │ │ -687 if (seed >= 0) { │ │ │ │ │ -688 candidates2.push(j); // the candidate and a seed for the candidate │ │ │ │ │ -689 seeds[j] = seed; │ │ │ │ │ -690 break; │ │ │ │ │ -691 } else // If the brute force search did not find any intersection we can │ │ │ │ │ -skip this element │ │ │ │ │ -692 isHandled2[j] = true; │ │ │ │ │ -693 } │ │ │ │ │ -694} │ │ │ │ │ -695 │ │ │ │ │ -696template │ │ │ │ │ -697int StandardMerge::insertIntersections │ │ │ │ │ -(unsigned int candidate1, unsigned int candidate2, │ │ │ │ │ -698 std::vector& intersections) │ │ │ │ │ -699{ │ │ │ │ │ -700 typedef typename std::vector::size_type size_t; │ │ │ │ │ -701 int count = 0; │ │ │ │ │ -702 │ │ │ │ │ -703 for (size_t i = 0; i < intersections.size(); ++i) { │ │ │ │ │ -704 // get the intersection index of the current intersection from │ │ │ │ │ -intersections in this->intersections │ │ │ │ │ -705 bool found; │ │ │ │ │ -706 unsigned int index; │ │ │ │ │ -707 std::tie(found, index) = intersectionIndex │ │ │ │ │ -(candidate1,candidate2,intersections[i]); │ │ │ │ │ -708 │ │ │ │ │ -709 if (found && index >= this->intersections().size()) { //the intersection is │ │ │ │ │ -not yet contained in this->intersections │ │ │ │ │ -710 this->intersections().push_back(intersections[i]); // insert │ │ │ │ │ -711 │ │ │ │ │ -712 ++count; │ │ │ │ │ -713 } else if (found) { │ │ │ │ │ -714 auto& intersection = this->intersections()[index]; │ │ │ │ │ -715 │ │ │ │ │ -716 // insert each grid1 element and local representation of intersections[i] │ │ │ │ │ -with parent candidate1 │ │ │ │ │ -717 for (size_t j = 0; j < intersections[i].parents0.size(); ++j) { │ │ │ │ │ -718 intersection.parents0.push_back(candidate1); │ │ │ │ │ -719 intersection.corners0.push_back(intersections[i].corners0[j]); │ │ │ │ │ -720 } │ │ │ │ │ -721 │ │ │ │ │ -722 // insert each grid2 element and local representation of intersections[i] │ │ │ │ │ -with parent candidate2 │ │ │ │ │ -723 for (size_t j = 0; j < intersections[i].parents1.size(); ++j) { │ │ │ │ │ -724 intersection.parents1.push_back(candidate2); │ │ │ │ │ -725 intersection.corners1.push_back(intersections[i].corners1[j]); │ │ │ │ │ -726 } │ │ │ │ │ -727 │ │ │ │ │ -728 ++count; │ │ │ │ │ -729 } else { │ │ │ │ │ -730 Dune::dwarn << "Computed the same intersection twice!" << std::endl; │ │ │ │ │ -731 } │ │ │ │ │ -732 } │ │ │ │ │ -733 return count; │ │ │ │ │ -734} │ │ │ │ │ -735 │ │ │ │ │ -736template │ │ │ │ │ -737std::pair │ │ │ │ │ -738StandardMerge::intersectionIndex(unsigned int │ │ │ │ │ -grid1Index, unsigned int grid2Index, │ │ │ │ │ -739 SimplicialIntersection& intersection) { │ │ │ │ │ -740 │ │ │ │ │ -741 │ │ │ │ │ -742 // return index in intersections_ if at least one local representation of a │ │ │ │ │ -Simplicial Intersection (SI) │ │ │ │ │ -743 // of intersections_ is equal to the local representation of one element in │ │ │ │ │ -intersections │ │ │ │ │ -744 │ │ │ │ │ -745 std::size_t n_intersections = this->intersections().size(); │ │ │ │ │ -746 if (grid1Dim == grid2Dim) │ │ │ │ │ -747 return {true, n_intersections}; │ │ │ │ │ -748 │ │ │ │ │ -749 T eps = 1e-10; │ │ │ │ │ -750 │ │ │ │ │ -751 for (std::size_t i = 0; i < n_intersections; ++i) { │ │ │ │ │ -752 │ │ │ │ │ -753 // compare the local representation of the subelements of the SI │ │ │ │ │ -754 for (std::size_t ei = 0; ei < this->intersections()[i].parents0.size(); │ │ │ │ │ -++ei) // merger subelement │ │ │ │ │ -755 { │ │ │ │ │ -756 if (this->intersections()[i].parents0[ei] == grid1Index) │ │ │ │ │ -757 { │ │ │ │ │ -758 for (std::size_t er = 0; er < intersection.parents0.size(); ++er) // list │ │ │ │ │ -subelement │ │ │ │ │ -759 { │ │ │ │ │ -760 bool found_all = true; │ │ │ │ │ -761 // compare the local coordinate representations │ │ │ │ │ -762 for (std::size_t ci = 0; ci < this->intersections()[i].corners0[ei].size(); │ │ │ │ │ -++ci) │ │ │ │ │ -763 { │ │ │ │ │ -764 Dune::FieldVector ni = this->intersections()[i].corners0[ei] │ │ │ │ │ -[ci]; │ │ │ │ │ -765 bool found_ni = false; │ │ │ │ │ -766 for (std::size_t cr = 0; cr < intersection.corners0[er].size(); ++cr) │ │ │ │ │ -767 { │ │ │ │ │ -768 Dune::FieldVector nr = intersection.corners0[er][cr]; │ │ │ │ │ -769 │ │ │ │ │ -770 found_ni = found_ni || ((ni-nr).infinity_norm() < eps); │ │ │ │ │ -771 if (found_ni) │ │ │ │ │ -772 break; │ │ │ │ │ -773 } │ │ │ │ │ -774 found_all = found_all && found_ni; │ │ │ │ │ -775 │ │ │ │ │ -776 if (!found_ni) │ │ │ │ │ -777 break; │ │ │ │ │ -778 } │ │ │ │ │ -779 │ │ │ │ │ -780 if (found_all && (this->intersections()[i].parents1[ei] != grid2Index)) │ │ │ │ │ -781 return {true, i}; │ │ │ │ │ -782 else if (found_all) │ │ │ │ │ -783 return {false, 0}; │ │ │ │ │ -784 } │ │ │ │ │ -785 } │ │ │ │ │ -786 } │ │ │ │ │ -787 │ │ │ │ │ -788 // compare the local representation of the subelements of the SI │ │ │ │ │ -789 for (std::size_t ei = 0; ei < this->intersections()[i].parents1.size(); │ │ │ │ │ -++ei) // merger subelement │ │ │ │ │ -790 { │ │ │ │ │ -791 if (this->intersections()[i].parents1[ei] == grid2Index) │ │ │ │ │ -792 { │ │ │ │ │ -793 for (std::size_t er = 0; er < intersection.parents1.size(); ++er) // list │ │ │ │ │ -subelement │ │ │ │ │ -794 { │ │ │ │ │ -795 bool found_all = true; │ │ │ │ │ -796 // compare the local coordinate representations │ │ │ │ │ -797 for (std::size_t ci = 0; ci < this->intersections()[i].corners1[ei].size(); │ │ │ │ │ -++ci) │ │ │ │ │ -798 { │ │ │ │ │ -799 Dune::FieldVector ni = this->intersections()[i].corners1[ei] │ │ │ │ │ -[ci]; │ │ │ │ │ -800 bool found_ni = false; │ │ │ │ │ -801 for (std::size_t cr = 0; cr < intersection.corners1[er].size(); ++cr) │ │ │ │ │ -802 { │ │ │ │ │ -803 Dune::FieldVector nr = intersection.corners1[er][cr]; │ │ │ │ │ -804 found_ni = found_ni || ((ni-nr).infinity_norm() < eps); │ │ │ │ │ -805 │ │ │ │ │ -806 if (found_ni) │ │ │ │ │ -807 break; │ │ │ │ │ -808 } │ │ │ │ │ -809 found_all = found_all && found_ni; │ │ │ │ │ -810 │ │ │ │ │ -811 if (!found_ni) │ │ │ │ │ -812 break; │ │ │ │ │ -813 } │ │ │ │ │ -814 │ │ │ │ │ -815 if (found_all && (this->intersections()[i].parents0[ei] != grid1Index)) │ │ │ │ │ -816 return {true, i}; │ │ │ │ │ -817 else if (found_all) │ │ │ │ │ -818 return {false, 0}; │ │ │ │ │ -819 } │ │ │ │ │ -820 } │ │ │ │ │ -821 } │ │ │ │ │ -822 } │ │ │ │ │ -823 │ │ │ │ │ -824 return {true, n_intersections}; │ │ │ │ │ -825} │ │ │ │ │ -826 │ │ │ │ │ -827#define DECL extern │ │ │ │ │ -828#define STANDARD_MERGE_INSTANTIATE(T,A,B,C) \ │ │ │ │ │ -829 DECL template \ │ │ │ │ │ -830 void StandardMerge::build(const std::vector │ │ │ │ │ ->& grid1Coords, \ │ │ │ │ │ -831 const std::vector& grid1_elements, \ │ │ │ │ │ -832 const std::vector& grid1_element_types, \ │ │ │ │ │ -833 const std::vector >& grid2Coords, \ │ │ │ │ │ -834 const std::vector& grid2_elements, \ │ │ │ │ │ -835 const std::vector& grid2_element_types \ │ │ │ │ │ -836 ) │ │ │ │ │ -837 │ │ │ │ │ -838STANDARD_MERGE_INSTANTIATE(double,1,1,1); │ │ │ │ │ -839STANDARD_MERGE_INSTANTIATE(double,2,2,2); │ │ │ │ │ -840STANDARD_MERGE_INSTANTIATE(double,3,3,3); │ │ │ │ │ -841#undef STANDARD_MERGE_INSTANTIATE │ │ │ │ │ -842#undef DECL │ │ │ │ │ -843 │ │ │ │ │ -844} /* namespace GridGlue */ │ │ │ │ │ -845} /* namespace Dune */ │ │ │ │ │ -846 │ │ │ │ │ -847#endif // DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH │ │ │ │ │ -merger.hh │ │ │ │ │ -intersectionlist.hh │ │ │ │ │ -STANDARD_MERGE_INSTANTIATE │ │ │ │ │ -#define STANDARD_MERGE_INSTANTIATE(T, A, B, C) │ │ │ │ │ -Definition standardmerge.cc:13 │ │ │ │ │ +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 │ │ │ │ │ +overlappingmerge.cc │ │ │ │ │ computeintersection.hh │ │ │ │ │ +standardmerge.hh │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. │ │ │ │ │ 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::SimplicialIntersectionListProvider │ │ │ │ │ -Definition intersectionlist.hh:207 │ │ │ │ │ -Dune::GridGlue::SimplicialIntersectionListProvider::SimplicialIntersection │ │ │ │ │ -Definition intersectionlist.hh:222 │ │ │ │ │ -Dune::GridGlue::Merger │ │ │ │ │ -Abstract base for all classes that take extracted grids and build sets of │ │ │ │ │ -intersections. │ │ │ │ │ -Definition merger.hh:27 │ │ │ │ │ -Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::WorldCoords │ │ │ │ │ +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 merger.hh:37 │ │ │ │ │ -Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::IntersectionList │ │ │ │ │ -Dune::GridGlue::IntersectionList< Grid1Coords, Grid2Coords > IntersectionList │ │ │ │ │ -Definition merger.hh:39 │ │ │ │ │ -Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::Grid1Coords │ │ │ │ │ -Dune::FieldVector< T, grid1Dim > Grid1Coords │ │ │ │ │ -the local coordinate type for the grid1 coordinates │ │ │ │ │ -Definition merger.hh:31 │ │ │ │ │ -Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::Grid2Coords │ │ │ │ │ -Dune::FieldVector< T, grid2Dim > Grid2Coords │ │ │ │ │ -the local coordinate type for the grid2 coordinates │ │ │ │ │ -Definition merger.hh:34 │ │ │ │ │ +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::computeIntersections │ │ │ │ │ -virtual void computeIntersections(const Dune::GeometryType &grid1ElementType, │ │ │ │ │ -const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, │ │ │ │ │ -std::bitset<(1<< grid1Dim)> &neighborIntersects1, unsigned int grid1Index, │ │ │ │ │ -const Dune::GeometryType &grid2ElementType, const std::vector< Dune:: │ │ │ │ │ -FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< grid2Dim)> │ │ │ │ │ -&neighborIntersects2, unsigned int grid2Index, std::vector< │ │ │ │ │ -SimplicialIntersection > &intersections)=0 │ │ │ │ │ -Compute the intersection between two overlapping elements. │ │ │ │ │ -Dune::GridGlue::StandardMerge::intersectionList_ │ │ │ │ │ -std::shared_ptr< IntersectionList > intersectionList_ │ │ │ │ │ -Definition standardmerge.hh:124 │ │ │ │ │ -Dune::GridGlue::StandardMerge::Grid1Coords │ │ │ │ │ -typename Base::Grid1Coords Grid1Coords │ │ │ │ │ -Type used for local coordinates on the grid1 side. │ │ │ │ │ -Definition standardmerge.hh:69 │ │ │ │ │ -Dune::GridGlue::StandardMerge::enableFallback │ │ │ │ │ -void enableFallback(bool fallback) │ │ │ │ │ -Definition standardmerge.hh:166 │ │ │ │ │ -Dune::GridGlue::StandardMerge::elementNeighbors2_ │ │ │ │ │ -std::vector< std::vector< int > > elementNeighbors2_ │ │ │ │ │ -Definition standardmerge.hh:131 │ │ │ │ │ -Dune::GridGlue::StandardMerge::elementNeighbors1_ │ │ │ │ │ -std::vector< std::vector< int > > elementNeighbors1_ │ │ │ │ │ -Definition standardmerge.hh:130 │ │ │ │ │ -Dune::GridGlue::StandardMerge::ctype │ │ │ │ │ -T ctype │ │ │ │ │ -the numeric type used in this interface │ │ │ │ │ -Definition standardmerge.hh:66 │ │ │ │ │ -Dune::GridGlue::StandardMerge::clear │ │ │ │ │ -void clear() override │ │ │ │ │ -Definition standardmerge.hh:150 │ │ │ │ │ -Dune::GridGlue::StandardMerge::IntersectionList │ │ │ │ │ -typename Base::IntersectionList IntersectionList │ │ │ │ │ -Definition standardmerge.hh:77 │ │ │ │ │ -Dune::GridGlue::StandardMerge::computeIntersection │ │ │ │ │ -bool computeIntersection(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ -const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std:: │ │ │ │ │ -vector< Dune::GeometryType > &grid1_element_types, std::bitset<(1<< grid1Dim)> │ │ │ │ │ -&neighborIntersects1, const std::vector< Dune::FieldVector< T, dimworld > > │ │ │ │ │ -&grid2Coords, const std::vector< Dune::GeometryType > &grid2_element_types, │ │ │ │ │ -std::bitset<(1<< grid2Dim)> &neighborIntersects2, bool insert=true) │ │ │ │ │ -Compute the intersection between two overlapping elements. │ │ │ │ │ -Definition standardmerge.hh:263 │ │ │ │ │ -Dune::GridGlue::StandardMerge::enableBruteForce │ │ │ │ │ -void enableBruteForce(bool bruteForce) │ │ │ │ │ -Definition standardmerge.hh:171 │ │ │ │ │ -Dune::GridGlue::StandardMerge::intersectionListProvider_ │ │ │ │ │ -std::shared_ptr< IntersectionListProvider > intersectionListProvider_ │ │ │ │ │ -Definition standardmerge.hh:123 │ │ │ │ │ -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 standardmerge.hh:392 │ │ │ │ │ -Dune::GridGlue::StandardMerge::grid1ElementCorners_ │ │ │ │ │ -std::vector< std::vector< unsigned int > > grid1ElementCorners_ │ │ │ │ │ -Temporary internal data. │ │ │ │ │ -Definition standardmerge.hh:127 │ │ │ │ │ -Dune::GridGlue::StandardMerge::grid2ElementCorners_ │ │ │ │ │ -std::vector< std::vector< unsigned int > > grid2ElementCorners_ │ │ │ │ │ -Definition standardmerge.hh:128 │ │ │ │ │ -Dune::GridGlue::StandardMerge::Grid2Coords │ │ │ │ │ -typename Base::Grid2Coords Grid2Coords │ │ │ │ │ -Type used for local coordinates on the grid2 side. │ │ │ │ │ -Definition standardmerge.hh:72 │ │ │ │ │ -Dune::GridGlue::StandardMerge::intersectionList │ │ │ │ │ -std::shared_ptr< IntersectionList > intersectionList() const final │ │ │ │ │ -Definition standardmerge.hh:160 │ │ │ │ │ -Dune::GridGlue::StandardMerge::~StandardMerge │ │ │ │ │ -virtual ~StandardMerge()=default │ │ │ │ │ -Dune::GridGlue::StandardMerge::RemoteSimplicialIntersection │ │ │ │ │ -SimplicialIntersection RemoteSimplicialIntersection │ │ │ │ │ -Definition standardmerge.hh:84 │ │ │ │ │ -Dune::GridGlue::StandardMerge::valid │ │ │ │ │ -bool valid │ │ │ │ │ -Definition standardmerge.hh:86 │ │ │ │ │ -Dune::GridGlue::StandardMerge::StandardMerge │ │ │ │ │ -StandardMerge() │ │ │ │ │ -Definition standardmerge.hh:88 │ │ │ │ │ Dune::GridGlue::StandardMerge::SimplicialIntersection │ │ │ │ │ typename IntersectionListProvider::SimplicialIntersection │ │ │ │ │ SimplicialIntersection │ │ │ │ │ Definition standardmerge.hh:83 │ │ │ │ │ -Dune::GridGlue::StandardMerge::WorldCoords │ │ │ │ │ -typename Base::WorldCoords WorldCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition standardmerge.hh:75 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.cc File Reference │ │ │ │ +dune-grid-glue: simplexintersection.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,29 +70,69 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces
│ │ │ │ -
contactmerge.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
simplexintersection.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ -#include <dune/grid-glue/common/projection.hh>
│ │ │ │ -
│ │ │ │ + │ │ │ │

Go to the source code of this file.

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

│ │ │ │ +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 {} │ │ │ │ │ @@ -1,19 +1,65 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces │ │ │ │ │ -contactmerge.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +simplexintersection.cc File Reference │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00071_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.cc Source File │ │ │ │ +dune-grid-glue: simplexintersection.cc Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,389 +74,1430 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
contactmerge.cc
│ │ │ │ +
simplexintersection.cc
│ │ │ │
│ │ │ │
│ │ │ │ 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
│ │ │ │ - │ │ │ │ - │ │ │ │ +
6namespace Dune {
│ │ │ │ +
7namespace GridGlue {
│ │ │ │
8
│ │ │ │ -
9namespace Dune {
│ │ │ │ -
10namespace GridGlue {
│ │ │ │ -
11
│ │ │ │ -
12template<int dimworld, typename T>
│ │ │ │ -
13void ContactMerge<dimworld, T>::computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
14 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
15 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ -
16 unsigned int grid1Index,
│ │ │ │ -
17 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
18 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
19 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ -
20 unsigned int grid2Index,
│ │ │ │ -
21 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ -
22{
│ │ │ │ -
23 using std::get;
│ │ │ │ -
24
│ │ │ │ -
25 std::vector<std::array<LocalCoords,2> > polytopeCorners;
│ │ │ │ +
9template <int dimworld, typename T>
│ │ │ │ +
10inline void simplexSubdivision(std::integral_constant<int,0>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
11 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
12 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
13template <int dimworld, typename T>
│ │ │ │ +
14inline void simplexSubdivision(std::integral_constant<int,1>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
15 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
16 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
17template <int dimworld, typename T>
│ │ │ │ +
18inline void simplexSubdivision(std::integral_constant<int,2>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
19 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
20 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
21template <int dimworld, typename T>
│ │ │ │ +
22inline void simplexSubdivision(std::integral_constant<int,3>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
23 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
24 std::vector<std::vector<int> >& faceIds);
│ │ │ │ +
25
│ │ │ │
26
│ │ │ │ -
27 // Initialize
│ │ │ │ -
28 neighborIntersects1.reset();
│ │ │ │ -
29 neighborIntersects2.reset();
│ │ │ │ -
30
│ │ │ │ -
31 const int nCorners1 = grid1ElementCorners.size();
│ │ │ │ -
32 const int nCorners2 = grid2ElementCorners.size();
│ │ │ │ -
33
│ │ │ │ -
34 if (nCorners1 != dimworld)
│ │ │ │ -
35 DUNE_THROW(Dune::Exception, "element1 must have " << dimworld << " corners, but has " << nCorners1);
│ │ │ │ -
36 if (nCorners2 != dimworld)
│ │ │ │ -
37 DUNE_THROW(Dune::Exception, "element2 must have " << dimworld << " corners, but has " << nCorners2);
│ │ │ │ +
27
│ │ │ │ +
28// *****************SIMPLEX INTERSECTION COMPUTATION METHODS ***************************
│ │ │ │ +
29template<int dimWorld,int dim1, int dim2, typename T>
│ │ │ │ +
│ │ │ │ +
30class SimplexMethod : public ComputationMethod<dimWorld,dim1,dim2,T>{
│ │ │ │ +
31 static_assert(dim1 > dim2, "Specialization missing");
│ │ │ │ +
32 friend class ComputationMethod<dimWorld,dim1,dim2,T>;
│ │ │ │ +
33public:
│ │ │ │ +
34 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
35 static const int grid1Dimension = dim1;
│ │ │ │ +
36 static const int grid2Dimension = dim2;
│ │ │ │ +
37 static const int intersectionDimension = dim2;
│ │ │ │
38
│ │ │ │ -
39 // The grid1 projection directions
│ │ │ │ -
40 std::vector<WorldCoords> directions1(nCorners1);
│ │ │ │ -
41 for (size_t i=0; i<directions1.size(); i++)
│ │ │ │ -
42 directions1[i] = nodalDomainDirections_[this->grid1ElementCorners_[grid1Index][i]];
│ │ │ │ -
43
│ │ │ │ -
44 // The grid2 projection directions
│ │ │ │ -
45 std::vector<WorldCoords> directions2(nCorners2);
│ │ │ │ -
46 for (size_t i=0; i<directions2.size(); i++)
│ │ │ │ -
47 directions2[i] = nodalTargetDirections_[this->grid2ElementCorners_[grid2Index][i]];
│ │ │ │ -
48
│ │ │ │ -
49 // The difference between the closest point projection and the normal projection is just the ordering
│ │ │ │ -
50 // of the involved surfaces. The closest point projection is done along the outer normal field of grid2
│ │ │ │ -
51 // (due to being a best approximation) and the outer normal projection is using the outer normal field
│ │ │ │ -
52 // of grid1 instead.
│ │ │ │ -
53 std::array<decltype(std::cref(grid1ElementCorners)),2> cornersRef ={std::cref(grid1ElementCorners), std::cref(grid2ElementCorners)};
│ │ │ │ -
54 std::array<decltype(std::cref(directions1)),2> directionsRef ={std::cref(directions1), std::cref(directions2)};
│ │ │ │ -
55 std::array<Dune::GeometryType,2> elementTypes = {grid1ElementType, grid2ElementType};
│ │ │ │ -
56
│ │ │ │ -
57 // Determine which is the grid we use for outer normal projection
│ │ │ │ -
58 const size_t domGrid = (type_==ProjectionType::OUTER_NORMAL) ? 0 : 1;
│ │ │ │ -
59 const size_t tarGrid = (type_==ProjectionType::OUTER_NORMAL) ? 1 : 0;
│ │ │ │ -
60
│ │ │ │ -
62 // Compute all corners of the intersection polytope
│ │ │ │ +
│ │ │ │ +
39 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
40 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
41 std::vector<std::vector<int> > & SX,
│ │ │ │ +
42 std::vector<std::vector<int> > & SY,
│ │ │ │ +
43 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
44 {
│ │ │ │ + │ │ │ │ +
46 }
│ │ │ │ +
│ │ │ │ +
47
│ │ │ │ +
│ │ │ │ +
48 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
49 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
50 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
51 {
│ │ │ │ +
52 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
53 elementCorners,subElements, faceIds);
│ │ │ │ +
54 }
│ │ │ │ +
│ │ │ │ +
55
│ │ │ │ +
56 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
57 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
58 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
59 {
│ │ │ │ +
60 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
61 elementCorners, subElements, faceIds);
│ │ │ │ +
62 }
│ │ │ │ +
63};
│ │ │ │ +
│ │ │ │
64
│ │ │ │ -
65 const auto corners = std::tie(cornersRef[domGrid].get(),cornersRef[tarGrid].get());
│ │ │ │ -
66 const auto normals = std::tie(directionsRef[domGrid].get(), directionsRef[tarGrid].get());
│ │ │ │ -
67 Projection<WorldCoords> p(overlap_, maxNormalProduct_);
│ │ │ │ -
68 p.project(corners, normals);
│ │ │ │ -
69
│ │ │ │ -
70 /* projection */
│ │ │ │ -
71 {
│ │ │ │ -
72 const auto& success = get<0>(p.success());
│ │ │ │ -
73 const auto& images = get<0>(p.images());
│ │ │ │ -
74 for (unsigned i = 0; i < dimworld; ++i) {
│ │ │ │ -
75 if (success[i]) {
│ │ │ │ -
76 std::array<LocalCoords, 2> corner;
│ │ │ │ -
77 corner[domGrid] = localCornerCoords(i, elementTypes[domGrid]);
│ │ │ │ -
78 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ -
79 corner[tarGrid][j] = images[i][j];
│ │ │ │ -
80 polytopeCorners.push_back(corner);
│ │ │ │ -
81 }
│ │ │ │ -
82 }
│ │ │ │ -
83 }
│ │ │ │ -
84
│ │ │ │ -
85 /* inverse projection */
│ │ │ │ -
86 {
│ │ │ │ -
87 const auto& success = get<1>(p.success());
│ │ │ │ -
88 const auto& preimages = get<1>(p.images());
│ │ │ │ -
89 for (unsigned i = 0; i < dimworld; ++i) {
│ │ │ │ -
90 if (success[i]) {
│ │ │ │ -
91 std::array<LocalCoords, 2> corner;
│ │ │ │ -
92 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ -
93 corner[domGrid][j] = preimages[i][j];
│ │ │ │ -
94 corner[tarGrid] = localCornerCoords(i, elementTypes[tarGrid]);
│ │ │ │ -
95 polytopeCorners.push_back(corner);
│ │ │ │ -
96 }
│ │ │ │ -
97 }
│ │ │ │ -
98 }
│ │ │ │ -
99
│ │ │ │ -
100 /* edge intersections */
│ │ │ │ -
101 {
│ │ │ │ -
102 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) {
│ │ │ │ -
103 std::array<LocalCoords, 2> corner;
│ │ │ │ -
104 const auto& local = p.edgeIntersections()[i].local;
│ │ │ │ -
105 for (unsigned j = 0; j < dim; ++j) {
│ │ │ │ -
106 corner[domGrid][j] = local[0][j];
│ │ │ │ -
107 corner[tarGrid][j] = local[1][j];
│ │ │ │ -
108 }
│ │ │ │ -
109 polytopeCorners.push_back(corner);
│ │ │ │ -
110 }
│ │ │ │ -
111 }
│ │ │ │ -
112
│ │ │ │ -
113 // check which neighbors might also intersect
│ │ │ │ -
114 std::array<decltype(std::ref(neighborIntersects1)),2> neighborIntersectsRef = {std::ref(neighborIntersects1), std::ref(neighborIntersects2)};
│ │ │ │ -
115 const auto& refTar = Dune::ReferenceElements<T,dim>::general(elementTypes[tarGrid]);
│ │ │ │ -
116 for (int i=0; i<refTar.size(1); i++) {
│ │ │ │ -
117
│ │ │ │ -
118 // if all face corners hit the other element then
│ │ │ │ -
119 // the neighbor might also intersect
│ │ │ │ -
120
│ │ │ │ -
121 bool intersects(true);
│ │ │ │ -
122 for (int k=0; k<refTar.size(i,1,dim); k++)
│ │ │ │ -
123 intersects &= get<1>(p.success())[refTar.subEntity(i,1,k,dim)];
│ │ │ │ -
124
│ │ │ │ -
125 if (intersects)
│ │ │ │ -
126 neighborIntersectsRef[tarGrid].get()[i] = true;
│ │ │ │ -
127 }
│ │ │ │ -
128
│ │ │ │ -
129 const auto& refDom = Dune::ReferenceElements<T,dim>::general(elementTypes[domGrid]);
│ │ │ │ -
130 for (int i=0; i<refDom.size(1); i++) {
│ │ │ │ -
131
│ │ │ │ -
132 // if all face corners hit the other element then
│ │ │ │ -
133 // the neighbor might also intersect
│ │ │ │ -
134
│ │ │ │ -
135 bool intersects(true);
│ │ │ │ -
136 for (int k=0; k<refDom.size(i,1,dim); k++)
│ │ │ │ -
137 intersects &= get<0>(p.success())[refDom.subEntity(i,1,k,dim)];
│ │ │ │ -
138
│ │ │ │ -
139 if (intersects)
│ │ │ │ -
140 neighborIntersectsRef[domGrid].get()[i] = true;
│ │ │ │ -
141 }
│ │ │ │ -
142
│ │ │ │ -
143 // Compute the edge intersections
│ │ │ │ -
144 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) {
│ │ │ │ -
145 const auto& edge = p.edgeIntersections()[i].edge;
│ │ │ │ -
146 neighborIntersects1[edge[domGrid]] = true;
│ │ │ │ -
147 neighborIntersects2[edge[tarGrid]] = true;
│ │ │ │ -
148 }
│ │ │ │ -
149
│ │ │ │ -
150 // remove possible doubles
│ │ │ │ -
151 removeDoubles(polytopeCorners);
│ │ │ │ -
152
│ │ │ │ -
153 // Compute an interior point of the polytope
│ │ │ │ -
154 int nPolyCorners = polytopeCorners.size();
│ │ │ │ -
155
│ │ │ │ -
156 // If the polytope is degenerated then there is no intersection
│ │ │ │ -
157 if (nPolyCorners<dimworld)
│ │ │ │ -
158 return;
│ │ │ │ -
159
│ │ │ │ -
160 // If the polytope is a simplex return it
│ │ │ │ -
161 if (nPolyCorners==dim+1) {
│ │ │ │ -
162
│ │ │ │ -
163 // std::cout<<"Add intersection: 1\n";
│ │ │ │ -
164 typename Base::SimplicialIntersection intersect(grid1Index, grid2Index);
│ │ │ │ -
165
│ │ │ │ -
166 for (int j=0;j<dim+1; j++) {
│ │ │ │ -
167 intersect.corners0[0][j]=polytopeCorners[j][0];
│ │ │ │ -
168 intersect.corners1[0][j]=polytopeCorners[j][1];
│ │ │ │ -
169 }
│ │ │ │ -
170 intersections.push_back(intersect);
│ │ │ │ -
171
│ │ │ │ -
172 return;
│ │ │ │ -
173 }
│ │ │ │ -
174
│ │ │ │ -
175 // At this point we must have dimworld>=3
│ │ │ │ -
176
│ │ │ │ -
178 // Compute a point in the middle of the polytope and order all corners cyclic
│ │ │ │ +
65
│ │ │ │ +
66
│ │ │ │ +
67// POINTS ARE EQUAL
│ │ │ │ +
68template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
69class SimplexMethod<dimWorld,0,0,T> : public ComputationMethod<dimWorld,0,0,T>{
│ │ │ │ +
70 friend class ComputationMethod<dimWorld,0,0,T>;
│ │ │ │ +
71
│ │ │ │ +
72public:
│ │ │ │ +
73 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
74 static const int grid1Dimension = 0;
│ │ │ │ +
75 static const int grid2Dimension = 0;
│ │ │ │ +
76 static const int intersectionDimension = 0;
│ │ │ │ +
77
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
79 const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
80 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
81 std::vector<std::vector<int> > & SX,
│ │ │ │ +
82 std::vector<std::vector<int> > & SY,
│ │ │ │ +
83 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
84 {
│ │ │ │ +
85 assert(X.size() == 1 && Y.size() == 1);
│ │ │ │ +
86
│ │ │ │ +
87 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
88 int k;
│ │ │ │ +
89
│ │ │ │ +
90 T eps = 1e-8;
│ │ │ │ +
91 T a = X[0].infinity_norm();
│ │ │ │ +
92 T b = Y[0].infinity_norm();
│ │ │ │ +
93 T c = (X[0] - Y[0]).infinity_norm();
│ │ │ │ +
94
│ │ │ │ +
95 if (c <= eps*a || c <= eps*b ||
│ │ │ │ +
96 (a<eps && b< eps && c < 0.5*eps) ) {
│ │ │ │ +
97 k = insertPoint(X[0],P);
│ │ │ │ +
98
│ │ │ │ +
99 return true;
│ │ │ │ +
100 }
│ │ │ │ +
101 return false;
│ │ │ │ +
102 }
│ │ │ │ +
│ │ │ │ +
103
│ │ │ │ +
│ │ │ │ +
104 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
105 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
106 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
107 {
│ │ │ │ +
108 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
109 elementCorners,subElements, faceIds);
│ │ │ │ +
110 }
│ │ │ │ +
│ │ │ │ +
111
│ │ │ │ +
112 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
113 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
114 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
115 {
│ │ │ │ +
116 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
117 elementCorners, subElements, faceIds);
│ │ │ │ +
118 }
│ │ │ │ +
119
│ │ │ │ +
120};
│ │ │ │ +
│ │ │ │ +
121
│ │ │ │ +
122
│ │ │ │ +
123// POINT ON LINE SEGMENT - :)
│ │ │ │ +
124template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
125class SimplexMethod<dimWorld,0,1,T> : public ComputationMethod<dimWorld,0,1,T>{
│ │ │ │ +
126 friend class ComputationMethod<dimWorld,0,1,T>;
│ │ │ │ +
127
│ │ │ │ +
128public:
│ │ │ │ +
129 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
130 static const int grid1Dimension = 0;
│ │ │ │ +
131 static const int grid2Dimension = 1;
│ │ │ │ +
132 static const int intersectionDimension = 0;
│ │ │ │ +
133
│ │ │ │ +
│ │ │ │ +
134 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
135 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
136 std::vector<std::vector<int> > & SX,
│ │ │ │ +
137 std::vector<std::vector<int> > & SY,
│ │ │ │ +
138 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
139 {
│ │ │ │ +
140 assert(X.size() == 1 && Y.size() == 2);
│ │ │ │ +
141
│ │ │ │ +
142 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
143 SY.resize(2);
│ │ │ │ +
144
│ │ │ │ +
145 if (dimWorld == 1) {
│ │ │ │ +
146 T lowerBound = std::max(X[0][0], std::min(Y[0][0],Y[1][0]));
│ │ │ │ +
147 T upperBound = std::min(X[0][0], std::max(Y[0][0],Y[1][0]));
│ │ │ │ +
148
│ │ │ │ +
149 if (lowerBound <= upperBound) { // Intersection is non-empty
│ │ │ │ +
150 insertPoint(X[0],P);
│ │ │ │ +
151 return true;
│ │ │ │ +
152 }
│ │ │ │ +
153 } else {
│ │ │ │ +
154
│ │ │ │ +
155 T eps = 1e-8;
│ │ │ │ +
156
│ │ │ │ +
157 // check whether the point is on the segment
│ │ │ │ +
158 FieldVector<T,dimWorld> v0 = X[0] - Y[0];
│ │ │ │ +
159 FieldVector<T,dimWorld> v1 = X[0] - Y[1];
│ │ │ │ +
160 FieldVector<T,dimWorld> v2 = Y[1] - Y[0];
│ │ │ │ +
161
│ │ │ │ +
162 T s = v0.dot(v1);
│ │ │ │ +
163 T t = v0.two_norm()/v2.two_norm();
│ │ │ │ +
164 v2*=t;
│ │ │ │ +
165 v2+=Y[0];
│ │ │ │ +
166 v2-=X[0];
│ │ │ │ +
167
│ │ │ │ +
168 if (v2.infinity_norm() < eps && s<=eps && t<=1+eps) {
│ │ │ │ +
169
│ │ │ │ +
170 int k = insertPoint(X[0],P);
│ │ │ │ +
171 if (s < eps && t < eps)
│ │ │ │ +
172 SY[0].push_back(k);
│ │ │ │ +
173 else if (s < eps && t>1-eps)
│ │ │ │ +
174 SY[1].push_back(k);
│ │ │ │ +
175 return true;
│ │ │ │ +
176 }
│ │ │ │ +
177 }
│ │ │ │ +
178 return false;
│ │ │ │ +
179 }
│ │ │ │ +
│ │ │ │
180
│ │ │ │ -
181 std::array<LocalCoords,2> center;
│ │ │ │ -
182 center[0] = 0; center[1] = 0;
│ │ │ │ -
183 for (int i=0; i<nPolyCorners; i++) {
│ │ │ │ -
184 center[0].axpy(1.0/nPolyCorners,polytopeCorners[i][0]);
│ │ │ │ -
185 center[1].axpy(1.0/nPolyCorners,polytopeCorners[i][1]);
│ │ │ │ -
186 }
│ │ │ │ -
187
│ │ │ │ -
188 // Order cyclic
│ │ │ │ -
189 std::vector<int> ordering;
│ │ │ │ -
190 computeCyclicOrder(polytopeCorners,center[0],ordering);
│ │ │ │ -
191
│ │ │ │ -
193 // Add intersections
│ │ │ │ -
195
│ │ │ │ -
196 for (size_t i=1; i<polytopeCorners.size()-1; i++) {
│ │ │ │ -
197
│ │ │ │ -
198 typename Base::SimplicialIntersection intersect(grid1Index, grid2Index);
│ │ │ │ +
│ │ │ │ +
181 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
182 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
183 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
184 {
│ │ │ │ +
185 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
186 elementCorners,subElements, faceIds);
│ │ │ │ +
187 }
│ │ │ │ +
│ │ │ │ +
188
│ │ │ │ +
189 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
190 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
191 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
192 {
│ │ │ │ +
193 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
194 elementCorners, subElements, faceIds);
│ │ │ │ +
195 }
│ │ │ │ +
196
│ │ │ │ +
197};
│ │ │ │ +
│ │ │ │ +
198
│ │ │ │
199
│ │ │ │ -
200 for (int j=0;j<dim; j++) {
│ │ │ │ -
201 intersect.corners0[0][j]=polytopeCorners[ordering[i+j]][0];
│ │ │ │ -
202 intersect.corners1[0][j]=polytopeCorners[ordering[i+j]][1];
│ │ │ │ -
203 }
│ │ │ │ +
200// POINT IN TRIANGLE - :)
│ │ │ │ +
201template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
202class SimplexMethod<dimWorld,0,2,T> : public ComputationMethod<dimWorld,0,2,T>{
│ │ │ │ +
203 friend class ComputationMethod<dimWorld,0,2,T>;
│ │ │ │
204
│ │ │ │ -
205 // last corner is the first for all intersections
│ │ │ │ -
206 intersect.corners0[0][dim]=polytopeCorners[ordering[0]][0];
│ │ │ │ -
207 intersect.corners1[0][dim]=polytopeCorners[ordering[0]][1];
│ │ │ │ -
208
│ │ │ │ -
209 intersections.push_back(intersect);
│ │ │ │ -
210 }
│ │ │ │ -
211}
│ │ │ │ -
212
│ │ │ │ -
213template<int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
214void ContactMerge<dimworld, T>::computeCyclicOrder(const std::vector<std::array<LocalCoords,2> >& polytopeCorners,
│ │ │ │ -
215 const LocalCoords& center, std::vector<int>& ordering) const
│ │ │ │ -
216{
│ │ │ │ -
217 ordering.resize(polytopeCorners.size());
│ │ │ │ +
205public:
│ │ │ │ +
206 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
207 static const int grid1Dimension = 0;
│ │ │ │ +
208 static const int grid2Dimension = 2;
│ │ │ │ +
209 static const int intersectionDimension = 0;
│ │ │ │ +
210
│ │ │ │ +
│ │ │ │ +
211 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
212 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
213 std::vector<std::vector<int> > & SX,
│ │ │ │ +
214 std::vector<std::vector<int> > & SY,
│ │ │ │ +
215 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
216 {
│ │ │ │ +
217 assert(X.size() == 1 && Y.size() == 3 && dimWorld > 1);
│ │ │ │
218
│ │ │ │ -
219 for (size_t k=0; k<ordering.size(); k++)
│ │ │ │ -
220 ordering[k] = k;
│ │ │ │ -
221
│ │ │ │ -
222 //TODO Do I have to order triangles to get some correct orientation?
│ │ │ │ -
223 if (polytopeCorners.size()<=3)
│ │ │ │ -
224 return;
│ │ │ │ +
219 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
220 SY.resize(3);
│ │ │ │ +
221 int k;
│ │ │ │ +
222
│ │ │ │ +
223 // If not, check whether it is inside the triangle
│ │ │ │ +
224 double eps= 1e-8 ; // tolerance for relative error
│ │ │ │
225
│ │ │ │ -
226 // compute angles inside the polygon plane w.r.t to this axis
│ │ │ │ -
227 LocalCoords edge0 = polytopeCorners[1][0] - polytopeCorners[0][0];
│ │ │ │ -
228
│ │ │ │ -
229 // Compute a vector that is perpendicular to the edge but lies in the polytope plane
│ │ │ │ -
230 // So we have a unique ordering
│ │ │ │ -
231 LocalCoords edge1 = polytopeCorners[2][0] - polytopeCorners[0][0];
│ │ │ │ -
232 LocalCoords normal0 = edge1;
│ │ │ │ -
233 normal0.axpy(-(edge0*edge1),edge0);
│ │ │ │ -
234
│ │ │ │ -
235 std::vector<T> angles(polytopeCorners.size());
│ │ │ │ -
236
│ │ │ │ -
237 for (size_t i=0; i<polytopeCorners.size(); i++) {
│ │ │ │ +
226 FieldVector<T,dimWorld> v0,v1,v2,r;
│ │ │ │ +
227
│ │ │ │ +
228 v0 = Y[1] - Y[0];
│ │ │ │ +
229 v1 = Y[2] - Y[0];
│ │ │ │ +
230 v2 = X[0] - Y[0];
│ │ │ │ +
231
│ │ │ │ +
232 T s,t,d;
│ │ │ │ +
233
│ │ │ │ +
234 d = ((v0.dot(v0))*(v1.dot(v1)) - (v0.dot(v1))*(v0.dot(v1)));
│ │ │ │ +
235
│ │ │ │ +
236 s = ((v1.dot(v1))*(v0.dot(v2)) - (v0.dot(v1))*(v1.dot(v2))) / d;
│ │ │ │ +
237 t = ((v0.dot(v0))*(v1.dot(v2)) - (v0.dot(v1))*(v0.dot(v2))) / d;
│ │ │ │
238
│ │ │ │ -
239 LocalCoords edge = polytopeCorners[i][0] - center;
│ │ │ │ -
240
│ │ │ │ -
241 T x(edge*edge0);
│ │ │ │ -
242 T y(edge*normal0);
│ │ │ │ -
243
│ │ │ │ -
244 angles[i] = std::atan2(y, x);
│ │ │ │ -
245 if (angles[i]<0)
│ │ │ │ -
246 angles[i] += 2*M_PI;
│ │ │ │ -
247 }
│ │ │ │ -
248
│ │ │ │ -
249 // bubblesort
│ │ │ │ -
250
│ │ │ │ -
251 for (int i=polytopeCorners.size(); i>1; i--){
│ │ │ │ -
252 bool swapped = false;
│ │ │ │ -
253
│ │ │ │ -
254 for (int j=0; j<i-1; j++){
│ │ │ │ +
239 v0*=s;
│ │ │ │ +
240 v1*=t;
│ │ │ │ +
241 r = Y[0] + v0 + v1;
│ │ │ │ +
242
│ │ │ │ +
243 if (s > -eps && t > -eps && (s+t)< 1+eps && (r-X[0]).infinity_norm() < eps) {
│ │ │ │ +
244 k = insertPoint(X[0],P);
│ │ │ │ +
245
│ │ │ │ +
246 if (t < eps) { // t ~ 0, s varies -> edge 0
│ │ │ │ +
247 SY[0].push_back(k);
│ │ │ │ +
248 }
│ │ │ │ +
249 if (s < eps) { // s ~ 0, t varies -> edge 1
│ │ │ │ +
250 SY[1].push_back(k);
│ │ │ │ +
251 }
│ │ │ │ +
252 if (s+t > 1-eps) { // s+t ~ 1 -> edge 2
│ │ │ │ +
253 SY[2].push_back(k);
│ │ │ │ +
254 }
│ │ │ │
255
│ │ │ │ -
256 if (angles[j] > angles[j+1]){
│ │ │ │ -
257 swapped = true;
│ │ │ │ -
258 std::swap(angles[j], angles[j+1]);
│ │ │ │ -
259 std::swap(ordering[j], ordering[j+1]);
│ │ │ │ -
260 }
│ │ │ │ -
261 }
│ │ │ │ -
262
│ │ │ │ -
263 if (!swapped)
│ │ │ │ -
264 break;
│ │ │ │ -
265 }
│ │ │ │ -
266}
│ │ │ │ -
│ │ │ │ -
267
│ │ │ │ -
268template<int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
269void ContactMerge<dimworld, T>::setupNodalDirections(const std::vector<WorldCoords>& coords1,
│ │ │ │ -
270 const std::vector<unsigned int>& elements1,
│ │ │ │ -
271 const std::vector<Dune::GeometryType>& elementTypes1,
│ │ │ │ -
272 const std::vector<WorldCoords>& coords2,
│ │ │ │ -
273 const std::vector<unsigned int>& elements2,
│ │ │ │ -
274 const std::vector<Dune::GeometryType>& elementTypes2)
│ │ │ │ -
275{
│ │ │ │ -
276 if (domainDirections_) {
│ │ │ │ -
277
│ │ │ │ -
278 // Sample the provided analytical contact direction field
│ │ │ │ -
279 nodalDomainDirections_.resize(coords1.size());
│ │ │ │ -
280 for (size_t i=0; i<coords1.size(); i++)
│ │ │ │ -
281 nodalDomainDirections_[i] = domainDirections_(coords1[i]);
│ │ │ │ -
282 } else
│ │ │ │ -
283 computeOuterNormalField(coords1,elements1,elementTypes1, nodalDomainDirections_);
│ │ │ │ +
256 return true;
│ │ │ │ +
257 }
│ │ │ │ +
258
│ │ │ │ +
259 return false;
│ │ │ │ +
260 }
│ │ │ │ +
│ │ │ │ +
261
│ │ │ │ +
│ │ │ │ +
262 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
263 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
264 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
265 {
│ │ │ │ +
266 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
267 elementCorners,subElements, faceIds);
│ │ │ │ +
268 }
│ │ │ │ +
│ │ │ │ +
269
│ │ │ │ +
270 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
271 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
272 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
273 {
│ │ │ │ +
274 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
275 elementCorners, subElements, faceIds);
│ │ │ │ +
276 }
│ │ │ │ +
277};
│ │ │ │ +
│ │ │ │ +
278
│ │ │ │ +
279
│ │ │ │ +
280// POINT IN TETRAHEDRON - : )
│ │ │ │ +
281template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
282class SimplexMethod<dimWorld,0,3,T> : public ComputationMethod<dimWorld,0,3,T>{
│ │ │ │ +
283 friend class ComputationMethod<dimWorld,0,3,T>;
│ │ │ │
284
│ │ │ │ -
285 if (targetDirections_) {
│ │ │ │ -
286
│ │ │ │ -
287 // Sample the provided analytical target direction field
│ │ │ │ -
288 nodalTargetDirections_.resize(coords2.size());
│ │ │ │ -
289 for (size_t i=0; i<coords2.size(); i++)
│ │ │ │ -
290 nodalTargetDirections_[i] = targetDirections_(coords2[i]);
│ │ │ │ -
291 } else
│ │ │ │ -
292 computeOuterNormalField(coords2,elements2,elementTypes2, nodalTargetDirections_);
│ │ │ │ -
293}
│ │ │ │ -
│ │ │ │ -
294
│ │ │ │ -
295template<int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
296void ContactMerge<dimworld, T>::computeOuterNormalField(const std::vector<WorldCoords>& coords,
│ │ │ │ -
297 const std::vector<unsigned int>& elements,
│ │ │ │ -
298 const std::vector<Dune::GeometryType>& elementTypes,
│ │ │ │ -
299 std::vector<WorldCoords>& normals)
│ │ │ │ -
300{
│ │ │ │ -
301 normals.assign(coords.size(),WorldCoords(0));
│ │ │ │ -
302
│ │ │ │ -
303
│ │ │ │ -
304 int offset = 0;
│ │ │ │ +
285public:
│ │ │ │ +
286 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
287 static const int grid1Dimension = 0;
│ │ │ │ +
288 static const int grid2Dimension = 3;
│ │ │ │ +
289 static const int intersectionDimension = 0;
│ │ │ │ +
290
│ │ │ │ +
│ │ │ │ +
291 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
292 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
293 std::vector<std::vector<int> > & SX,
│ │ │ │ +
294 std::vector<std::vector<int> > & SY,
│ │ │ │ +
295 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
296 {
│ │ │ │ +
297 assert(X.size() == 1 && Y.size() == 4 && dimWorld == 3);
│ │ │ │ +
298
│ │ │ │ +
299 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
300 SY.resize(4);
│ │ │ │ +
301
│ │ │ │ +
302 T eps = 1e-8;
│ │ │ │ +
303 // if not, check whether its inside the tetrahedron
│ │ │ │ +
304 FieldMatrix<T,dimWorld+1,dimWorld+1> D,DD ;
│ │ │ │
305
│ │ │ │ -
306 for (size_t i=0; i<elementTypes.size(); i++) {
│ │ │ │ -
307
│ │ │ │ -
308 int nCorners = Dune::ReferenceElements<T,dim>::general(elementTypes[i]).size(dim);
│ │ │ │ -
309
│ │ │ │ -
310 // For segments 1, for triangles or quadrilaterals take the first 2
│ │ │ │ -
311 std::array<WorldCoords, dim> edges;
│ │ │ │ -
312 for (int j=1; j<=dim; j++)
│ │ │ │ -
313 edges[j-1] = coords[elements[offset + j]] - coords[elements[offset]];
│ │ │ │ -
314
│ │ │ │ -
315 WorldCoords elementNormal;
│ │ │ │ -
316
│ │ │ │ -
317 if (dim==1) {
│ │ │ │ -
318 elementNormal[0] = edges[0][1]; elementNormal[1] = -edges[0][0];
│ │ │ │ -
319 } else
│ │ │ │ -
320 elementNormal = crossProduct(edges[0], edges[1]);
│ │ │ │ -
321
│ │ │ │ -
322 elementNormal /= elementNormal.two_norm();
│ │ │ │ -
323
│ │ │ │ -
324 for (int j=0; j<nCorners;j++)
│ │ │ │ -
325 normals[elements[offset + j]] += elementNormal;
│ │ │ │ -
326
│ │ │ │ -
327 offset += nCorners;
│ │ │ │ -
328 }
│ │ │ │ -
329
│ │ │ │ -
330 for (size_t i=0; i<coords.size(); i++)
│ │ │ │ -
331 normals[i] /= normals[i].two_norm();
│ │ │ │ -
332}
│ │ │ │ -
│ │ │ │ -
333
│ │ │ │ -
334template<int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
335void ContactMerge<dimworld, T>::removeDoubles(std::vector<std::array<LocalCoords,2> >& polytopeCorners)
│ │ │ │ -
336{
│ │ │ │ -
337
│ │ │ │ -
338 size_t counter(1);
│ │ │ │ -
339 for (size_t i=1; i<polytopeCorners.size(); i++) {
│ │ │ │ -
340 bool contained = false;
│ │ │ │ -
341 for (size_t j=0; j<counter; j++)
│ │ │ │ -
342 if ( (polytopeCorners[j][0]-polytopeCorners[i][0]).two_norm()<1e-10) {
│ │ │ │ -
343 assert((polytopeCorners[j][1]-polytopeCorners[i][1]).two_norm()<1e-10);
│ │ │ │ -
344 contained = true;
│ │ │ │ -
345 break;
│ │ │ │ -
346 }
│ │ │ │ -
347
│ │ │ │ -
348 if (!contained) {
│ │ │ │ -
349 if (counter < i)
│ │ │ │ -
350 polytopeCorners[counter] = polytopeCorners[i];
│ │ │ │ -
351 counter++;
│ │ │ │ -
352 }
│ │ │ │ -
353 }
│ │ │ │ -
354 polytopeCorners.resize(counter);
│ │ │ │ -
355}
│ │ │ │ -
│ │ │ │ -
356
│ │ │ │ -
357} /* namespace GridGlue */
│ │ │ │ -
358} /* namespace Dune */
│ │ │ │ - │ │ │ │ - │ │ │ │ +
306 D[0][0] = Y[0][0] ; D[0][1] = Y[1][0] ; D[0][2] = Y[2][0] ; D[0][3] = Y[3][0] ;
│ │ │ │ +
307 D[1][0] = Y[0][1] ; D[1][1] = Y[1][1] ; D[1][2] = Y[2][1] ; D[1][3] = Y[3][1] ;
│ │ │ │ +
308 D[2][0] = Y[0][2] ; D[2][1] = Y[1][2] ; D[2][2] = Y[2][2] ; D[2][3] = Y[3][2] ;
│ │ │ │ +
309 D[3][0] = 1 ; D[3][1] = 1 ; D[3][2] = 1 ; D[3][3] = 1 ;
│ │ │ │ +
310
│ │ │ │ +
311 std::array<T, 5> detD;
│ │ │ │ +
312 detD[0] = D.determinant();
│ │ │ │ +
313
│ │ │ │ +
314 for(unsigned i = 1; i < detD.size(); ++i) {
│ │ │ │ +
315 DD = D;
│ │ │ │ +
316 for (unsigned d = 0; d < dimWorld; ++d)
│ │ │ │ +
317 DD[d][i-1] = X[0][d];
│ │ │ │ +
318 detD[i] = DD.determinant();
│ │ │ │ +
319 if (std::abs(detD[i]) > eps && std::signbit(detD[0]) != std::signbit(detD[i]))
│ │ │ │ +
320 return false; // We are outside.
│ │ │ │ +
321 }
│ │ │ │ +
322
│ │ │ │ +
323 int k = insertPoint(X[0],P);
│ │ │ │ +
324 unsigned int faces[4] = {3,2,1,0};
│ │ │ │ +
325 for (unsigned i = 1; i < detD.size(); ++i)
│ │ │ │ +
326 if(std::abs(detD[i]) < eps)
│ │ │ │ +
327 SY[faces[i-1]].push_back(k); // on triangle not containing node i-1
│ │ │ │ +
328
│ │ │ │ +
329 return true;
│ │ │ │ +
330 }
│ │ │ │ +
│ │ │ │ +
331
│ │ │ │ +
│ │ │ │ +
332 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
333 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
334 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
335 {
│ │ │ │ +
336 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
337 elementCorners,subElements, faceIds);
│ │ │ │ +
338 }
│ │ │ │ +
│ │ │ │ +
339
│ │ │ │ +
340 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
341 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
342 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
343 {
│ │ │ │ +
344 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
345 elementCorners, subElements, faceIds);
│ │ │ │ +
346 }
│ │ │ │ +
347};
│ │ │ │ +
│ │ │ │ +
348
│ │ │ │ +
349// SEGEMENT-SEGMENT INTERSECTION - :)
│ │ │ │ +
350template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
351class SimplexMethod<dimWorld,1,1,T> : public ComputationMethod<dimWorld,1,1,T>{
│ │ │ │ +
352 friend class ComputationMethod<dimWorld,1,1,T>;
│ │ │ │ +
353
│ │ │ │ +
354public:
│ │ │ │ +
355 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
356 static const int grid1Dimension = 1;
│ │ │ │ +
357 static const int grid2Dimension = 1;
│ │ │ │ +
358 static const int intersectionDimension = 1;
│ │ │ │ +
359
│ │ │ │ +
│ │ │ │ +
360 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
361 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
362 std::vector<std::vector<int> > & SX,
│ │ │ │ +
363 std::vector<std::vector<int> > & SY,
│ │ │ │ +
364 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
365 {
│ │ │ │ +
366 assert(X.size() == 2 && Y.size() == 2);
│ │ │ │ +
367
│ │ │ │ +
368 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
369 SX.resize(2);
│ │ │ │ +
370 SY.resize(2);
│ │ │ │ +
371 T eps = 1e-8;
│ │ │ │ +
372 int k,idX_min=-1,idX_max=-1,idY_min=-1,idY_max=-1;
│ │ │ │ +
373
│ │ │ │ +
374 // compute intersections
│ │ │ │ +
375 switch (dimWorld) {
│ │ │ │ +
376 case 1: // d
│ │ │ │ +
377 {
│ │ │ │ +
378 FieldVector<T,dimWorld> lowerbound(std::max(std::min(X[0][0],X[1][0]), std::min(Y[0][0],X[1][0])));
│ │ │ │ +
379 FieldVector<T,dimWorld> upperbound(std::min(std::max(X[0][0],X[1][0]), std::max(Y[0][0],Y[1][0])));
│ │ │ │ +
380
│ │ │ │ +
381 if (lowerbound[0] < upperbound[0]) { // Intersection is non-empty
│ │ │ │ +
382
│ │ │ │ +
383 idX_min = (std::min(X[0][0],X[1][0]) < std::min(Y[0][0],Y[1][0]))?(-1):((X[0][0]<X[1][0])?(0):(1));
│ │ │ │ +
384 if (idX_min < 0)
│ │ │ │ +
385 idY_min = ((Y[0][0]<Y[1][0])?(0):(1));
│ │ │ │ +
386
│ │ │ │ +
387 idX_max = (std::max(X[0][0],X[1][0]) > std::max(Y[0][0],Y[1][0]))?(-1):((X[0][0]>X[1][0])?(0):(1));
│ │ │ │ +
388 if (idX_max < 0)
│ │ │ │ +
389 idY_max = ((Y[0][0]>Y[1][0])?(0):(1));
│ │ │ │ +
390
│ │ │ │ +
391 k = insertPoint(lowerbound,P);
│ │ │ │ +
392 if (idX_min >= 0)
│ │ │ │ +
393 SX[idX_min].push_back(k);
│ │ │ │ +
394 else
│ │ │ │ +
395 SY[idY_min].push_back(k);
│ │ │ │ +
396
│ │ │ │ +
397 k = insertPoint(upperbound,P);
│ │ │ │ +
398 if (idX_max >= 0)
│ │ │ │ +
399 SX[idX_max].push_back(k);
│ │ │ │ +
400 else
│ │ │ │ +
401 SY[idY_max].push_back(k);
│ │ │ │ +
402
│ │ │ │ +
403 return true;
│ │ │ │ +
404 }
│ │ │ │ +
405 return false;
│ │ │ │ +
406 }
│ │ │ │ +
407 case 2: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0)
│ │ │ │ +
408 { // get size_type for all the vectors we are using
│ │ │ │ +
409
│ │ │ │ +
410 FieldMatrix<T,dimWorld, dimWorld> A;
│ │ │ │ +
411 A[0][0] = X[1][0] - X[0][0]; A[0][1] = Y[0][0] - Y[1][0];
│ │ │ │ +
412 A[1][0] = X[1][1] - X[0][1]; A[1][1] = Y[0][1] - Y[1][1];
│ │ │ │ +
413
│ │ │ │ +
414 if (std::abs(A.determinant())>eps) {
│ │ │ │ +
415 // lines are non parallel and not degenerated
│ │ │ │ +
416 FieldVector<T,dimWorld> p,r,b = Y[0] - X[0];
│ │ │ │ +
417 A.solve(r,b) ;
│ │ │ │ +
418
│ │ │ │ +
419 if ((r[0]>-eps)&&(r[0]<=1+eps)&&(r[1]>-eps)&&(r[1]<1+eps)) {
│ │ │ │ +
420 p = X[1] - X[0];
│ │ │ │ +
421 p *= r[0] ;
│ │ │ │ +
422 p += X[0] ;
│ │ │ │ +
423 k = insertPoint(p,P);
│ │ │ │ +
424 if(r[0] < eps) { // X = X_0 + r_0 (X_1 - X_0) = X_0
│ │ │ │ +
425 SX[0].push_back(k);
│ │ │ │ +
426 P[k] = X[0];
│ │ │ │ +
427 }
│ │ │ │ +
428 else if(r[0] > 1-eps) { // X = X_0 + r_0 (X_1 - X_0) = X_1
│ │ │ │ +
429 SX[1].push_back(k);
│ │ │ │ +
430 P[k] = X[1];
│ │ │ │ +
431 }
│ │ │ │ +
432 if(r[1] < eps){ // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_0
│ │ │ │ +
433 SY[0].push_back(k);
│ │ │ │ +
434 P[k] = Y[0];
│ │ │ │ +
435 }
│ │ │ │ +
436 else if(r[1] > 1-eps) { // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_1
│ │ │ │ +
437 SY[1].push_back(k);
│ │ │ │ +
438 P[k] = Y[1];
│ │ │ │ +
439 }
│ │ │ │ +
440 return true;
│ │ │ │ +
441 }
│ │ │ │ +
442 } else if ((X[1]-X[0]).infinity_norm() > eps && (Y[1]-Y[0]).infinity_norm() > eps) {
│ │ │ │ +
443 // lines are parallels, but non degenerated
│ │ │ │ +
444 bool found = false;
│ │ │ │ +
445
│ │ │ │ +
446 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2 for non perpendicular lines
│ │ │ │ +
447 for (unsigned i = 0; i < 2; ++i) {
│ │ │ │ +
448 if (std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm())
│ │ │ │ +
449 - std::abs((X[1]-X[0]).two_norm())) < eps) {
│ │ │ │ +
450 k = insertPoint(Y[i],P);
│ │ │ │ +
451 SY[i].push_back(k);
│ │ │ │ +
452 found = true;
│ │ │ │ +
453 }
│ │ │ │ +
454 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm())
│ │ │ │ +
455 - std::abs((Y[1]-Y[0]).two_norm())) < eps) {
│ │ │ │ +
456 k = insertPoint(X[i],P);
│ │ │ │ +
457 SX[i].push_back(k);
│ │ │ │ +
458 found = true;
│ │ │ │ +
459 }
│ │ │ │ +
460 }
│ │ │ │ +
461 return found;
│ │ │ │ +
462 }
│ │ │ │ +
463 return false;
│ │ │ │ +
464 }
│ │ │ │ +
465 case 3: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0)
│ │ │ │ +
466 { FieldVector<T,dimWorld> dX, dY, dZ, cXY, cYZ;
│ │ │ │ +
467
│ │ │ │ +
468 dX = X[1]-X[0];
│ │ │ │ +
469 dY = Y[1]-Y[0];
│ │ │ │ +
470 dZ = Y[0]-X[0];
│ │ │ │ +
471
│ │ │ │ +
472 cXY[0] = dX[1]* dY[2] - dX[2]* dY[1];
│ │ │ │ +
473 cXY[1] = dX[2]* dY[0] - dX[0]* dY[2];
│ │ │ │ +
474 cXY[2] = dX[0]* dY[1] - dX[1]* dY[0];
│ │ │ │ +
475
│ │ │ │ +
476 if (fabs(dZ.dot(cXY)) < eps*1e+3 && cXY.infinity_norm()>eps) { // coplanar, but not aligned
│ │ │ │ +
477
│ │ │ │ +
478 cYZ[0] = dY[1]* dZ[2] - dY[2]* dZ[1];
│ │ │ │ +
479 cYZ[1] = dY[2]* dZ[0] - dY[0]* dZ[2];
│ │ │ │ +
480 cYZ[2] = dY[0]* dZ[1] - dY[1]* dZ[0];
│ │ │ │ +
481
│ │ │ │ +
482 T s = -cYZ.dot(cXY) / cXY.two_norm2();
│ │ │ │ +
483
│ │ │ │ +
484 if (s > -eps && s < 1+eps) {
│ │ │ │ +
485 dX*= s;
│ │ │ │ +
486 dX+= X[0];
│ │ │ │ +
487 T o = (dX - Y[0]).two_norm() + (dX- Y[1]).two_norm();
│ │ │ │ +
488
│ │ │ │ +
489 if (std::abs(o-dY.two_norm()) < eps) {
│ │ │ │ +
490 k = insertPoint(dX,P);
│ │ │ │ +
491 \
│ │ │ │ +
492 if (s<eps) {
│ │ │ │ +
493 P[k] = X[0];
│ │ │ │ +
494 SX[0].push_back(k);
│ │ │ │ +
495 } else if(s > 1-eps) {
│ │ │ │ +
496 P[k] = X[1];
│ │ │ │ +
497 SX[1].push_back(k);
│ │ │ │ +
498 } else if ((dX - Y[0]).two_norm() < eps) {
│ │ │ │ +
499 P[k] = Y[0];
│ │ │ │ +
500 SY[0].push_back(k);
│ │ │ │ +
501 } else if((dX - Y[1]).two_norm() < eps) {
│ │ │ │ +
502 P[k] = Y[1];
│ │ │ │ +
503 SY[1].push_back(k);
│ │ │ │ +
504 }
│ │ │ │ +
505
│ │ │ │ +
506 return true;
│ │ │ │ +
507 }
│ │ │ │ +
508 }
│ │ │ │ +
509 } else if (cXY.infinity_norm() <= eps) {// lines are parallel
│ │ │ │ +
510
│ │ │ │ +
511 bool found = false;
│ │ │ │ +
512
│ │ │ │ +
513 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2,
│ │ │ │ +
514 // under the assumption (a-c)*(c-b) > 0 or (a-c) = 0 or (c-b) = 0
│ │ │ │ +
515 for (unsigned i = 0; i < 2; ++i) {
│ │ │ │ +
516 if ((std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) // triangle equality
│ │ │ │ +
517 - std::abs((X[1]-X[0]).two_norm())) < eps) &&
│ │ │ │ +
518 (std::abs((Y[i]-X[0]).dot((Y[i]-X[1]))) > eps // assumption
│ │ │ │ +
519 || (Y[i]-X[0]).infinity_norm() < eps || (Y[i]-X[1]).infinity_norm() < eps)) {
│ │ │ │ +
520 k = insertPoint(Y[i],P);
│ │ │ │ +
521 SY[i].push_back(k);
│ │ │ │ +
522 found = true;
│ │ │ │ +
523 }
│ │ │ │ +
524 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) // triangle equality
│ │ │ │ +
525 - std::abs((Y[1]-Y[0]).two_norm())) < eps &&
│ │ │ │ +
526 (std::abs((X[i]-Y[0]).dot((X[i]-Y[1]))) > eps // assumption
│ │ │ │ +
527 || (X[i]-Y[0]).infinity_norm() < eps || (X[i]-Y[1]).infinity_norm() < eps)){
│ │ │ │ +
528 k = insertPoint(X[i],P);
│ │ │ │ +
529 SX[i].push_back(k);
│ │ │ │ +
530 found = true;
│ │ │ │ +
531 }
│ │ │ │ +
532 }
│ │ │ │ +
533 return found;
│ │ │ │ +
534 }
│ │ │ │ +
535
│ │ │ │ +
536 return false;
│ │ │ │ +
537 }
│ │ │ │ +
538 }
│ │ │ │ +
539 return false;
│ │ │ │ +
540 }
│ │ │ │ +
│ │ │ │ +
541
│ │ │ │ +
│ │ │ │ +
542 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
543 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
544 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
545 {
│ │ │ │ +
546 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
547 elementCorners,subElements, faceIds);
│ │ │ │ +
548 }
│ │ │ │ +
│ │ │ │ +
549
│ │ │ │ +
550 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
551 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
552 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
553 {
│ │ │ │ +
554 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
555 elementCorners, subElements, faceIds);
│ │ │ │ +
556 }
│ │ │ │ +
557};
│ │ │ │ +
│ │ │ │ +
558
│ │ │ │ +
559// SEGEMENT-TRIANGLE INTERSECTION - : )
│ │ │ │ +
560template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
561class SimplexMethod<dimWorld,1,2,T> : public ComputationMethod<dimWorld,1,2,T>{
│ │ │ │ +
562 friend class ComputationMethod<dimWorld,1,2,T>;
│ │ │ │ +
563
│ │ │ │ +
564public:
│ │ │ │ +
565 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
566 static const int grid1Dimension = 1;
│ │ │ │ +
567 static const int grid2Dimension = 2;
│ │ │ │ +
568 static const int intersectionDimension = 1;
│ │ │ │ +
569
│ │ │ │ +
│ │ │ │ +
570 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
571 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
572 std::vector<std::vector<int> > & SX,
│ │ │ │ +
573 std::vector<std::vector<int> > & SY,
│ │ │ │ +
574 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
575 {
│ │ │ │ +
576
│ │ │ │ +
577 assert(X.size() == 2 && Y.size() == 3 && dimWorld > 1);
│ │ │ │ +
578 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
579 SX.resize(2);
│ │ │ │ +
580 SY.resize(3);
│ │ │ │ +
581
│ │ │ │ +
582 int k;
│ │ │ │ +
583 std::vector<FieldVector<T,dimWorld> > surfPts, edge(2), pni(1);
│ │ │ │ +
584 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ +
585
│ │ │ │ +
586 // is any segment point inside the triangle?
│ │ │ │ +
587 for (unsigned ni = 0; ni < 2; ++ni) {
│ │ │ │ +
588 pni[0] = X[ni];
│ │ │ │ +
589
│ │ │ │ + │ │ │ │ +
591 k = insertPoint(X[ni],P);
│ │ │ │ +
592 SX[ni].push_back(k);
│ │ │ │ +
593 for (unsigned e=0; e < 3; ++e)
│ │ │ │ +
594 if (hSY[e].size() > 0)
│ │ │ │ +
595 SY[e].push_back(k);
│ │ │ │ +
596
│ │ │ │ +
597 }
│ │ │ │ +
598 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ +
599 }
│ │ │ │ +
600
│ │ │ │ +
601 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ +
602 return true;
│ │ │ │ +
603
│ │ │ │ +
604 unsigned int faces[3] = {0,2,1};
│ │ │ │ +
605 // do triangle faces intersect with the segment?
│ │ │ │ +
606 for (unsigned ni = 0; ni < 3; ++ni) {
│ │ │ │ +
607 edge[0] = Y[ni];
│ │ │ │ +
608 edge[1] = Y[(ni+1)%3];
│ │ │ │ +
609
│ │ │ │ + │ │ │ │ +
611 for (unsigned ne = 0; ne < surfPts.size(); ++ne) {
│ │ │ │ +
612 k = insertPoint(surfPts[ne],P);
│ │ │ │ +
613 SY[faces[ni]].push_back(k);
│ │ │ │ +
614 if (hSX[0].size() > 0)
│ │ │ │ +
615 SX[0].push_back(k);
│ │ │ │ +
616 if (hSX[1].size() > 0)
│ │ │ │ +
617 SX[1].push_back(k);
│ │ │ │ +
618 }
│ │ │ │ +
619
│ │ │ │ +
620 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ +
621 return true;
│ │ │ │ +
622
│ │ │ │ +
623 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ +
624 }
│ │ │ │ +
625 }
│ │ │ │ +
626
│ │ │ │ +
627 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ +
628 return true;
│ │ │ │ +
629
│ │ │ │ +
630 // if line and triangle are not coplanar in 3d and do not intersect at boundaries
│ │ │ │ +
631 if (dimWorld == 3) {
│ │ │ │ +
632 T eps = 1e-8;
│ │ │ │ +
633
│ │ │ │ +
634 Dune::FieldVector<T,dimWorld> B,r,p ;
│ │ │ │ +
635 Dune::FieldMatrix<T,dimWorld,dimWorld> A ;
│ │ │ │ +
636
│ │ │ │ +
637 B = Y[0] - X[0] ;
│ │ │ │ +
638
│ │ │ │ +
639 for (unsigned i = 0; i < dimWorld; ++i) {
│ │ │ │ +
640 A[i][0] = (X[1][i] - X[0][i]);
│ │ │ │ +
641 A[i][1] = (Y[0][i] - Y[1][i]);
│ │ │ │ +
642 A[i][dimWorld-1] = (Y[0][i] - Y[dimWorld-1][i]);
│ │ │ │ +
643 }
│ │ │ │ +
644
│ │ │ │ +
645 if (std::abs(A.determinant())>eps) {
│ │ │ │ +
646
│ │ │ │ +
647 A.solve(r,B) ;
│ │ │ │ +
648
│ │ │ │ +
649 if ((r[0]>=-eps)&&(r[0]<=1+eps)
│ │ │ │ +
650 &&(r[1]>=-eps)&&(r[1]<=1+eps)
│ │ │ │ +
651 &&(r[2]>=-eps)&&(r[2]<=1+eps)
│ │ │ │ +
652 &&(r[1]+r[2]>=-eps) &&(r[1]+r[2]<=1+eps)) {
│ │ │ │ +
653 p = X[1] - X[0] ;
│ │ │ │ +
654 p *= r[0] ;
│ │ │ │ +
655 p += X[0] ;
│ │ │ │ +
656 k = insertPoint(p,P);
│ │ │ │ +
657
│ │ │ │ +
658 if (std::abs(r[0]) < eps) // we prefer exact locations
│ │ │ │ +
659 P[k] = X[0];
│ │ │ │ +
660 else if (std::abs(r[0]) > 1-eps)
│ │ │ │ +
661 P[k] = X[1];
│ │ │ │ +
662 else if (std::abs(r[1]) < eps && std::abs(r[2]) < eps)
│ │ │ │ +
663 P[k] = Y[0];
│ │ │ │ +
664 else if (std::abs(r[1]) < eps && std::abs(r[2]) > 1-eps)
│ │ │ │ +
665 P[k] = Y[2];
│ │ │ │ +
666 else if (std::abs(r[1]) > 1-eps && std::abs(r[2]) < eps)
│ │ │ │ +
667 P[k] = Y[1];
│ │ │ │ +
668
│ │ │ │ +
669 if (std::abs(r[1]) < eps)
│ │ │ │ +
670 SY[1].push_back(k);
│ │ │ │ +
671 if (std::fabs(r[dimWorld-1]) < eps)
│ │ │ │ +
672 SY[0].push_back(k);
│ │ │ │ +
673 if (std::fabs(r[1]+r[dimWorld-1] - 1) < eps)
│ │ │ │ +
674 SY[2].push_back(k);
│ │ │ │ +
675
│ │ │ │ +
676
│ │ │ │ +
677 return true ;
│ │ │ │ +
678 }
│ │ │ │ +
679 }
│ │ │ │ +
680 }
│ │ │ │ +
681 return false ;
│ │ │ │ +
682 }
│ │ │ │ +
│ │ │ │ +
683
│ │ │ │ +
│ │ │ │ +
684 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
685 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
686 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
687 {
│ │ │ │ +
688 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
689 elementCorners,subElements, faceIds);
│ │ │ │ +
690 }
│ │ │ │ +
│ │ │ │ +
691
│ │ │ │ +
692 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
693 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
694 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
695 {
│ │ │ │ +
696 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
697 elementCorners, subElements, faceIds);
│ │ │ │ +
698 }
│ │ │ │ +
699};
│ │ │ │ +
│ │ │ │ +
700
│ │ │ │ +
701// SEGEMENT-TETRAHEDRON INTERSECTION - : )
│ │ │ │ +
702template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
703class SimplexMethod<dimWorld,1,3,T> : public ComputationMethod<dimWorld,1,3,T>{
│ │ │ │ +
704 friend class ComputationMethod<dimWorld,1,3,T>;
│ │ │ │ +
705
│ │ │ │ +
706public:
│ │ │ │ +
707 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
708 static const int grid1Dimension = 1;
│ │ │ │ +
709 static const int grid2Dimension = 3;
│ │ │ │ +
710 static const int intersectionDimension = 1;
│ │ │ │ +
711
│ │ │ │ +
│ │ │ │ +
712 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
713 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
714 std::vector<std::vector<int> > & SX,
│ │ │ │ +
715 std::vector<std::vector<int> > & SY,
│ │ │ │ +
716 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
717 {
│ │ │ │ +
718 assert(X.size() == 2 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ +
719
│ │ │ │ +
720 std::vector<int> indices;
│ │ │ │ +
721 std::vector<FieldVector<T,dimWorld> > surfPts;
│ │ │ │ +
722 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ +
723
│ │ │ │ +
724 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
725 SX.resize(2);
│ │ │ │ +
726 SY.resize(4);
│ │ │ │ +
727
│ │ │ │ +
728 std::vector<FieldVector<T,dimWorld> > pni(1);
│ │ │ │ +
729
│ │ │ │ +
730 bool b = false;
│ │ │ │ +
731
│ │ │ │ +
732 // check whether the corners of the segment are contained in the tetrahedron
│ │ │ │ +
733 for (unsigned int ci = 0; ci < 2; ++ ci) {
│ │ │ │ +
734
│ │ │ │ +
735 pni[0] = X[ci];
│ │ │ │ + │ │ │ │ +
737 int k = insertPoint(X[ci],P);
│ │ │ │ +
738 SX[ci].push_back(k);
│ │ │ │ +
739 b=true;
│ │ │ │ +
740 }
│ │ │ │ +
741 surfPts.clear();
│ │ │ │ +
742 hSX.clear(); hSY.clear();
│ │ │ │ +
743 }
│ │ │ │ +
744
│ │ │ │ +
745 if (P.size() == 2)
│ │ │ │ +
746 return true;
│ │ │ │ +
747
│ │ │ │ +
748 unsigned int faces[4] = {0,3,2,1};
│ │ │ │ +
749 // check whether tetrahedron faces intersect with segment
│ │ │ │ +
750 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ +
751 for (unsigned int ci = 0; ci < 4; ++ci) { // iterate over all faces
│ │ │ │ +
752 triangle[0] = Y[ci];
│ │ │ │ +
753 triangle[1] = Y[(ci+1)%4];
│ │ │ │ +
754 triangle[2] = Y[(ci+2)%4];
│ │ │ │ +
755
│ │ │ │ +
756 if (SimplexMethod<dimWorld,1,2,T>::computeIntersectionPoints(X,triangle,hSX,hSY,surfPts)) { // seg - triangle intersection
│ │ │ │ +
757 std::vector<int> indices(surfPts.size());
│ │ │ │ +
758 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
759 int k = insertPoint(surfPts[np],P);
│ │ │ │ +
760 indices[np]=k;
│ │ │ │ +
761 SY[faces[ci]].push_back(k);
│ │ │ │ +
762 }
│ │ │ │ +
763
│ │ │ │ +
764 // hSX[*] is nonempty if the intersection point is on an edge of the current face of Y
│ │ │ │ +
765 for (unsigned int np = 0; np < hSX[0].size(); ++np)
│ │ │ │ +
766 SX[0].push_back(indices[hSX[0][np]]);
│ │ │ │ +
767 for (unsigned int np = 0; np < hSX[1].size(); ++np)
│ │ │ │ +
768 SX[0].push_back(indices[hSX[1][np]]);
│ │ │ │ +
769
│ │ │ │ +
770 b = true;
│ │ │ │ +
771 }
│ │ │ │ +
772 surfPts.clear();
│ │ │ │ +
773 hSX.clear(); hSY.clear();
│ │ │ │ +
774 }
│ │ │ │ +
775
│ │ │ │ +
776 return b;
│ │ │ │ +
777 }
│ │ │ │ +
│ │ │ │ +
778
│ │ │ │ +
│ │ │ │ +
779 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
780 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
781 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
782 {
│ │ │ │ +
783 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
784 elementCorners,subElements, faceIds);
│ │ │ │ +
785 }
│ │ │ │ +
│ │ │ │ +
786
│ │ │ │ +
787 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
788 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
789 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
790 {
│ │ │ │ +
791 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
792 elementCorners, subElements, faceIds);
│ │ │ │ +
793 }
│ │ │ │ +
794};
│ │ │ │ +
│ │ │ │ +
795
│ │ │ │ +
796// TRIANGLE -TRIANGLE INTERSECTION
│ │ │ │ +
797template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
798class SimplexMethod<dimWorld,2,2,T> : public ComputationMethod<dimWorld,2,2,T>{
│ │ │ │ +
799 friend class ComputationMethod<dimWorld,2,2,T>;
│ │ │ │ +
800
│ │ │ │ +
801public:
│ │ │ │ +
802 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
803 static const int grid1Dimension = 2;
│ │ │ │ +
804 static const int grid2Dimension = 2;
│ │ │ │ +
805 static const int intersectionDimension = 2;
│ │ │ │ +
806
│ │ │ │ +
│ │ │ │ +
807 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
808 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
809 std::vector<std::vector<int> > & SX,
│ │ │ │ +
810 std::vector<std::vector<int> > & SY,
│ │ │ │ +
811 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
812 {
│ │ │ │ +
813 assert(X.size() == 3 && Y.size() == 3 && dimWorld > 1);
│ │ │ │ +
814
│ │ │ │ +
815 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
816
│ │ │ │ +
817 SX.resize(3);
│ │ │ │ +
818 SY.resize(3);
│ │ │ │ +
819
│ │ │ │ +
820 bool b = false;
│ │ │ │ +
821
│ │ │ │ +
822 std::vector<FieldVector<T,dimWorld> > edge(2);
│ │ │ │ +
823 std::vector<FieldVector<T,dimWorld> > surfPts;
│ │ │ │ +
824 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ +
825 std::vector<int> indices;
│ │ │ │ +
826
│ │ │ │ +
827 unsigned int faces[3] = {0,2,1};
│ │ │ │ +
828
│ │ │ │ +
829 for (unsigned int ni = 0; ni < 3; ++ni) {
│ │ │ │ +
830 // check whether the faces of triangle Y intersect the triangle X
│ │ │ │ +
831 edge[0] = Y[ni];
│ │ │ │ +
832 edge[1] = Y[(ni+1)%3];
│ │ │ │ +
833
│ │ │ │ + │ │ │ │ +
835
│ │ │ │ +
836 indices.resize(surfPts.size());
│ │ │ │ +
837 // add intersections of edges of Y with triangle X
│ │ │ │ +
838 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
839 int k = insertPoint(surfPts[np],P);
│ │ │ │ +
840 indices[np] = k;
│ │ │ │ +
841 SY[faces[ni]].push_back(k); // add edge data
│ │ │ │ +
842 }
│ │ │ │ +
843
│ │ │ │ +
844 b=true;
│ │ │ │ +
845 }
│ │ │ │ +
846 if (P.size() >= 6)
│ │ │ │ +
847 return true;
│ │ │ │ +
848
│ │ │ │ +
849 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ +
850 // check whether the faces of triangle X intersect the triangle Y
│ │ │ │ +
851 edge[0] = X[ni];
│ │ │ │ +
852 edge[1] = X[(ni+1)%3];
│ │ │ │ +
853
│ │ │ │ + │ │ │ │ +
855
│ │ │ │ +
856 indices.resize(surfPts.size());
│ │ │ │ +
857 // add intersections of edges of X with triangle Y
│ │ │ │ +
858 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
859 int k = insertPoint(surfPts[np],P);
│ │ │ │ +
860 indices[np] = k;
│ │ │ │ +
861 SX[faces[ni]].push_back(k); // add edge data
│ │ │ │ +
862 }
│ │ │ │ +
863
│ │ │ │ +
864 b=true;
│ │ │ │ +
865 }
│ │ │ │ +
866 if (P.size() >= 6)
│ │ │ │ +
867 return true;
│ │ │ │ +
868
│ │ │ │ +
869 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ +
870 }
│ │ │ │ +
871
│ │ │ │ +
872 return b;
│ │ │ │ +
873 }
│ │ │ │ +
│ │ │ │ +
874
│ │ │ │ +
│ │ │ │ +
875 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
876 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
877 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
878 {
│ │ │ │ +
879 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
880 elementCorners,subElements, faceIds);
│ │ │ │ +
881 }
│ │ │ │ +
│ │ │ │ +
882
│ │ │ │ +
883 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
884 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
885 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
886 {
│ │ │ │ +
887 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
888 elementCorners, subElements, faceIds);
│ │ │ │ +
889 }
│ │ │ │ +
890};
│ │ │ │ +
│ │ │ │ +
891
│ │ │ │ +
892// TRIANGLE -TETRAHEDRON INTERSECTION -: )
│ │ │ │ +
893template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
894class SimplexMethod<dimWorld,2,3,T> : public ComputationMethod<dimWorld,2,3,T>{
│ │ │ │ +
895 friend class ComputationMethod<dimWorld,2,3,T>;
│ │ │ │ +
896
│ │ │ │ +
897public:
│ │ │ │ +
898 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
899 static const int grid1Dimension = 2;
│ │ │ │ +
900 static const int grid2Dimension = 3;
│ │ │ │ +
901 static const int intersectionDimension = 2;
│ │ │ │ +
902
│ │ │ │ +
│ │ │ │ +
903 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
904 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
905 std::vector<std::vector<int> > & SX,
│ │ │ │ +
906 std::vector<std::vector<int> > & SY,
│ │ │ │ +
907 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
908 {
│ │ │ │ +
909 assert(X.size() == 3 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ +
910 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
911 SX.resize(3);
│ │ │ │ +
912 SY.resize(4);
│ │ │ │ +
913
│ │ │ │ +
914 bool b = false;
│ │ │ │ +
915 int k,ni,np, ep;
│ │ │ │ +
916 std::vector<FieldVector<T,dimWorld> > surfPts, xni(1);
│ │ │ │ +
917 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ +
918
│ │ │ │ +
919 unsigned int fiX[3][2];
│ │ │ │ +
920
│ │ │ │ +
921 fiX[0][0] = 0; fiX[1][0] = 0; fiX[2][0] = 1; // faces to node
│ │ │ │ +
922 fiX[0][1] = 1; fiX[1][1] = 2; fiX[2][1] = 2;
│ │ │ │ +
923 // 1st step: check whether the points of the triangle are contained in the tetrahedron
│ │ │ │ +
924 for (ni = 0; ni < 3; ++ni) {
│ │ │ │ +
925
│ │ │ │ +
926 xni[0] = X[ni];
│ │ │ │ + │ │ │ │ +
928 std::vector<int> indices(surfPts.size());
│ │ │ │ +
929 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
930 k = insertPoint(X[ni],P);
│ │ │ │ +
931 indices[np] = k;
│ │ │ │ +
932 SX[fiX[ni][0]].push_back(k); // the corresponding edges to the node are ni and (ni+2)%3
│ │ │ │ +
933 SX[fiX[ni][1]].push_back(k);
│ │ │ │ +
934 }
│ │ │ │ +
935
│ │ │ │ +
936 for (ep = 0; ep < 4; ++ep) {
│ │ │ │ +
937 for (np = 0; np < hSY[ep].size();++np) {
│ │ │ │ +
938 SY[ep].push_back(indices[hSY[ep][np]]);
│ │ │ │ +
939 }
│ │ │ │ +
940 }
│ │ │ │ +
941 b = true;
│ │ │ │ +
942 }
│ │ │ │ +
943 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
944 }
│ │ │ │ +
945
│ │ │ │ +
946 if (P.size() == 3) // intersection is given by all three corners of the triangle
│ │ │ │ +
947 return true;
│ │ │ │ +
948
│ │ │ │ +
949 // note: points of Y in X is called indirectly via triangle-triangle intesection
│ │ │ │ +
950
│ │ │ │ +
951 // check whether the triangles of the one tetrahedron intersect the triangle
│ │ │ │ +
952 unsigned int facesY[4] = {0,3,2,1}; // face ordering
│ │ │ │ +
953
│ │ │ │ +
954 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ +
955 for (ni = 0; ni < 4; ++ni) {
│ │ │ │ +
956
│ │ │ │ +
957 triangle[0] = Y[ni];
│ │ │ │ +
958 triangle[1] = Y[(ni+1)%4];
│ │ │ │ +
959 triangle[2] = Y[(ni+2)%4];
│ │ │ │ +
960
│ │ │ │ +
961 if (SimplexMethod<dimWorld,2,2,T>::computeIntersectionPoints(X,triangle,hSX,hSY,surfPts)) {
│ │ │ │ +
962 std::vector<int> indices(surfPts.size());
│ │ │ │ +
963 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
964 k = insertPoint(surfPts[np],P);
│ │ │ │ +
965 indices[np]=k;
│ │ │ │ +
966 SY[facesY[ni]].push_back(k);
│ │ │ │ +
967 }
│ │ │ │ +
968
│ │ │ │ +
969 // SX[*] is nonempty if the face * of X is intersected
│ │ │ │ +
970 for (np = 0; np < 3; ++np) {
│ │ │ │ +
971 for (ep = 0; ep < hSX[np].size(); ++ep) {
│ │ │ │ +
972 SX[np].push_back(indices[hSX[np][ep]]);
│ │ │ │ +
973 }
│ │ │ │ +
974 }
│ │ │ │ +
975
│ │ │ │ +
976 b = true;
│ │ │ │ +
977 }
│ │ │ │ +
978 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
979 }
│ │ │ │ +
980 return b;
│ │ │ │ +
981 }
│ │ │ │ +
│ │ │ │ +
982
│ │ │ │ +
│ │ │ │ +
983 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
984 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
985 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
986 {
│ │ │ │ +
987 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
988 elementCorners,subElements, faceIds);
│ │ │ │ +
989 }
│ │ │ │ +
│ │ │ │ +
990
│ │ │ │ +
991 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
992 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
993 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
994 {
│ │ │ │ +
995 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
996 elementCorners, subElements, faceIds);
│ │ │ │ +
997 }
│ │ │ │ +
998};
│ │ │ │ +
│ │ │ │ +
999
│ │ │ │ +
1000template<int dimWorld,typename T>
│ │ │ │ +
│ │ │ │ +
1001class SimplexMethod<dimWorld,3,3,T> : public ComputationMethod<dimWorld,3,3,T>{
│ │ │ │ +
1002 friend class ComputationMethod<dimWorld,3,3,T>;
│ │ │ │ +
1003
│ │ │ │ +
1004public:
│ │ │ │ +
1005 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ +
1006 static const int grid1Dimension = 3;
│ │ │ │ +
1007 static const int grid2Dimension = 3;
│ │ │ │ +
1008 static const int intersectionDimension = 3;
│ │ │ │ +
1009
│ │ │ │ +
│ │ │ │ +
1010 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ +
1011 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ +
1012 std::vector<std::vector<int> > & SX,
│ │ │ │ +
1013 std::vector<std::vector<int> > & SY,
│ │ │ │ +
1014 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ +
1015 {
│ │ │ │ +
1016 assert(X.size() == 4 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ +
1017 P.clear(); SX.clear(); SY.clear();
│ │ │ │ +
1018
│ │ │ │ +
1019 SX.resize(4);
│ │ │ │ +
1020 SY.resize(4);
│ │ │ │ +
1021
│ │ │ │ +
1022 bool b = false;
│ │ │ │ +
1023 int ci,np,ne,k,ni[4][3];
│ │ │ │ +
1024
│ │ │ │ +
1025 ni[0][0]= 0 ; ni[0][1]= 1 ; ni[0][2]= 2 ; // faces touching each node
│ │ │ │ +
1026 ni[1][0]= 0 ; ni[1][1]= 1 ; ni[1][2]= 3 ;
│ │ │ │ +
1027 ni[2][0]= 0 ; ni[2][1]= 2 ; ni[2][2]= 3 ;
│ │ │ │ +
1028 ni[3][0]= 1 ; ni[3][1]= 2 ; ni[3][2]= 3 ;
│ │ │ │ +
1029
│ │ │ │ +
1030 // temporal data container
│ │ │ │ +
1031 std::vector<FieldVector<T,dimWorld> > surfPts, pci(1);
│ │ │ │ +
1032 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ +
1033
│ │ │ │ +
1034 // check whether the points of the one tetrahedron are contained in the other tetrahedron
│ │ │ │ +
1035 for (ci = 0; ci < 3; ++ci) {
│ │ │ │ +
1036 pci[0] = X[ci];
│ │ │ │ +
1037 // point of X is inside Y
│ │ │ │ + │ │ │ │ +
1039 std::vector<int> indices(surfPts.size());
│ │ │ │ +
1040
│ │ │ │ +
1041 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
1042
│ │ │ │ +
1043 k = insertPoint(X[ci],P);
│ │ │ │ +
1044 indices[np]=k;
│ │ │ │ +
1045 SX[ni[ci][0]].push_back(k); // add face data
│ │ │ │ +
1046 SX[ni[ci][1]].push_back(k);
│ │ │ │ +
1047 SX[ni[ci][2]].push_back(k);
│ │ │ │ +
1048 }
│ │ │ │ +
1049
│ │ │ │ +
1050 // hSY[*] is nonempty if X[ci] is on the face * of Y
│ │ │ │ +
1051 for (ne = 0; ne < 4; ++ne) {
│ │ │ │ +
1052 for (np = 0; np < hSY[ne].size(); ++np) {
│ │ │ │ +
1053 SY[ne].push_back(indices[hSY[ne][np]]);
│ │ │ │ +
1054 }
│ │ │ │ +
1055 }
│ │ │ │ +
1056
│ │ │ │ +
1057 b = true;
│ │ │ │ +
1058 }
│ │ │ │ +
1059 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
1060
│ │ │ │ +
1061 // probably one point of Y is inside X
│ │ │ │ +
1062 surfPts.resize(0);
│ │ │ │ +
1063 pci[0]=Y[ci];
│ │ │ │ + │ │ │ │ +
1065 std::vector<int> indices(surfPts.size());
│ │ │ │ +
1066
│ │ │ │ +
1067 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
1068 k = insertPoint(Y[ci],P);
│ │ │ │ +
1069 indices[np]=k;
│ │ │ │ +
1070 SY[ni[ci][0]].push_back(k); // add face data
│ │ │ │ +
1071 SY[ni[ci][1]].push_back(k);
│ │ │ │ +
1072 SY[ni[ci][2]].push_back(k);
│ │ │ │ +
1073 }
│ │ │ │ +
1074
│ │ │ │ +
1075 // hSX[*] is nonempty if the point Y[ci] is on the face * of X
│ │ │ │ +
1076 for (ne = 0; ne < 4; ++ne) {
│ │ │ │ +
1077 for (np = 0; np < hSX[ne].size(); ++np) {
│ │ │ │ +
1078 SX[ne].push_back(indices[hSX[ne][np]]);
│ │ │ │ +
1079 }
│ │ │ │ +
1080 }
│ │ │ │ +
1081 b = true;
│ │ │ │ +
1082 }
│ │ │ │ +
1083 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
1084 }
│ │ │ │ +
1085
│ │ │ │ +
1086 // check whether the triangles of the one tetrahedron intersect the triangles
│ │ │ │ +
1087 // of the other tetrahedron
│ │ │ │ +
1088 unsigned int faces[4] = {0,3,2,1}; // face ordering
│ │ │ │ +
1089
│ │ │ │ +
1090 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ +
1091 for (ci = 0; ci < 4; ++ci) { // iterate over faces of Y
│ │ │ │ +
1092
│ │ │ │ +
1093 triangle[0] = Y[ci];
│ │ │ │ +
1094 triangle[1] = Y[(ci+1)%4];
│ │ │ │ +
1095 triangle[2] = Y[(ci+2)%4];
│ │ │ │ +
1096
│ │ │ │ +
1097 if(SimplexMethod<dimWorld,3,2,T>::computeIntersectionPoints(X, triangle,hSX,hSY,surfPts)) {
│ │ │ │ +
1098
│ │ │ │ +
1099 // add Triangle of Y intersects tetrahedron Y data
│ │ │ │ +
1100 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
1101 k = insertPoint(surfPts[np],P);
│ │ │ │ +
1102 SY[faces[ci]].push_back(k); // add face data
│ │ │ │ +
1103 }
│ │ │ │ +
1104 b = true;
│ │ │ │ +
1105 }
│ │ │ │ +
1106 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
1107
│ │ │ │ +
1108 triangle[0] = X[ci];
│ │ │ │ +
1109 triangle[1] = X[(ci+1)%4];
│ │ │ │ +
1110 triangle[2] = X[(ci+2)%4];
│ │ │ │ +
1111
│ │ │ │ +
1112 if(SimplexMethod<dimWorld,3,2,T>::computeIntersectionPoints(Y, triangle,hSY,hSX,surfPts)) {
│ │ │ │ +
1113
│ │ │ │ +
1114 // add Triangle of Y intersects tetrahedron Y data
│ │ │ │ +
1115 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ +
1116 k = insertPoint(surfPts[np],P);
│ │ │ │ +
1117 SX[faces[ci]].push_back(k); // add face data
│ │ │ │ +
1118 }
│ │ │ │ +
1119 b = true;
│ │ │ │ +
1120 }
│ │ │ │ +
1121 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ +
1122 }
│ │ │ │ +
1123
│ │ │ │ +
1124 return b;
│ │ │ │ +
1125 }
│ │ │ │ +
│ │ │ │ +
1126
│ │ │ │ +
│ │ │ │ +
1127 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
1128 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1129 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1130 {
│ │ │ │ +
1131 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ +
1132 elementCorners,subElements, faceIds);
│ │ │ │ +
1133 }
│ │ │ │ +
│ │ │ │ +
1134
│ │ │ │ +
│ │ │ │ +
1135 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ +
1136 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1137 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1138 {
│ │ │ │ +
1139 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ +
1140 elementCorners, subElements, faceIds);
│ │ │ │ +
1141 }
│ │ │ │ +
│ │ │ │ +
1142};
│ │ │ │ +
│ │ │ │ +
1143
│ │ │ │ +
1144template <int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
1145inline void simplexSubdivision(std::integral_constant<int,0>,
│ │ │ │ +
1146 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
1147 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1148 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1149{
│ │ │ │ +
1150 subElements.resize(1);
│ │ │ │ +
1151 faceIds.resize(0);
│ │ │ │ +
1152
│ │ │ │ +
1153 subElements[0].push_back(0);
│ │ │ │ +
1154}
│ │ │ │ +
│ │ │ │ +
1155
│ │ │ │ +
1156template <int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
1157inline void simplexSubdivision(std::integral_constant<int,1>,
│ │ │ │ +
1158 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
1159 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1160 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1161{
│ │ │ │ +
1162 subElements.resize(1);
│ │ │ │ +
1163 faceIds.resize(1);
│ │ │ │ +
1164
│ │ │ │ +
1165 subElements[0].push_back(0);
│ │ │ │ +
1166 subElements[0].push_back(1);
│ │ │ │ +
1167
│ │ │ │ +
1168 faceIds[0].push_back(0);
│ │ │ │ +
1169 faceIds[0].push_back(1);
│ │ │ │ +
1170}
│ │ │ │ +
│ │ │ │ +
1171
│ │ │ │ +
1172template <int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
1173inline void simplexSubdivision(std::integral_constant<int,2>,
│ │ │ │ +
1174 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
1175 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1176 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1177{
│ │ │ │ +
1178 subElements.clear();
│ │ │ │ +
1179 faceIds.clear();
│ │ │ │ +
1180
│ │ │ │ +
1181 if (elementCorners.size() == 3) { // triangle
│ │ │ │ +
1182 subElements.resize(1);
│ │ │ │ +
1183 faceIds.resize(1);
│ │ │ │ +
1184
│ │ │ │ +
1185 subElements[0].push_back(0);
│ │ │ │ +
1186 subElements[0].push_back(1);
│ │ │ │ +
1187 subElements[0].push_back(2);
│ │ │ │ +
1188
│ │ │ │ +
1189 faceIds[0].push_back(0);
│ │ │ │ +
1190 faceIds[0].push_back(1);
│ │ │ │ +
1191 faceIds[0].push_back(2);
│ │ │ │ +
1192 } else if (elementCorners.size() == 4) { // quadrilateral => 2 triangles
│ │ │ │ +
1193 subElements.resize(2);
│ │ │ │ +
1194 faceIds.resize(2);
│ │ │ │ +
1195
│ │ │ │ +
1196 subElements[0].push_back(0);
│ │ │ │ +
1197 subElements[0].push_back(1);
│ │ │ │ +
1198 subElements[0].push_back(2);
│ │ │ │ +
1199
│ │ │ │ +
1200 subElements[1].push_back(1);
│ │ │ │ +
1201 subElements[1].push_back(2);
│ │ │ │ +
1202 subElements[1].push_back(3);
│ │ │ │ +
1203
│ │ │ │ +
1204 faceIds[0].push_back(2);
│ │ │ │ +
1205 faceIds[0].push_back(0);
│ │ │ │ +
1206 faceIds[0].push_back(-1);
│ │ │ │ +
1207
│ │ │ │ +
1208 faceIds[1].push_back(-1);
│ │ │ │ +
1209 faceIds[1].push_back(1);
│ │ │ │ +
1210 faceIds[1].push_back(3);
│ │ │ │ +
1211 }
│ │ │ │ +
1212}
│ │ │ │ +
│ │ │ │ +
1213
│ │ │ │ +
1214template <int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
1215inline void simplexSubdivision(std::integral_constant<int,3>,
│ │ │ │ +
1216 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ +
1217 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ +
1218 std::vector<std::vector<int> >& faceIds)
│ │ │ │ +
1219{
│ │ │ │ +
1220 subElements.clear();
│ │ │ │ +
1221 faceIds.clear();
│ │ │ │ +
1222
│ │ │ │ +
1223 if (elementCorners.size() == 4) { // tetrahedron
│ │ │ │ +
1224 subElements.resize(1);
│ │ │ │ +
1225 faceIds.resize(1);
│ │ │ │ +
1226
│ │ │ │ +
1227 subElements[0].push_back(0);
│ │ │ │ +
1228 subElements[0].push_back(1);
│ │ │ │ +
1229 subElements[0].push_back(2);
│ │ │ │ +
1230 subElements[0].push_back(3);
│ │ │ │ +
1231
│ │ │ │ +
1232 faceIds[0].push_back(0);
│ │ │ │ +
1233 faceIds[0].push_back(1);
│ │ │ │ +
1234 faceIds[0].push_back(2);
│ │ │ │ +
1235 faceIds[0].push_back(3);
│ │ │ │ +
1236
│ │ │ │ +
1237 } else if (elementCorners.size() == 8) { // cube => 5 tetrahedra
│ │ │ │ +
1238 subElements.resize(5);
│ │ │ │ +
1239 faceIds.resize(5);
│ │ │ │ +
1240
│ │ │ │ +
1241 subElements[0].push_back(0);
│ │ │ │ +
1242 subElements[0].push_back(2);
│ │ │ │ +
1243 subElements[0].push_back(3);
│ │ │ │ +
1244 subElements[0].push_back(6);
│ │ │ │ +
1245
│ │ │ │ +
1246 subElements[1].push_back(0);
│ │ │ │ +
1247 subElements[1].push_back(1);
│ │ │ │ +
1248 subElements[1].push_back(3);
│ │ │ │ +
1249 subElements[1].push_back(5);
│ │ │ │ +
1250
│ │ │ │ +
1251 subElements[2].push_back(0);
│ │ │ │ +
1252 subElements[2].push_back(3);
│ │ │ │ +
1253 subElements[2].push_back(5);
│ │ │ │ +
1254 subElements[2].push_back(6);
│ │ │ │ +
1255
│ │ │ │ +
1256 subElements[3].push_back(0);
│ │ │ │ +
1257 subElements[3].push_back(4);
│ │ │ │ +
1258 subElements[3].push_back(5);
│ │ │ │ +
1259 subElements[3].push_back(6);
│ │ │ │ +
1260
│ │ │ │ +
1261 subElements[4].push_back(3);
│ │ │ │ +
1262 subElements[4].push_back(5);
│ │ │ │ +
1263 subElements[4].push_back(6);
│ │ │ │ +
1264 subElements[4].push_back(7);
│ │ │ │ +
1265
│ │ │ │ +
1266 faceIds[0].push_back(4);
│ │ │ │ +
1267 faceIds[0].push_back(0);
│ │ │ │ +
1268 faceIds[0].push_back(-1);
│ │ │ │ +
1269 faceIds[0].push_back(3);
│ │ │ │ +
1270
│ │ │ │ +
1271 faceIds[1].push_back(4);
│ │ │ │ +
1272 faceIds[1].push_back(2);
│ │ │ │ +
1273 faceIds[1].push_back(-1);
│ │ │ │ +
1274 faceIds[1].push_back(1);
│ │ │ │ +
1275
│ │ │ │ +
1276 faceIds[2].push_back(-1);
│ │ │ │ +
1277 faceIds[2].push_back(-1);
│ │ │ │ +
1278 faceIds[2].push_back(-1);
│ │ │ │ +
1279 faceIds[2].push_back(-1);
│ │ │ │ +
1280
│ │ │ │ +
1281 faceIds[3].push_back(2);
│ │ │ │ +
1282 faceIds[3].push_back(0);
│ │ │ │ +
1283 faceIds[3].push_back(-1);
│ │ │ │ +
1284 faceIds[3].push_back(5);
│ │ │ │ +
1285
│ │ │ │ +
1286 faceIds[4].push_back(-1);
│ │ │ │ +
1287 faceIds[4].push_back(1);
│ │ │ │ +
1288 faceIds[4].push_back(3);
│ │ │ │ +
1289 faceIds[4].push_back(5);
│ │ │ │ +
1290 }
│ │ │ │ +
1291}
│ │ │ │ +
│ │ │ │ +
1292
│ │ │ │ +
1293} /* namespace Dune::GridGlue */
│ │ │ │ +
1294} /* namespace Dune */
│ │ │ │
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
│ │ │ │ -
Coordinate corner(unsigned c)
Definition projection_impl.hh:24
│ │ │ │ -
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
│ │ │ │ -
void removeDoubles(std::vector< std::array< LocalCoords, 2 > > &polytopeCorners)
Remove all multiples.
Definition contactmerge.cc:335
│ │ │ │ -
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 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::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition contactmerge.hh:62
│ │ │ │ +
int insertPoint(const V p, std::vector< V > &P)
Definition computeintersection.hh:164
│ │ │ │ +
void 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)
Definition simplexintersection.cc:1145
│ │ │ │ +
Definition computeintersection.hh:13
│ │ │ │ +
Definition simplexintersection.cc:30
│ │ │ │ +
static const int grid1Dimension
Definition simplexintersection.cc:35
│ │ │ │ +
static const int grid2Dimension
Definition simplexintersection.cc:36
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:34
│ │ │ │ +
static const int intersectionDimension
Definition simplexintersection.cc:37
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:39
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:48
│ │ │ │ +
static void grid2_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:56
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:104
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:78
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:73
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:181
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:129
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:134
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:206
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:211
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:262
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:291
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:286
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:332
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:360
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:542
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:355
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:570
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:684
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:565
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:779
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:712
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:707
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:802
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:875
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:807
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:903
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:983
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:898
│ │ │ │ +
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:1127
│ │ │ │ +
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:1010
│ │ │ │ +
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:1005
│ │ │ │ +
static void grid2_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:1135
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,439 +1,1578 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -contactmerge.cc │ │ │ │ │ +simplexintersection.cc │ │ │ │ │ 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 │ │ │ │ │ -6#include │ │ │ │ │ -7#include │ │ │ │ │ +6namespace Dune { │ │ │ │ │ +7namespace GridGlue { │ │ │ │ │ 8 │ │ │ │ │ -9namespace Dune { │ │ │ │ │ -10namespace GridGlue { │ │ │ │ │ -11 │ │ │ │ │ -12template │ │ │ │ │ -13void ContactMerge::computeIntersections(const Dune:: │ │ │ │ │ -GeometryType& grid1ElementType, │ │ │ │ │ -14 const std::vector >& grid1ElementCorners, │ │ │ │ │ -15 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -16 unsigned int grid1Index, │ │ │ │ │ -17 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ -18 const std::vector >& grid2ElementCorners, │ │ │ │ │ -19 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -20 unsigned int grid2Index, │ │ │ │ │ -21 std::vector& intersections) │ │ │ │ │ -22{ │ │ │ │ │ -23 using std::get; │ │ │ │ │ -24 │ │ │ │ │ -25 std::vector > polytopeCorners; │ │ │ │ │ +9template │ │ │ │ │ +10inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ +vector >& elementCorners, │ │ │ │ │ +11 std::vector >& subElements, │ │ │ │ │ +12 std::vector >& faceIds); │ │ │ │ │ +13template │ │ │ │ │ +14inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ +vector >& elementCorners, │ │ │ │ │ +15 std::vector >& subElements, │ │ │ │ │ +16 std::vector >& faceIds); │ │ │ │ │ +17template │ │ │ │ │ +18inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ +vector >& elementCorners, │ │ │ │ │ +19 std::vector >& subElements, │ │ │ │ │ +20 std::vector >& faceIds); │ │ │ │ │ +21template │ │ │ │ │ +22inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ +vector >& elementCorners, │ │ │ │ │ +23 std::vector >& subElements, │ │ │ │ │ +24 std::vector >& faceIds); │ │ │ │ │ +25 │ │ │ │ │ 26 │ │ │ │ │ -27 // Initialize │ │ │ │ │ -28 neighborIntersects1.reset(); │ │ │ │ │ -29 neighborIntersects2.reset(); │ │ │ │ │ -30 │ │ │ │ │ -31 const int nCorners1 = grid1ElementCorners.size(); │ │ │ │ │ -32 const int nCorners2 = grid2ElementCorners.size(); │ │ │ │ │ -33 │ │ │ │ │ -34 if (nCorners1 != dimworld) │ │ │ │ │ -35 DUNE_THROW(Dune::Exception, "element1 must have " << dimworld << " corners, │ │ │ │ │ -but has " << nCorners1); │ │ │ │ │ -36 if (nCorners2 != dimworld) │ │ │ │ │ -37 DUNE_THROW(Dune::Exception, "element2 must have " << dimworld << " corners, │ │ │ │ │ -but has " << nCorners2); │ │ │ │ │ +27 │ │ │ │ │ +28// *****************SIMPLEX INTERSECTION COMPUTATION METHODS │ │ │ │ │ +*************************** │ │ │ │ │ +29template │ │ │ │ │ +30class SimplexMethod : public ComputationMethod{ │ │ │ │ │ +31 static_assert(dim1 > dim2, "Specialization missing"); │ │ │ │ │ +32 friend class ComputationMethod; │ │ │ │ │ +33public: │ │ │ │ │ +34 typedef FieldVector Vector; │ │ │ │ │ +35 static const int grid1Dimension = dim1; │ │ │ │ │ +36 static const int grid2Dimension = dim2; │ │ │ │ │ +37 static const int intersectionDimension = dim2; │ │ │ │ │ 38 │ │ │ │ │ -39 // The grid1 projection directions │ │ │ │ │ -40 std::vector directions1(nCorners1); │ │ │ │ │ -41 for (size_t i=0; igrid1ElementCorners_ │ │ │ │ │ -[grid1Index][i]]; │ │ │ │ │ -43 │ │ │ │ │ -44 // The grid2 projection directions │ │ │ │ │ -45 std::vector directions2(nCorners2); │ │ │ │ │ -46 for (size_t i=0; igrid2ElementCorners_ │ │ │ │ │ -[grid2Index][i]]; │ │ │ │ │ -48 │ │ │ │ │ -49 // The difference between the closest point projection and the normal │ │ │ │ │ -projection is just the ordering │ │ │ │ │ -50 // of the involved surfaces. The closest point projection is done along the │ │ │ │ │ -outer normal field of grid2 │ │ │ │ │ -51 // (due to being a best approximation) and the outer normal projection is │ │ │ │ │ -using the outer normal field │ │ │ │ │ -52 // of grid1 instead. │ │ │ │ │ -53 std::array cornersRef ={std:: │ │ │ │ │ -cref(grid1ElementCorners), std::cref(grid2ElementCorners)}; │ │ │ │ │ -54 std::array directionsRef ={std::cref │ │ │ │ │ -(directions1), std::cref(directions2)}; │ │ │ │ │ -55 std::array elementTypes = {grid1ElementType, │ │ │ │ │ -grid2ElementType}; │ │ │ │ │ -56 │ │ │ │ │ -57 // Determine which is the grid we use for outer normal projection │ │ │ │ │ -58 const size_t domGrid = (type_==ProjectionType::OUTER_NORMAL) ? 0 : 1; │ │ │ │ │ -59 const size_t tarGrid = (type_==ProjectionType::OUTER_NORMAL) ? 1 : 0; │ │ │ │ │ -60 │ │ │ │ │ -62 // Compute all corners of the intersection polytope │ │ │ │ │ +39 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +40 const std::vector >& Y, │ │ │ │ │ +41 std::vector > & SX, │ │ │ │ │ +42 std::vector > & SY, │ │ │ │ │ +43 std::vector > & P) │ │ │ │ │ +44 { │ │ │ │ │ +45 return SimplexMethod::computeIntersectionPoints(Y, X, │ │ │ │ │ +SY, SX, P); │ │ │ │ │ +46 } │ │ │ │ │ +47 │ │ │ │ │ +48 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +49 std::vector >& subElements, │ │ │ │ │ +50 std::vector >& faceIds) │ │ │ │ │ +51 { │ │ │ │ │ +52 simplexSubdivision(std::integral_constant(), │ │ │ │ │ +53 elementCorners,subElements, faceIds); │ │ │ │ │ +54 } │ │ │ │ │ +55 │ │ │ │ │ +56 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +57 std::vector >& subElements, │ │ │ │ │ +58 std::vector >& faceIds) │ │ │ │ │ +59 { │ │ │ │ │ +60 simplexSubdivision(std::integral_constant(), │ │ │ │ │ +61 elementCorners, subElements, faceIds); │ │ │ │ │ +62 } │ │ │ │ │ +63}; │ │ │ │ │ 64 │ │ │ │ │ -65 const auto corners = std::tie(cornersRef[domGrid].get(),cornersRef │ │ │ │ │ -[tarGrid].get()); │ │ │ │ │ -66 const auto normals = std::tie(directionsRef[domGrid].get(), directionsRef │ │ │ │ │ -[tarGrid].get()); │ │ │ │ │ -67 Projection p(overlap_, maxNormalProduct_); │ │ │ │ │ -68 p.project(corners, normals); │ │ │ │ │ -69 │ │ │ │ │ -70 /* projection */ │ │ │ │ │ -71 { │ │ │ │ │ -72 const auto& success = get<0>(p.success()); │ │ │ │ │ -73 const auto& images = get<0>(p.images()); │ │ │ │ │ -74 for (unsigned i = 0; i < dimworld; ++i) { │ │ │ │ │ -75 if (success[i]) { │ │ │ │ │ -76 std::array corner; │ │ │ │ │ -77 corner[domGrid] = localCornerCoords(i, elementTypes[domGrid]); │ │ │ │ │ -78 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ -79 corner[tarGrid][j] = images[i][j]; │ │ │ │ │ -80 polytopeCorners.push_back(corner); │ │ │ │ │ -81 } │ │ │ │ │ -82 } │ │ │ │ │ -83 } │ │ │ │ │ -84 │ │ │ │ │ -85 /* inverse projection */ │ │ │ │ │ -86 { │ │ │ │ │ -87 const auto& success = get<1>(p.success()); │ │ │ │ │ -88 const auto& preimages = get<1>(p.images()); │ │ │ │ │ -89 for (unsigned i = 0; i < dimworld; ++i) { │ │ │ │ │ -90 if (success[i]) { │ │ │ │ │ -91 std::array corner; │ │ │ │ │ -92 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ -93 corner[domGrid][j] = preimages[i][j]; │ │ │ │ │ -94 corner[tarGrid] = localCornerCoords(i, elementTypes[tarGrid]); │ │ │ │ │ -95 polytopeCorners.push_back(corner); │ │ │ │ │ -96 } │ │ │ │ │ -97 } │ │ │ │ │ -98 } │ │ │ │ │ -99 │ │ │ │ │ -100 /* edge intersections */ │ │ │ │ │ -101 { │ │ │ │ │ -102 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ -103 std::array corner; │ │ │ │ │ -104 const auto& local = p.edgeIntersections()[i].local; │ │ │ │ │ -105 for (unsigned j = 0; j < dim; ++j) { │ │ │ │ │ -106 corner[domGrid][j] = local[0][j]; │ │ │ │ │ -107 corner[tarGrid][j] = local[1][j]; │ │ │ │ │ -108 } │ │ │ │ │ -109 polytopeCorners.push_back(corner); │ │ │ │ │ +65 │ │ │ │ │ +66 │ │ │ │ │ +67// POINTS ARE EQUAL │ │ │ │ │ +68template │ │ │ │ │ +69class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +70 friend class ComputationMethod; │ │ │ │ │ +71 │ │ │ │ │ +72public: │ │ │ │ │ +73 typedef FieldVector Vector; │ │ │ │ │ +74 static const int grid1Dimension = 0; │ │ │ │ │ +75 static const int grid2Dimension = 0; │ │ │ │ │ +76 static const int intersectionDimension = 0; │ │ │ │ │ +77 │ │ │ │ │ +78 static bool computeIntersectionPoints( │ │ │ │ │ +79 const std::vector >& X, │ │ │ │ │ +80 const std::vector >& Y, │ │ │ │ │ +81 std::vector > & SX, │ │ │ │ │ +82 std::vector > & SY, │ │ │ │ │ +83 std::vector > & P) │ │ │ │ │ +84 { │ │ │ │ │ +85 assert(X.size() == 1 && Y.size() == 1); │ │ │ │ │ +86 │ │ │ │ │ +87 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +88 int k; │ │ │ │ │ +89 │ │ │ │ │ +90 T eps = 1e-8; │ │ │ │ │ +91 T a = X[0].infinity_norm(); │ │ │ │ │ +92 T b = Y[0].infinity_norm(); │ │ │ │ │ +93 T c = (X[0] - Y[0]).infinity_norm(); │ │ │ │ │ +94 │ │ │ │ │ +95 if (c <= eps*a || c <= eps*b || │ │ │ │ │ +96 (a& elementCorners, │ │ │ │ │ +105 std::vector >& subElements, │ │ │ │ │ +106 std::vector >& faceIds) │ │ │ │ │ +107 { │ │ │ │ │ +108 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +109 elementCorners,subElements, faceIds); │ │ │ │ │ 110 } │ │ │ │ │ -111 } │ │ │ │ │ -112 │ │ │ │ │ -113 // check which neighbors might also intersect │ │ │ │ │ -114 std::array neighborIntersectsRef │ │ │ │ │ -= {std::ref(neighborIntersects1), std::ref(neighborIntersects2)}; │ │ │ │ │ -115 const auto& refTar = Dune::ReferenceElements::general(elementTypes │ │ │ │ │ -[tarGrid]); │ │ │ │ │ -116 for (int i=0; i(p.success())[refTar.subEntity(i,1,k,dim)]; │ │ │ │ │ -124 │ │ │ │ │ -125 if (intersects) │ │ │ │ │ -126 neighborIntersectsRef[tarGrid].get()[i] = true; │ │ │ │ │ -127 } │ │ │ │ │ -128 │ │ │ │ │ -129 const auto& refDom = Dune::ReferenceElements::general(elementTypes │ │ │ │ │ -[domGrid]); │ │ │ │ │ -130 for (int i=0; i(p.success())[refDom.subEntity(i,1,k,dim)]; │ │ │ │ │ -138 │ │ │ │ │ -139 if (intersects) │ │ │ │ │ -140 neighborIntersectsRef[domGrid].get()[i] = true; │ │ │ │ │ -141 } │ │ │ │ │ -142 │ │ │ │ │ -143 // Compute the edge intersections │ │ │ │ │ -144 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ -145 const auto& edge = p.edgeIntersections()[i].edge; │ │ │ │ │ -146 neighborIntersects1[edge[domGrid]] = true; │ │ │ │ │ -147 neighborIntersects2[edge[tarGrid]] = true; │ │ │ │ │ -148 } │ │ │ │ │ -149 │ │ │ │ │ -150 // remove possible doubles │ │ │ │ │ -151 removeDoubles(polytopeCorners); │ │ │ │ │ -152 │ │ │ │ │ -153 // Compute an interior point of the polytope │ │ │ │ │ -154 int nPolyCorners = polytopeCorners.size(); │ │ │ │ │ -155 │ │ │ │ │ -156 // If the polytope is degenerated then there is no intersection │ │ │ │ │ -157 if (nPolyCorners=3 │ │ │ │ │ -176 │ │ │ │ │ -178 // Compute a point in the middle of the polytope and order all corners │ │ │ │ │ -cyclic │ │ │ │ │ +111 │ │ │ │ │ +112 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +113 std::vector >& subElements, │ │ │ │ │ +114 std::vector >& faceIds) │ │ │ │ │ +115 { │ │ │ │ │ +116 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +117 elementCorners, subElements, faceIds); │ │ │ │ │ +118 } │ │ │ │ │ +119 │ │ │ │ │ +120}; │ │ │ │ │ +121 │ │ │ │ │ +122 │ │ │ │ │ +123// POINT ON LINE SEGMENT - :) │ │ │ │ │ +124template │ │ │ │ │ +125class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +126 friend class ComputationMethod; │ │ │ │ │ +127 │ │ │ │ │ +128public: │ │ │ │ │ +129 typedef FieldVector Vector; │ │ │ │ │ +130 static const int grid1Dimension = 0; │ │ │ │ │ +131 static const int grid2Dimension = 1; │ │ │ │ │ +132 static const int intersectionDimension = 0; │ │ │ │ │ +133 │ │ │ │ │ +134 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +135 const std::vector >& Y, │ │ │ │ │ +136 std::vector > & SX, │ │ │ │ │ +137 std::vector > & SY, │ │ │ │ │ +138 std::vector > & P) │ │ │ │ │ +139 { │ │ │ │ │ +140 assert(X.size() == 1 && Y.size() == 2); │ │ │ │ │ +141 │ │ │ │ │ +142 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +143 SY.resize(2); │ │ │ │ │ +144 │ │ │ │ │ +145 if (dimWorld == 1) { │ │ │ │ │ +146 T lowerBound = std::max(X[0][0], std::min(Y[0][0],Y[1][0])); │ │ │ │ │ +147 T upperBound = std::min(X[0][0], std::max(Y[0][0],Y[1][0])); │ │ │ │ │ +148 │ │ │ │ │ +149 if (lowerBound <= upperBound) { // Intersection is non-empty │ │ │ │ │ +150 insertPoint(X[0],P); │ │ │ │ │ +151 return true; │ │ │ │ │ +152 } │ │ │ │ │ +153 } else { │ │ │ │ │ +154 │ │ │ │ │ +155 T eps = 1e-8; │ │ │ │ │ +156 │ │ │ │ │ +157 // check whether the point is on the segment │ │ │ │ │ +158 FieldVector v0 = X[0] - Y[0]; │ │ │ │ │ +159 FieldVector v1 = X[0] - Y[1]; │ │ │ │ │ +160 FieldVector v2 = Y[1] - Y[0]; │ │ │ │ │ +161 │ │ │ │ │ +162 T s = v0.dot(v1); │ │ │ │ │ +163 T t = v0.two_norm()/v2.two_norm(); │ │ │ │ │ +164 v2*=t; │ │ │ │ │ +165 v2+=Y[0]; │ │ │ │ │ +166 v2-=X[0]; │ │ │ │ │ +167 │ │ │ │ │ +168 if (v2.infinity_norm() < eps && s<=eps && t<=1+eps) { │ │ │ │ │ +169 │ │ │ │ │ +170 int k = insertPoint(X[0],P); │ │ │ │ │ +171 if (s < eps && t < eps) │ │ │ │ │ +172 SY[0].push_back(k); │ │ │ │ │ +173 else if (s < eps && t>1-eps) │ │ │ │ │ +174 SY[1].push_back(k); │ │ │ │ │ +175 return true; │ │ │ │ │ +176 } │ │ │ │ │ +177 } │ │ │ │ │ +178 return false; │ │ │ │ │ +179 } │ │ │ │ │ 180 │ │ │ │ │ -181 std::array center; │ │ │ │ │ -182 center[0] = 0; center[1] = 0; │ │ │ │ │ -183 for (int i=0; i ordering; │ │ │ │ │ -190 computeCyclicOrder(polytopeCorners,center[0],ordering); │ │ │ │ │ -191 │ │ │ │ │ -193 // Add intersections │ │ │ │ │ -195 │ │ │ │ │ -196 for (size_t i=1; i& elementCorners, │ │ │ │ │ +182 std::vector >& subElements, │ │ │ │ │ +183 std::vector >& faceIds) │ │ │ │ │ +184 { │ │ │ │ │ +185 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +186 elementCorners,subElements, faceIds); │ │ │ │ │ +187 } │ │ │ │ │ +188 │ │ │ │ │ +189 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +190 std::vector >& subElements, │ │ │ │ │ +191 std::vector >& faceIds) │ │ │ │ │ +192 { │ │ │ │ │ +193 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +194 elementCorners, subElements, faceIds); │ │ │ │ │ +195 } │ │ │ │ │ +196 │ │ │ │ │ +197}; │ │ │ │ │ +198 │ │ │ │ │ 199 │ │ │ │ │ -200 for (int j=0;j │ │ │ │ │ +202class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +203 friend class ComputationMethod; │ │ │ │ │ 204 │ │ │ │ │ -205 // last corner is the first for all intersections │ │ │ │ │ -206 intersect.corners0[0][dim]=polytopeCorners[ordering[0]][0]; │ │ │ │ │ -207 intersect.corners1[0][dim]=polytopeCorners[ordering[0]][1]; │ │ │ │ │ -208 │ │ │ │ │ -209 intersections.push_back(intersect); │ │ │ │ │ -210 } │ │ │ │ │ -211} │ │ │ │ │ -212 │ │ │ │ │ -213template │ │ │ │ │ -214void ContactMerge::computeCyclicOrder(const std::vector >& polytopeCorners, │ │ │ │ │ -215 const LocalCoords& center, std::vector& ordering) const │ │ │ │ │ -216{ │ │ │ │ │ -217 ordering.resize(polytopeCorners.size()); │ │ │ │ │ +205public: │ │ │ │ │ +206 typedef FieldVector Vector; │ │ │ │ │ +207 static const int grid1Dimension = 0; │ │ │ │ │ +208 static const int grid2Dimension = 2; │ │ │ │ │ +209 static const int intersectionDimension = 0; │ │ │ │ │ +210 │ │ │ │ │ +211 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +212 const std::vector >& Y, │ │ │ │ │ +213 std::vector > & SX, │ │ │ │ │ +214 std::vector > & SY, │ │ │ │ │ +215 std::vector > & P) │ │ │ │ │ +216 { │ │ │ │ │ +217 assert(X.size() == 1 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ 218 │ │ │ │ │ -219 for (size_t k=0; k angles(polytopeCorners.size()); │ │ │ │ │ -236 │ │ │ │ │ -237 for (size_t i=0; i v0,v1,v2,r; │ │ │ │ │ +227 │ │ │ │ │ +228 v0 = Y[1] - Y[0]; │ │ │ │ │ +229 v1 = Y[2] - Y[0]; │ │ │ │ │ +230 v2 = X[0] - Y[0]; │ │ │ │ │ +231 │ │ │ │ │ +232 T s,t,d; │ │ │ │ │ +233 │ │ │ │ │ +234 d = ((v0.dot(v0))*(v1.dot(v1)) - (v0.dot(v1))*(v0.dot(v1))); │ │ │ │ │ +235 │ │ │ │ │ +236 s = ((v1.dot(v1))*(v0.dot(v2)) - (v0.dot(v1))*(v1.dot(v2))) / d; │ │ │ │ │ +237 t = ((v0.dot(v0))*(v1.dot(v2)) - (v0.dot(v1))*(v0.dot(v2))) / d; │ │ │ │ │ 238 │ │ │ │ │ -239 LocalCoords edge = polytopeCorners[i][0] - center; │ │ │ │ │ -240 │ │ │ │ │ -241 T x(edge*edge0); │ │ │ │ │ -242 T y(edge*normal0); │ │ │ │ │ -243 │ │ │ │ │ -244 angles[i] = std::atan2(y, x); │ │ │ │ │ -245 if (angles[i]<0) │ │ │ │ │ -246 angles[i] += 2*M_PI; │ │ │ │ │ -247 } │ │ │ │ │ -248 │ │ │ │ │ -249 // bubblesort │ │ │ │ │ -250 │ │ │ │ │ -251 for (int i=polytopeCorners.size(); i>1; i--){ │ │ │ │ │ -252 bool swapped = false; │ │ │ │ │ -253 │ │ │ │ │ -254 for (int j=0; j -eps && t > -eps && (s+t)< 1+eps && (r-X[0]).infinity_norm() < eps) │ │ │ │ │ +{ │ │ │ │ │ +244 k = insertPoint(X[0],P); │ │ │ │ │ +245 │ │ │ │ │ +246 if (t < eps) { // t ~ 0, s varies -> edge 0 │ │ │ │ │ +247 SY[0].push_back(k); │ │ │ │ │ +248 } │ │ │ │ │ +249 if (s < eps) { // s ~ 0, t varies -> edge 1 │ │ │ │ │ +250 SY[1].push_back(k); │ │ │ │ │ +251 } │ │ │ │ │ +252 if (s+t > 1-eps) { // s+t ~ 1 -> edge 2 │ │ │ │ │ +253 SY[2].push_back(k); │ │ │ │ │ +254 } │ │ │ │ │ 255 │ │ │ │ │ -256 if (angles[j] > angles[j+1]){ │ │ │ │ │ -257 swapped = true; │ │ │ │ │ -258 std::swap(angles[j], angles[j+1]); │ │ │ │ │ -259 std::swap(ordering[j], ordering[j+1]); │ │ │ │ │ +256 return true; │ │ │ │ │ +257 } │ │ │ │ │ +258 │ │ │ │ │ +259 return false; │ │ │ │ │ 260 } │ │ │ │ │ -261 } │ │ │ │ │ -262 │ │ │ │ │ -263 if (!swapped) │ │ │ │ │ -264 break; │ │ │ │ │ -265 } │ │ │ │ │ -266} │ │ │ │ │ -267 │ │ │ │ │ -268template │ │ │ │ │ -269void ContactMerge::setupNodalDirections(const std:: │ │ │ │ │ -vector& coords1, │ │ │ │ │ -270 const std::vector& elements1, │ │ │ │ │ -271 const std::vector& elementTypes1, │ │ │ │ │ -272 const std::vector& coords2, │ │ │ │ │ -273 const std::vector& elements2, │ │ │ │ │ -274 const std::vector& elementTypes2) │ │ │ │ │ -275{ │ │ │ │ │ -276 if (domainDirections_) { │ │ │ │ │ -277 │ │ │ │ │ -278 // Sample the provided analytical contact direction field │ │ │ │ │ -279 nodalDomainDirections_.resize(coords1.size()); │ │ │ │ │ -280 for (size_t i=0; i& elementCorners, │ │ │ │ │ +263 std::vector >& subElements, │ │ │ │ │ +264 std::vector >& faceIds) │ │ │ │ │ +265 { │ │ │ │ │ +266 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +267 elementCorners,subElements, faceIds); │ │ │ │ │ +268 } │ │ │ │ │ +269 │ │ │ │ │ +270 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +271 std::vector >& subElements, │ │ │ │ │ +272 std::vector >& faceIds) │ │ │ │ │ +273 { │ │ │ │ │ +274 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +275 elementCorners, subElements, faceIds); │ │ │ │ │ +276 } │ │ │ │ │ +277}; │ │ │ │ │ +278 │ │ │ │ │ +279 │ │ │ │ │ +280// POINT IN TETRAHEDRON - : ) │ │ │ │ │ +281template │ │ │ │ │ +282class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +283 friend class ComputationMethod; │ │ │ │ │ 284 │ │ │ │ │ -285 if (targetDirections_) { │ │ │ │ │ -286 │ │ │ │ │ -287 // Sample the provided analytical target direction field │ │ │ │ │ -288 nodalTargetDirections_.resize(coords2.size()); │ │ │ │ │ -289 for (size_t i=0; i │ │ │ │ │ -296void ContactMerge::computeOuterNormalField(const std:: │ │ │ │ │ -vector& coords, │ │ │ │ │ -297 const std::vector& elements, │ │ │ │ │ -298 const std::vector& elementTypes, │ │ │ │ │ -299 std::vector& normals) │ │ │ │ │ -300{ │ │ │ │ │ -301 normals.assign(coords.size(),WorldCoords(0)); │ │ │ │ │ -302 │ │ │ │ │ -303 │ │ │ │ │ -304 int offset = 0; │ │ │ │ │ +285public: │ │ │ │ │ +286 typedef FieldVector Vector; │ │ │ │ │ +287 static const int grid1Dimension = 0; │ │ │ │ │ +288 static const int grid2Dimension = 3; │ │ │ │ │ +289 static const int intersectionDimension = 0; │ │ │ │ │ +290 │ │ │ │ │ +291 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +292 const std::vector >& Y, │ │ │ │ │ +293 std::vector > & SX, │ │ │ │ │ +294 std::vector > & SY, │ │ │ │ │ +295 std::vector > & P) │ │ │ │ │ +296 { │ │ │ │ │ +297 assert(X.size() == 1 && Y.size() == 4 && dimWorld == 3); │ │ │ │ │ +298 │ │ │ │ │ +299 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +300 SY.resize(4); │ │ │ │ │ +301 │ │ │ │ │ +302 T eps = 1e-8; │ │ │ │ │ +303 // if not, check whether its inside the tetrahedron │ │ │ │ │ +304 FieldMatrix D,DD ; │ │ │ │ │ 305 │ │ │ │ │ -306 for (size_t i=0; i::general(elementTypes │ │ │ │ │ -[i]).size(dim); │ │ │ │ │ -309 │ │ │ │ │ -310 // For segments 1, for triangles or quadrilaterals take the first 2 │ │ │ │ │ -311 std::array edges; │ │ │ │ │ -312 for (int j=1; j<=dim; j++) │ │ │ │ │ -313 edges[j-1] = coords[elements[offset + j]] - coords[elements[offset]]; │ │ │ │ │ -314 │ │ │ │ │ -315 WorldCoords elementNormal; │ │ │ │ │ -316 │ │ │ │ │ -317 if (dim==1) { │ │ │ │ │ -318 elementNormal[0] = edges[0][1]; elementNormal[1] = -edges[0][0]; │ │ │ │ │ -319 } else │ │ │ │ │ -320 elementNormal = crossProduct(edges[0], edges[1]); │ │ │ │ │ -321 │ │ │ │ │ -322 elementNormal /= elementNormal.two_norm(); │ │ │ │ │ -323 │ │ │ │ │ -324 for (int j=0; j │ │ │ │ │ -335void ContactMerge::removeDoubles(std::vector >& polytopeCorners) │ │ │ │ │ -336{ │ │ │ │ │ -337 │ │ │ │ │ -338 size_t counter(1); │ │ │ │ │ -339 for (size_t i=1; i detD; │ │ │ │ │ +312 detD[0] = D.determinant(); │ │ │ │ │ +313 │ │ │ │ │ +314 for(unsigned i = 1; i < detD.size(); ++i) { │ │ │ │ │ +315 DD = D; │ │ │ │ │ +316 for (unsigned d = 0; d < dimWorld; ++d) │ │ │ │ │ +317 DD[d][i-1] = X[0][d]; │ │ │ │ │ +318 detD[i] = DD.determinant(); │ │ │ │ │ +319 if (std::abs(detD[i]) > eps && std::signbit(detD[0]) != std::signbit(detD │ │ │ │ │ +[i])) │ │ │ │ │ +320 return false; // We are outside. │ │ │ │ │ +321 } │ │ │ │ │ +322 │ │ │ │ │ +323 int k = insertPoint(X[0],P); │ │ │ │ │ +324 unsigned int faces[4] = {3,2,1,0}; │ │ │ │ │ +325 for (unsigned i = 1; i < detD.size(); ++i) │ │ │ │ │ +326 if(std::abs(detD[i]) < eps) │ │ │ │ │ +327 SY[faces[i-1]].push_back(k); // on triangle not containing node i-1 │ │ │ │ │ +328 │ │ │ │ │ +329 return true; │ │ │ │ │ +330 } │ │ │ │ │ +331 │ │ │ │ │ +332 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +333 std::vector >& subElements, │ │ │ │ │ +334 std::vector >& faceIds) │ │ │ │ │ +335 { │ │ │ │ │ +336 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +337 elementCorners,subElements, faceIds); │ │ │ │ │ +338 } │ │ │ │ │ +339 │ │ │ │ │ +340 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +341 std::vector >& subElements, │ │ │ │ │ +342 std::vector >& faceIds) │ │ │ │ │ +343 { │ │ │ │ │ +344 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +345 elementCorners, subElements, faceIds); │ │ │ │ │ 346 } │ │ │ │ │ -347 │ │ │ │ │ -348 if (!contained) { │ │ │ │ │ -349 if (counter < i) │ │ │ │ │ -350 polytopeCorners[counter] = polytopeCorners[i]; │ │ │ │ │ -351 counter++; │ │ │ │ │ -352 } │ │ │ │ │ -353 } │ │ │ │ │ -354 polytopeCorners.resize(counter); │ │ │ │ │ -355} │ │ │ │ │ -356 │ │ │ │ │ -357} /* namespace GridGlue */ │ │ │ │ │ -358} /* namespace Dune */ │ │ │ │ │ -projection.hh │ │ │ │ │ -crossproduct.hh │ │ │ │ │ +347}; │ │ │ │ │ +348 │ │ │ │ │ +349// SEGEMENT-SEGMENT INTERSECTION - :) │ │ │ │ │ +350template │ │ │ │ │ +351class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +352 friend class ComputationMethod; │ │ │ │ │ +353 │ │ │ │ │ +354public: │ │ │ │ │ +355 typedef FieldVector Vector; │ │ │ │ │ +356 static const int grid1Dimension = 1; │ │ │ │ │ +357 static const int grid2Dimension = 1; │ │ │ │ │ +358 static const int intersectionDimension = 1; │ │ │ │ │ +359 │ │ │ │ │ +360 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +361 const std::vector >& Y, │ │ │ │ │ +362 std::vector > & SX, │ │ │ │ │ +363 std::vector > & SY, │ │ │ │ │ +364 std::vector > & P) │ │ │ │ │ +365 { │ │ │ │ │ +366 assert(X.size() == 2 && Y.size() == 2); │ │ │ │ │ +367 │ │ │ │ │ +368 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +369 SX.resize(2); │ │ │ │ │ +370 SY.resize(2); │ │ │ │ │ +371 T eps = 1e-8; │ │ │ │ │ +372 int k,idX_min=-1,idX_max=-1,idY_min=-1,idY_max=-1; │ │ │ │ │ +373 │ │ │ │ │ +374 // compute intersections │ │ │ │ │ +375 switch (dimWorld) { │ │ │ │ │ +376 case 1: // d │ │ │ │ │ +377 { │ │ │ │ │ +378 FieldVector lowerbound(std::max(std::min(X[0][0],X[1][0]), │ │ │ │ │ +std::min(Y[0][0],X[1][0]))); │ │ │ │ │ +379 FieldVector upperbound(std::min(std::max(X[0][0],X[1][0]), │ │ │ │ │ +std::max(Y[0][0],Y[1][0]))); │ │ │ │ │ +380 │ │ │ │ │ +381 if (lowerbound[0] < upperbound[0]) { // Intersection is non-empty │ │ │ │ │ +382 │ │ │ │ │ +383 idX_min = (std::min(X[0][0],X[1][0]) < std::min(Y[0][0],Y[1][0]))?(-1):((X │ │ │ │ │ +[0][0] std::max(Y[0][0],Y[1][0]))?(-1):((X │ │ │ │ │ +[0][0]>X[1][0])?(0):(1)); │ │ │ │ │ +388 if (idX_max < 0) │ │ │ │ │ +389 idY_max = ((Y[0][0]>Y[1][0])?(0):(1)); │ │ │ │ │ +390 │ │ │ │ │ +391 k = insertPoint(lowerbound,P); │ │ │ │ │ +392 if (idX_min >= 0) │ │ │ │ │ +393 SX[idX_min].push_back(k); │ │ │ │ │ +394 else │ │ │ │ │ +395 SY[idY_min].push_back(k); │ │ │ │ │ +396 │ │ │ │ │ +397 k = insertPoint(upperbound,P); │ │ │ │ │ +398 if (idX_max >= 0) │ │ │ │ │ +399 SX[idX_max].push_back(k); │ │ │ │ │ +400 else │ │ │ │ │ +401 SY[idY_max].push_back(k); │ │ │ │ │ +402 │ │ │ │ │ +403 return true; │ │ │ │ │ +404 } │ │ │ │ │ +405 return false; │ │ │ │ │ +406 } │ │ │ │ │ +407 case 2: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0) │ │ │ │ │ +408 { // get size_type for all the vectors we are using │ │ │ │ │ +409 │ │ │ │ │ +410 FieldMatrix A; │ │ │ │ │ +411 A[0][0] = X[1][0] - X[0][0]; A[0][1] = Y[0][0] - Y[1][0]; │ │ │ │ │ +412 A[1][0] = X[1][1] - X[0][1]; A[1][1] = Y[0][1] - Y[1][1]; │ │ │ │ │ +413 │ │ │ │ │ +414 if (std::abs(A.determinant())>eps) { │ │ │ │ │ +415 // lines are non parallel and not degenerated │ │ │ │ │ +416 FieldVector p,r,b = Y[0] - X[0]; │ │ │ │ │ +417 A.solve(r,b) ; │ │ │ │ │ +418 │ │ │ │ │ +419 if ((r[0]>-eps)&&(r[0]<=1+eps)&&(r[1]>-eps)&&(r[1]<1+eps)) { │ │ │ │ │ +420 p = X[1] - X[0]; │ │ │ │ │ +421 p *= r[0] ; │ │ │ │ │ +422 p += X[0] ; │ │ │ │ │ +423 k = insertPoint(p,P); │ │ │ │ │ +424 if(r[0] < eps) { // X = X_0 + r_0 (X_1 - X_0) = X_0 │ │ │ │ │ +425 SX[0].push_back(k); │ │ │ │ │ +426 P[k] = X[0]; │ │ │ │ │ +427 } │ │ │ │ │ +428 else if(r[0] > 1-eps) { // X = X_0 + r_0 (X_1 - X_0) = X_1 │ │ │ │ │ +429 SX[1].push_back(k); │ │ │ │ │ +430 P[k] = X[1]; │ │ │ │ │ +431 } │ │ │ │ │ +432 if(r[1] < eps){ // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_0 │ │ │ │ │ +433 SY[0].push_back(k); │ │ │ │ │ +434 P[k] = Y[0]; │ │ │ │ │ +435 } │ │ │ │ │ +436 else if(r[1] > 1-eps) { // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_1 │ │ │ │ │ +437 SY[1].push_back(k); │ │ │ │ │ +438 P[k] = Y[1]; │ │ │ │ │ +439 } │ │ │ │ │ +440 return true; │ │ │ │ │ +441 } │ │ │ │ │ +442 } else if ((X[1]-X[0]).infinity_norm() > eps && (Y[1]-Y[0]).infinity_norm() │ │ │ │ │ +> eps) { │ │ │ │ │ +443 // lines are parallels, but non degenerated │ │ │ │ │ +444 bool found = false; │ │ │ │ │ +445 │ │ │ │ │ +446 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2 for non │ │ │ │ │ +perpendicular lines │ │ │ │ │ +447 for (unsigned i = 0; i < 2; ++i) { │ │ │ │ │ +448 if (std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) │ │ │ │ │ +449 - std::abs((X[1]-X[0]).two_norm())) < eps) { │ │ │ │ │ +450 k = insertPoint(Y[i],P); │ │ │ │ │ +451 SY[i].push_back(k); │ │ │ │ │ +452 found = true; │ │ │ │ │ +453 } │ │ │ │ │ +454 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) │ │ │ │ │ +455 - std::abs((Y[1]-Y[0]).two_norm())) < eps) { │ │ │ │ │ +456 k = insertPoint(X[i],P); │ │ │ │ │ +457 SX[i].push_back(k); │ │ │ │ │ +458 found = true; │ │ │ │ │ +459 } │ │ │ │ │ +460 } │ │ │ │ │ +461 return found; │ │ │ │ │ +462 } │ │ │ │ │ +463 return false; │ │ │ │ │ +464 } │ │ │ │ │ +465 case 3: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0) │ │ │ │ │ +466 { FieldVector dX, dY, dZ, cXY, cYZ; │ │ │ │ │ +467 │ │ │ │ │ +468 dX = X[1]-X[0]; │ │ │ │ │ +469 dY = Y[1]-Y[0]; │ │ │ │ │ +470 dZ = Y[0]-X[0]; │ │ │ │ │ +471 │ │ │ │ │ +472 cXY[0] = dX[1]* dY[2] - dX[2]* dY[1]; │ │ │ │ │ +473 cXY[1] = dX[2]* dY[0] - dX[0]* dY[2]; │ │ │ │ │ +474 cXY[2] = dX[0]* dY[1] - dX[1]* dY[0]; │ │ │ │ │ +475 │ │ │ │ │ +476 if (fabs(dZ.dot(cXY)) < eps*1e+3 && cXY.infinity_norm()>eps) { // coplanar, │ │ │ │ │ +but not aligned │ │ │ │ │ +477 │ │ │ │ │ +478 cYZ[0] = dY[1]* dZ[2] - dY[2]* dZ[1]; │ │ │ │ │ +479 cYZ[1] = dY[2]* dZ[0] - dY[0]* dZ[2]; │ │ │ │ │ +480 cYZ[2] = dY[0]* dZ[1] - dY[1]* dZ[0]; │ │ │ │ │ +481 │ │ │ │ │ +482 T s = -cYZ.dot(cXY) / cXY.two_norm2(); │ │ │ │ │ +483 │ │ │ │ │ +484 if (s > -eps && s < 1+eps) { │ │ │ │ │ +485 dX*= s; │ │ │ │ │ +486 dX+= X[0]; │ │ │ │ │ +487 T o = (dX - Y[0]).two_norm() + (dX- Y[1]).two_norm(); │ │ │ │ │ +488 │ │ │ │ │ +489 if (std::abs(o-dY.two_norm()) < eps) { │ │ │ │ │ +490 k = insertPoint(dX,P); │ │ │ │ │ +491 \ │ │ │ │ │ +492 if (s 1-eps) { │ │ │ │ │ +496 P[k] = X[1]; │ │ │ │ │ +497 SX[1].push_back(k); │ │ │ │ │ +498 } else if ((dX - Y[0]).two_norm() < eps) { │ │ │ │ │ +499 P[k] = Y[0]; │ │ │ │ │ +500 SY[0].push_back(k); │ │ │ │ │ +501 } else if((dX - Y[1]).two_norm() < eps) { │ │ │ │ │ +502 P[k] = Y[1]; │ │ │ │ │ +503 SY[1].push_back(k); │ │ │ │ │ +504 } │ │ │ │ │ +505 │ │ │ │ │ +506 return true; │ │ │ │ │ +507 } │ │ │ │ │ +508 } │ │ │ │ │ +509 } else if (cXY.infinity_norm() <= eps) {// lines are parallel │ │ │ │ │ +510 │ │ │ │ │ +511 bool found = false; │ │ │ │ │ +512 │ │ │ │ │ +513 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2, │ │ │ │ │ +514 // under the assumption (a-c)*(c-b) > 0 or (a-c) = 0 or (c-b) = 0 │ │ │ │ │ +515 for (unsigned i = 0; i < 2; ++i) { │ │ │ │ │ +516 if ((std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) / │ │ │ │ │ +/ triangle equality │ │ │ │ │ +517 - std::abs((X[1]-X[0]).two_norm())) < eps) && │ │ │ │ │ +518 (std::abs((Y[i]-X[0]).dot((Y[i]-X[1]))) > eps // assumption │ │ │ │ │ +519 || (Y[i]-X[0]).infinity_norm() < eps || (Y[i]-X[1]).infinity_norm() < eps)) │ │ │ │ │ +{ │ │ │ │ │ +520 k = insertPoint(Y[i],P); │ │ │ │ │ +521 SY[i].push_back(k); │ │ │ │ │ +522 found = true; │ │ │ │ │ +523 } │ │ │ │ │ +524 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) / │ │ │ │ │ +/ triangle equality │ │ │ │ │ +525 - std::abs((Y[1]-Y[0]).two_norm())) < eps && │ │ │ │ │ +526 (std::abs((X[i]-Y[0]).dot((X[i]-Y[1]))) > eps // assumption │ │ │ │ │ +527 || (X[i]-Y[0]).infinity_norm() < eps || (X[i]-Y[1]).infinity_norm() < eps)) │ │ │ │ │ +{ │ │ │ │ │ +528 k = insertPoint(X[i],P); │ │ │ │ │ +529 SX[i].push_back(k); │ │ │ │ │ +530 found = true; │ │ │ │ │ +531 } │ │ │ │ │ +532 } │ │ │ │ │ +533 return found; │ │ │ │ │ +534 } │ │ │ │ │ +535 │ │ │ │ │ +536 return false; │ │ │ │ │ +537 } │ │ │ │ │ +538 } │ │ │ │ │ +539 return false; │ │ │ │ │ +540 } │ │ │ │ │ +541 │ │ │ │ │ +542 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +543 std::vector >& subElements, │ │ │ │ │ +544 std::vector >& faceIds) │ │ │ │ │ +545 { │ │ │ │ │ +546 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +547 elementCorners,subElements, faceIds); │ │ │ │ │ +548 } │ │ │ │ │ +549 │ │ │ │ │ +550 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +551 std::vector >& subElements, │ │ │ │ │ +552 std::vector >& faceIds) │ │ │ │ │ +553 { │ │ │ │ │ +554 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +555 elementCorners, subElements, faceIds); │ │ │ │ │ +556 } │ │ │ │ │ +557}; │ │ │ │ │ +558 │ │ │ │ │ +559// SEGEMENT-TRIANGLE INTERSECTION - : ) │ │ │ │ │ +560template │ │ │ │ │ +561class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +562 friend class ComputationMethod; │ │ │ │ │ +563 │ │ │ │ │ +564public: │ │ │ │ │ +565 typedef FieldVector Vector; │ │ │ │ │ +566 static const int grid1Dimension = 1; │ │ │ │ │ +567 static const int grid2Dimension = 2; │ │ │ │ │ +568 static const int intersectionDimension = 1; │ │ │ │ │ +569 │ │ │ │ │ +570 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +571 const std::vector >& Y, │ │ │ │ │ +572 std::vector > & SX, │ │ │ │ │ +573 std::vector > & SY, │ │ │ │ │ +574 std::vector > & P) │ │ │ │ │ +575 { │ │ │ │ │ +576 │ │ │ │ │ +577 assert(X.size() == 2 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ +578 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +579 SX.resize(2); │ │ │ │ │ +580 SY.resize(3); │ │ │ │ │ +581 │ │ │ │ │ +582 int k; │ │ │ │ │ +583 std::vector > surfPts, edge(2), pni(1); │ │ │ │ │ +584 std::vector > hSX, hSY; │ │ │ │ │ +585 │ │ │ │ │ +586 // is any segment point inside the triangle? │ │ │ │ │ +587 for (unsigned ni = 0; ni < 2; ++ni) { │ │ │ │ │ +588 pni[0] = X[ni]; │ │ │ │ │ +589 │ │ │ │ │ +590 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(pni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ +591 k = insertPoint(X[ni],P); │ │ │ │ │ +592 SX[ni].push_back(k); │ │ │ │ │ +593 for (unsigned e=0; e < 3; ++e) │ │ │ │ │ +594 if (hSY[e].size() > 0) │ │ │ │ │ +595 SY[e].push_back(k); │ │ │ │ │ +596 │ │ │ │ │ +597 } │ │ │ │ │ +598 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ +599 } │ │ │ │ │ +600 │ │ │ │ │ +601 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ +602 return true; │ │ │ │ │ +603 │ │ │ │ │ +604 unsigned int faces[3] = {0,2,1}; │ │ │ │ │ +605 // do triangle faces intersect with the segment? │ │ │ │ │ +606 for (unsigned ni = 0; ni < 3; ++ni) { │ │ │ │ │ +607 edge[0] = Y[ni]; │ │ │ │ │ +608 edge[1] = Y[(ni+1)%3]; │ │ │ │ │ +609 │ │ │ │ │ +610 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(X,edge,hSX,hSY,surfPts)) { │ │ │ │ │ +611 for (unsigned ne = 0; ne < surfPts.size(); ++ne) { │ │ │ │ │ +612 k = insertPoint(surfPts[ne],P); │ │ │ │ │ +613 SY[faces[ni]].push_back(k); │ │ │ │ │ +614 if (hSX[0].size() > 0) │ │ │ │ │ +615 SX[0].push_back(k); │ │ │ │ │ +616 if (hSX[1].size() > 0) │ │ │ │ │ +617 SX[1].push_back(k); │ │ │ │ │ +618 } │ │ │ │ │ +619 │ │ │ │ │ +620 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ +621 return true; │ │ │ │ │ +622 │ │ │ │ │ +623 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ +624 } │ │ │ │ │ +625 } │ │ │ │ │ +626 │ │ │ │ │ +627 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ +628 return true; │ │ │ │ │ +629 │ │ │ │ │ +630 // if line and triangle are not coplanar in 3d and do not intersect at │ │ │ │ │ +boundaries │ │ │ │ │ +631 if (dimWorld == 3) { │ │ │ │ │ +632 T eps = 1e-8; │ │ │ │ │ +633 │ │ │ │ │ +634 Dune::FieldVector B,r,p ; │ │ │ │ │ +635 Dune::FieldMatrix A ; │ │ │ │ │ +636 │ │ │ │ │ +637 B = Y[0] - X[0] ; │ │ │ │ │ +638 │ │ │ │ │ +639 for (unsigned i = 0; i < dimWorld; ++i) { │ │ │ │ │ +640 A[i][0] = (X[1][i] - X[0][i]); │ │ │ │ │ +641 A[i][1] = (Y[0][i] - Y[1][i]); │ │ │ │ │ +642 A[i][dimWorld-1] = (Y[0][i] - Y[dimWorld-1][i]); │ │ │ │ │ +643 } │ │ │ │ │ +644 │ │ │ │ │ +645 if (std::abs(A.determinant())>eps) { │ │ │ │ │ +646 │ │ │ │ │ +647 A.solve(r,B) ; │ │ │ │ │ +648 │ │ │ │ │ +649 if ((r[0]>=-eps)&&(r[0]<=1+eps) │ │ │ │ │ +650 &&(r[1]>=-eps)&&(r[1]<=1+eps) │ │ │ │ │ +651 &&(r[2]>=-eps)&&(r[2]<=1+eps) │ │ │ │ │ +652 &&(r[1]+r[2]>=-eps) &&(r[1]+r[2]<=1+eps)) { │ │ │ │ │ +653 p = X[1] - X[0] ; │ │ │ │ │ +654 p *= r[0] ; │ │ │ │ │ +655 p += X[0] ; │ │ │ │ │ +656 k = insertPoint(p,P); │ │ │ │ │ +657 │ │ │ │ │ +658 if (std::abs(r[0]) < eps) // we prefer exact locations │ │ │ │ │ +659 P[k] = X[0]; │ │ │ │ │ +660 else if (std::abs(r[0]) > 1-eps) │ │ │ │ │ +661 P[k] = X[1]; │ │ │ │ │ +662 else if (std::abs(r[1]) < eps && std::abs(r[2]) < eps) │ │ │ │ │ +663 P[k] = Y[0]; │ │ │ │ │ +664 else if (std::abs(r[1]) < eps && std::abs(r[2]) > 1-eps) │ │ │ │ │ +665 P[k] = Y[2]; │ │ │ │ │ +666 else if (std::abs(r[1]) > 1-eps && std::abs(r[2]) < eps) │ │ │ │ │ +667 P[k] = Y[1]; │ │ │ │ │ +668 │ │ │ │ │ +669 if (std::abs(r[1]) < eps) │ │ │ │ │ +670 SY[1].push_back(k); │ │ │ │ │ +671 if (std::fabs(r[dimWorld-1]) < eps) │ │ │ │ │ +672 SY[0].push_back(k); │ │ │ │ │ +673 if (std::fabs(r[1]+r[dimWorld-1] - 1) < eps) │ │ │ │ │ +674 SY[2].push_back(k); │ │ │ │ │ +675 │ │ │ │ │ +676 │ │ │ │ │ +677 return true ; │ │ │ │ │ +678 } │ │ │ │ │ +679 } │ │ │ │ │ +680 } │ │ │ │ │ +681 return false ; │ │ │ │ │ +682 } │ │ │ │ │ +683 │ │ │ │ │ +684 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +685 std::vector >& subElements, │ │ │ │ │ +686 std::vector >& faceIds) │ │ │ │ │ +687 { │ │ │ │ │ +688 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +689 elementCorners,subElements, faceIds); │ │ │ │ │ +690 } │ │ │ │ │ +691 │ │ │ │ │ +692 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +693 std::vector >& subElements, │ │ │ │ │ +694 std::vector >& faceIds) │ │ │ │ │ +695 { │ │ │ │ │ +696 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +697 elementCorners, subElements, faceIds); │ │ │ │ │ +698 } │ │ │ │ │ +699}; │ │ │ │ │ +700 │ │ │ │ │ +701// SEGEMENT-TETRAHEDRON INTERSECTION - : ) │ │ │ │ │ +702template │ │ │ │ │ +703class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +704 friend class ComputationMethod; │ │ │ │ │ +705 │ │ │ │ │ +706public: │ │ │ │ │ +707 typedef FieldVector Vector; │ │ │ │ │ +708 static const int grid1Dimension = 1; │ │ │ │ │ +709 static const int grid2Dimension = 3; │ │ │ │ │ +710 static const int intersectionDimension = 1; │ │ │ │ │ +711 │ │ │ │ │ +712 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +713 const std::vector >& Y, │ │ │ │ │ +714 std::vector > & SX, │ │ │ │ │ +715 std::vector > & SY, │ │ │ │ │ +716 std::vector > & P) │ │ │ │ │ +717 { │ │ │ │ │ +718 assert(X.size() == 2 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ +719 │ │ │ │ │ +720 std::vector indices; │ │ │ │ │ +721 std::vector > surfPts; │ │ │ │ │ +722 std::vector > hSX, hSY; │ │ │ │ │ +723 │ │ │ │ │ +724 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +725 SX.resize(2); │ │ │ │ │ +726 SY.resize(4); │ │ │ │ │ +727 │ │ │ │ │ +728 std::vector > pni(1); │ │ │ │ │ +729 │ │ │ │ │ +730 bool b = false; │ │ │ │ │ +731 │ │ │ │ │ +732 // check whether the corners of the segment are contained in the │ │ │ │ │ +tetrahedron │ │ │ │ │ +733 for (unsigned int ci = 0; ci < 2; ++ ci) { │ │ │ │ │ +734 │ │ │ │ │ +735 pni[0] = X[ci]; │ │ │ │ │ +736 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(pni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ +737 int k = insertPoint(X[ci],P); │ │ │ │ │ +738 SX[ci].push_back(k); │ │ │ │ │ +739 b=true; │ │ │ │ │ +740 } │ │ │ │ │ +741 surfPts.clear(); │ │ │ │ │ +742 hSX.clear(); hSY.clear(); │ │ │ │ │ +743 } │ │ │ │ │ +744 │ │ │ │ │ +745 if (P.size() == 2) │ │ │ │ │ +746 return true; │ │ │ │ │ +747 │ │ │ │ │ +748 unsigned int faces[4] = {0,3,2,1}; │ │ │ │ │ +749 // check whether tetrahedron faces intersect with segment │ │ │ │ │ +750 std::vector > triangle(3); │ │ │ │ │ +751 for (unsigned int ci = 0; ci < 4; ++ci) { // iterate over all faces │ │ │ │ │ +752 triangle[0] = Y[ci]; │ │ │ │ │ +753 triangle[1] = Y[(ci+1)%4]; │ │ │ │ │ +754 triangle[2] = Y[(ci+2)%4]; │ │ │ │ │ +755 │ │ │ │ │ +756 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(X,triangle,hSX,hSY,surfPts)) { // seg - triangle intersection │ │ │ │ │ +757 std::vector indices(surfPts.size()); │ │ │ │ │ +758 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +759 int k = insertPoint(surfPts[np],P); │ │ │ │ │ +760 indices[np]=k; │ │ │ │ │ +761 SY[faces[ci]].push_back(k); │ │ │ │ │ +762 } │ │ │ │ │ +763 │ │ │ │ │ +764 // hSX[*] is nonempty if the intersection point is on an edge of the │ │ │ │ │ +current face of Y │ │ │ │ │ +765 for (unsigned int np = 0; np < hSX[0].size(); ++np) │ │ │ │ │ +766 SX[0].push_back(indices[hSX[0][np]]); │ │ │ │ │ +767 for (unsigned int np = 0; np < hSX[1].size(); ++np) │ │ │ │ │ +768 SX[0].push_back(indices[hSX[1][np]]); │ │ │ │ │ +769 │ │ │ │ │ +770 b = true; │ │ │ │ │ +771 } │ │ │ │ │ +772 surfPts.clear(); │ │ │ │ │ +773 hSX.clear(); hSY.clear(); │ │ │ │ │ +774 } │ │ │ │ │ +775 │ │ │ │ │ +776 return b; │ │ │ │ │ +777 } │ │ │ │ │ +778 │ │ │ │ │ +779 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +780 std::vector >& subElements, │ │ │ │ │ +781 std::vector >& faceIds) │ │ │ │ │ +782 { │ │ │ │ │ +783 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +784 elementCorners,subElements, faceIds); │ │ │ │ │ +785 } │ │ │ │ │ +786 │ │ │ │ │ +787 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +788 std::vector >& subElements, │ │ │ │ │ +789 std::vector >& faceIds) │ │ │ │ │ +790 { │ │ │ │ │ +791 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +792 elementCorners, subElements, faceIds); │ │ │ │ │ +793 } │ │ │ │ │ +794}; │ │ │ │ │ +795 │ │ │ │ │ +796// TRIANGLE -TRIANGLE INTERSECTION │ │ │ │ │ +797template │ │ │ │ │ +798class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +799 friend class ComputationMethod; │ │ │ │ │ +800 │ │ │ │ │ +801public: │ │ │ │ │ +802 typedef FieldVector Vector; │ │ │ │ │ +803 static const int grid1Dimension = 2; │ │ │ │ │ +804 static const int grid2Dimension = 2; │ │ │ │ │ +805 static const int intersectionDimension = 2; │ │ │ │ │ +806 │ │ │ │ │ +807 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +808 const std::vector >& Y, │ │ │ │ │ +809 std::vector > & SX, │ │ │ │ │ +810 std::vector > & SY, │ │ │ │ │ +811 std::vector > & P) │ │ │ │ │ +812 { │ │ │ │ │ +813 assert(X.size() == 3 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ +814 │ │ │ │ │ +815 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +816 │ │ │ │ │ +817 SX.resize(3); │ │ │ │ │ +818 SY.resize(3); │ │ │ │ │ +819 │ │ │ │ │ +820 bool b = false; │ │ │ │ │ +821 │ │ │ │ │ +822 std::vector > edge(2); │ │ │ │ │ +823 std::vector > surfPts; │ │ │ │ │ +824 std::vector > hSX, hSY; │ │ │ │ │ +825 std::vector indices; │ │ │ │ │ +826 │ │ │ │ │ +827 unsigned int faces[3] = {0,2,1}; │ │ │ │ │ +828 │ │ │ │ │ +829 for (unsigned int ni = 0; ni < 3; ++ni) { │ │ │ │ │ +830 // check whether the faces of triangle Y intersect the triangle X │ │ │ │ │ +831 edge[0] = Y[ni]; │ │ │ │ │ +832 edge[1] = Y[(ni+1)%3]; │ │ │ │ │ +833 │ │ │ │ │ +834 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(X,edge,hSX,hSY,surfPts)) { │ │ │ │ │ +835 │ │ │ │ │ +836 indices.resize(surfPts.size()); │ │ │ │ │ +837 // add intersections of edges of Y with triangle X │ │ │ │ │ +838 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +839 int k = insertPoint(surfPts[np],P); │ │ │ │ │ +840 indices[np] = k; │ │ │ │ │ +841 SY[faces[ni]].push_back(k); // add edge data │ │ │ │ │ +842 } │ │ │ │ │ +843 │ │ │ │ │ +844 b=true; │ │ │ │ │ +845 } │ │ │ │ │ +846 if (P.size() >= 6) │ │ │ │ │ +847 return true; │ │ │ │ │ +848 │ │ │ │ │ +849 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ +850 // check whether the faces of triangle X intersect the triangle Y │ │ │ │ │ +851 edge[0] = X[ni]; │ │ │ │ │ +852 edge[1] = X[(ni+1)%3]; │ │ │ │ │ +853 │ │ │ │ │ +854 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(edge,Y,hSX,hSY,surfPts)) { │ │ │ │ │ +855 │ │ │ │ │ +856 indices.resize(surfPts.size()); │ │ │ │ │ +857 // add intersections of edges of X with triangle Y │ │ │ │ │ +858 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +859 int k = insertPoint(surfPts[np],P); │ │ │ │ │ +860 indices[np] = k; │ │ │ │ │ +861 SX[faces[ni]].push_back(k); // add edge data │ │ │ │ │ +862 } │ │ │ │ │ +863 │ │ │ │ │ +864 b=true; │ │ │ │ │ +865 } │ │ │ │ │ +866 if (P.size() >= 6) │ │ │ │ │ +867 return true; │ │ │ │ │ +868 │ │ │ │ │ +869 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ +870 } │ │ │ │ │ +871 │ │ │ │ │ +872 return b; │ │ │ │ │ +873 } │ │ │ │ │ +874 │ │ │ │ │ +875 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +876 std::vector >& subElements, │ │ │ │ │ +877 std::vector >& faceIds) │ │ │ │ │ +878 { │ │ │ │ │ +879 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +880 elementCorners,subElements, faceIds); │ │ │ │ │ +881 } │ │ │ │ │ +882 │ │ │ │ │ +883 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +884 std::vector >& subElements, │ │ │ │ │ +885 std::vector >& faceIds) │ │ │ │ │ +886 { │ │ │ │ │ +887 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +888 elementCorners, subElements, faceIds); │ │ │ │ │ +889 } │ │ │ │ │ +890}; │ │ │ │ │ +891 │ │ │ │ │ +892// TRIANGLE -TETRAHEDRON INTERSECTION -: ) │ │ │ │ │ +893template │ │ │ │ │ +894class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +895 friend class ComputationMethod; │ │ │ │ │ +896 │ │ │ │ │ +897public: │ │ │ │ │ +898 typedef FieldVector Vector; │ │ │ │ │ +899 static const int grid1Dimension = 2; │ │ │ │ │ +900 static const int grid2Dimension = 3; │ │ │ │ │ +901 static const int intersectionDimension = 2; │ │ │ │ │ +902 │ │ │ │ │ +903 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +904 const std::vector >& Y, │ │ │ │ │ +905 std::vector > & SX, │ │ │ │ │ +906 std::vector > & SY, │ │ │ │ │ +907 std::vector > & P) │ │ │ │ │ +908 { │ │ │ │ │ +909 assert(X.size() == 3 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ +910 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +911 SX.resize(3); │ │ │ │ │ +912 SY.resize(4); │ │ │ │ │ +913 │ │ │ │ │ +914 bool b = false; │ │ │ │ │ +915 int k,ni,np, ep; │ │ │ │ │ +916 std::vector > surfPts, xni(1); │ │ │ │ │ +917 std::vector > hSX, hSY; │ │ │ │ │ +918 │ │ │ │ │ +919 unsigned int fiX[3][2]; │ │ │ │ │ +920 │ │ │ │ │ +921 fiX[0][0] = 0; fiX[1][0] = 0; fiX[2][0] = 1; // faces to node │ │ │ │ │ +922 fiX[0][1] = 1; fiX[1][1] = 2; fiX[2][1] = 2; │ │ │ │ │ +923 // 1st step: check whether the points of the triangle are contained in the │ │ │ │ │ +tetrahedron │ │ │ │ │ +924 for (ni = 0; ni < 3; ++ni) { │ │ │ │ │ +925 │ │ │ │ │ +926 xni[0] = X[ni]; │ │ │ │ │ +927 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(xni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ +928 std::vector indices(surfPts.size()); │ │ │ │ │ +929 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +930 k = insertPoint(X[ni],P); │ │ │ │ │ +931 indices[np] = k; │ │ │ │ │ +932 SX[fiX[ni][0]].push_back(k); // the corresponding edges to the node are ni │ │ │ │ │ +and (ni+2)%3 │ │ │ │ │ +933 SX[fiX[ni][1]].push_back(k); │ │ │ │ │ +934 } │ │ │ │ │ +935 │ │ │ │ │ +936 for (ep = 0; ep < 4; ++ep) { │ │ │ │ │ +937 for (np = 0; np < hSY[ep].size();++np) { │ │ │ │ │ +938 SY[ep].push_back(indices[hSY[ep][np]]); │ │ │ │ │ +939 } │ │ │ │ │ +940 } │ │ │ │ │ +941 b = true; │ │ │ │ │ +942 } │ │ │ │ │ +943 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +944 } │ │ │ │ │ +945 │ │ │ │ │ +946 if (P.size() == 3) // intersection is given by all three corners of the │ │ │ │ │ +triangle │ │ │ │ │ +947 return true; │ │ │ │ │ +948 │ │ │ │ │ +949 // note: points of Y in X is called indirectly via triangle-triangle │ │ │ │ │ +intesection │ │ │ │ │ +950 │ │ │ │ │ +951 // check whether the triangles of the one tetrahedron intersect the │ │ │ │ │ +triangle │ │ │ │ │ +952 unsigned int facesY[4] = {0,3,2,1}; // face ordering │ │ │ │ │ +953 │ │ │ │ │ +954 std::vector > triangle(3); │ │ │ │ │ +955 for (ni = 0; ni < 4; ++ni) { │ │ │ │ │ +956 │ │ │ │ │ +957 triangle[0] = Y[ni]; │ │ │ │ │ +958 triangle[1] = Y[(ni+1)%4]; │ │ │ │ │ +959 triangle[2] = Y[(ni+2)%4]; │ │ │ │ │ +960 │ │ │ │ │ +961 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(X,triangle,hSX,hSY,surfPts)) { │ │ │ │ │ +962 std::vector indices(surfPts.size()); │ │ │ │ │ +963 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +964 k = insertPoint(surfPts[np],P); │ │ │ │ │ +965 indices[np]=k; │ │ │ │ │ +966 SY[facesY[ni]].push_back(k); │ │ │ │ │ +967 } │ │ │ │ │ +968 │ │ │ │ │ +969 // SX[*] is nonempty if the face * of X is intersected │ │ │ │ │ +970 for (np = 0; np < 3; ++np) { │ │ │ │ │ +971 for (ep = 0; ep < hSX[np].size(); ++ep) { │ │ │ │ │ +972 SX[np].push_back(indices[hSX[np][ep]]); │ │ │ │ │ +973 } │ │ │ │ │ +974 } │ │ │ │ │ +975 │ │ │ │ │ +976 b = true; │ │ │ │ │ +977 } │ │ │ │ │ +978 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +979 } │ │ │ │ │ +980 return b; │ │ │ │ │ +981 } │ │ │ │ │ +982 │ │ │ │ │ +983 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +984 std::vector >& subElements, │ │ │ │ │ +985 std::vector >& faceIds) │ │ │ │ │ +986 { │ │ │ │ │ +987 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +988 elementCorners,subElements, faceIds); │ │ │ │ │ +989 } │ │ │ │ │ +990 │ │ │ │ │ +991 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +992 std::vector >& subElements, │ │ │ │ │ +993 std::vector >& faceIds) │ │ │ │ │ +994 { │ │ │ │ │ +995 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +996 elementCorners, subElements, faceIds); │ │ │ │ │ +997 } │ │ │ │ │ +998}; │ │ │ │ │ +999 │ │ │ │ │ +1000template │ │ │ │ │ +1001class SimplexMethod : public │ │ │ │ │ +ComputationMethod{ │ │ │ │ │ +1002 friend class ComputationMethod; │ │ │ │ │ +1003 │ │ │ │ │ +1004public: │ │ │ │ │ +1005 typedef FieldVector Vector; │ │ │ │ │ +1006 static const int grid1Dimension = 3; │ │ │ │ │ +1007 static const int grid2Dimension = 3; │ │ │ │ │ +1008 static const int intersectionDimension = 3; │ │ │ │ │ +1009 │ │ │ │ │ +1010 static bool computeIntersectionPoints(const std:: │ │ │ │ │ +vector >& X, │ │ │ │ │ +1011 const std::vector >& Y, │ │ │ │ │ +1012 std::vector > & SX, │ │ │ │ │ +1013 std::vector > & SY, │ │ │ │ │ +1014 std::vector > & P) │ │ │ │ │ +1015 { │ │ │ │ │ +1016 assert(X.size() == 4 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ +1017 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ +1018 │ │ │ │ │ +1019 SX.resize(4); │ │ │ │ │ +1020 SY.resize(4); │ │ │ │ │ +1021 │ │ │ │ │ +1022 bool b = false; │ │ │ │ │ +1023 int ci,np,ne,k,ni[4][3]; │ │ │ │ │ +1024 │ │ │ │ │ +1025 ni[0][0]= 0 ; ni[0][1]= 1 ; ni[0][2]= 2 ; // faces touching each node │ │ │ │ │ +1026 ni[1][0]= 0 ; ni[1][1]= 1 ; ni[1][2]= 3 ; │ │ │ │ │ +1027 ni[2][0]= 0 ; ni[2][1]= 2 ; ni[2][2]= 3 ; │ │ │ │ │ +1028 ni[3][0]= 1 ; ni[3][1]= 2 ; ni[3][2]= 3 ; │ │ │ │ │ +1029 │ │ │ │ │ +1030 // temporal data container │ │ │ │ │ +1031 std::vector > surfPts, pci(1); │ │ │ │ │ +1032 std::vector > hSX, hSY; │ │ │ │ │ +1033 │ │ │ │ │ +1034 // check whether the points of the one tetrahedron are contained in the │ │ │ │ │ +other tetrahedron │ │ │ │ │ +1035 for (ci = 0; ci < 3; ++ci) { │ │ │ │ │ +1036 pci[0] = X[ci]; │ │ │ │ │ +1037 // point of X is inside Y │ │ │ │ │ +1038 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(pci,Y,hSX,hSY,surfPts)) { │ │ │ │ │ +1039 std::vector indices(surfPts.size()); │ │ │ │ │ +1040 │ │ │ │ │ +1041 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +1042 │ │ │ │ │ +1043 k = insertPoint(X[ci],P); │ │ │ │ │ +1044 indices[np]=k; │ │ │ │ │ +1045 SX[ni[ci][0]].push_back(k); // add face data │ │ │ │ │ +1046 SX[ni[ci][1]].push_back(k); │ │ │ │ │ +1047 SX[ni[ci][2]].push_back(k); │ │ │ │ │ +1048 } │ │ │ │ │ +1049 │ │ │ │ │ +1050 // hSY[*] is nonempty if X[ci] is on the face * of Y │ │ │ │ │ +1051 for (ne = 0; ne < 4; ++ne) { │ │ │ │ │ +1052 for (np = 0; np < hSY[ne].size(); ++np) { │ │ │ │ │ +1053 SY[ne].push_back(indices[hSY[ne][np]]); │ │ │ │ │ +1054 } │ │ │ │ │ +1055 } │ │ │ │ │ +1056 │ │ │ │ │ +1057 b = true; │ │ │ │ │ +1058 } │ │ │ │ │ +1059 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +1060 │ │ │ │ │ +1061 // probably one point of Y is inside X │ │ │ │ │ +1062 surfPts.resize(0); │ │ │ │ │ +1063 pci[0]=Y[ci]; │ │ │ │ │ +1064 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ +(pci,X,hSY,hSX,surfPts)) { │ │ │ │ │ +1065 std::vector indices(surfPts.size()); │ │ │ │ │ +1066 │ │ │ │ │ +1067 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +1068 k = insertPoint(Y[ci],P); │ │ │ │ │ +1069 indices[np]=k; │ │ │ │ │ +1070 SY[ni[ci][0]].push_back(k); // add face data │ │ │ │ │ +1071 SY[ni[ci][1]].push_back(k); │ │ │ │ │ +1072 SY[ni[ci][2]].push_back(k); │ │ │ │ │ +1073 } │ │ │ │ │ +1074 │ │ │ │ │ +1075 // hSX[*] is nonempty if the point Y[ci] is on the face * of X │ │ │ │ │ +1076 for (ne = 0; ne < 4; ++ne) { │ │ │ │ │ +1077 for (np = 0; np < hSX[ne].size(); ++np) { │ │ │ │ │ +1078 SX[ne].push_back(indices[hSX[ne][np]]); │ │ │ │ │ +1079 } │ │ │ │ │ +1080 } │ │ │ │ │ +1081 b = true; │ │ │ │ │ +1082 } │ │ │ │ │ +1083 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +1084 } │ │ │ │ │ +1085 │ │ │ │ │ +1086 // check whether the triangles of the one tetrahedron intersect the │ │ │ │ │ +triangles │ │ │ │ │ +1087 // of the other tetrahedron │ │ │ │ │ +1088 unsigned int faces[4] = {0,3,2,1}; // face ordering │ │ │ │ │ +1089 │ │ │ │ │ +1090 std::vector > triangle(3); │ │ │ │ │ +1091 for (ci = 0; ci < 4; ++ci) { // iterate over faces of Y │ │ │ │ │ +1092 │ │ │ │ │ +1093 triangle[0] = Y[ci]; │ │ │ │ │ +1094 triangle[1] = Y[(ci+1)%4]; │ │ │ │ │ +1095 triangle[2] = Y[(ci+2)%4]; │ │ │ │ │ +1096 │ │ │ │ │ +1097 if(SimplexMethod::computeIntersectionPoints(X, │ │ │ │ │ +triangle,hSX,hSY,surfPts)) { │ │ │ │ │ +1098 │ │ │ │ │ +1099 // add Triangle of Y intersects tetrahedron Y data │ │ │ │ │ +1100 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +1101 k = insertPoint(surfPts[np],P); │ │ │ │ │ +1102 SY[faces[ci]].push_back(k); // add face data │ │ │ │ │ +1103 } │ │ │ │ │ +1104 b = true; │ │ │ │ │ +1105 } │ │ │ │ │ +1106 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +1107 │ │ │ │ │ +1108 triangle[0] = X[ci]; │ │ │ │ │ +1109 triangle[1] = X[(ci+1)%4]; │ │ │ │ │ +1110 triangle[2] = X[(ci+2)%4]; │ │ │ │ │ +1111 │ │ │ │ │ +1112 if(SimplexMethod::computeIntersectionPoints(Y, │ │ │ │ │ +triangle,hSY,hSX,surfPts)) { │ │ │ │ │ +1113 │ │ │ │ │ +1114 // add Triangle of Y intersects tetrahedron Y data │ │ │ │ │ +1115 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ +1116 k = insertPoint(surfPts[np],P); │ │ │ │ │ +1117 SX[faces[ci]].push_back(k); // add face data │ │ │ │ │ +1118 } │ │ │ │ │ +1119 b = true; │ │ │ │ │ +1120 } │ │ │ │ │ +1121 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ +1122 } │ │ │ │ │ +1123 │ │ │ │ │ +1124 return b; │ │ │ │ │ +1125 } │ │ │ │ │ +1126 │ │ │ │ │ +1127 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +1128 std::vector >& subElements, │ │ │ │ │ +1129 std::vector >& faceIds) │ │ │ │ │ +1130 { │ │ │ │ │ +1131 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +1132 elementCorners,subElements, faceIds); │ │ │ │ │ +1133 } │ │ │ │ │ +1134 │ │ │ │ │ +1135 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ +1136 std::vector >& subElements, │ │ │ │ │ +1137 std::vector >& faceIds) │ │ │ │ │ +1138 { │ │ │ │ │ +1139 simplexSubdivision(std::integral_constant │ │ │ │ │ +(), │ │ │ │ │ +1140 elementCorners, subElements, faceIds); │ │ │ │ │ +1141 } │ │ │ │ │ +1142}; │ │ │ │ │ +1143 │ │ │ │ │ +1144template │ │ │ │ │ +1145inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ +1146 const std::vector >& elementCorners, │ │ │ │ │ +1147 std::vector >& subElements, │ │ │ │ │ +1148 std::vector >& faceIds) │ │ │ │ │ +1149{ │ │ │ │ │ +1150 subElements.resize(1); │ │ │ │ │ +1151 faceIds.resize(0); │ │ │ │ │ +1152 │ │ │ │ │ +1153 subElements[0].push_back(0); │ │ │ │ │ +1154} │ │ │ │ │ +1155 │ │ │ │ │ +1156template │ │ │ │ │ +1157inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ +1158 const std::vector >& elementCorners, │ │ │ │ │ +1159 std::vector >& subElements, │ │ │ │ │ +1160 std::vector >& faceIds) │ │ │ │ │ +1161{ │ │ │ │ │ +1162 subElements.resize(1); │ │ │ │ │ +1163 faceIds.resize(1); │ │ │ │ │ +1164 │ │ │ │ │ +1165 subElements[0].push_back(0); │ │ │ │ │ +1166 subElements[0].push_back(1); │ │ │ │ │ +1167 │ │ │ │ │ +1168 faceIds[0].push_back(0); │ │ │ │ │ +1169 faceIds[0].push_back(1); │ │ │ │ │ +1170} │ │ │ │ │ +1171 │ │ │ │ │ +1172template │ │ │ │ │ +1173inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ +1174 const std::vector >& elementCorners, │ │ │ │ │ +1175 std::vector >& subElements, │ │ │ │ │ +1176 std::vector >& faceIds) │ │ │ │ │ +1177{ │ │ │ │ │ +1178 subElements.clear(); │ │ │ │ │ +1179 faceIds.clear(); │ │ │ │ │ +1180 │ │ │ │ │ +1181 if (elementCorners.size() == 3) { // triangle │ │ │ │ │ +1182 subElements.resize(1); │ │ │ │ │ +1183 faceIds.resize(1); │ │ │ │ │ +1184 │ │ │ │ │ +1185 subElements[0].push_back(0); │ │ │ │ │ +1186 subElements[0].push_back(1); │ │ │ │ │ +1187 subElements[0].push_back(2); │ │ │ │ │ +1188 │ │ │ │ │ +1189 faceIds[0].push_back(0); │ │ │ │ │ +1190 faceIds[0].push_back(1); │ │ │ │ │ +1191 faceIds[0].push_back(2); │ │ │ │ │ +1192 } else if (elementCorners.size() == 4) { // quadrilateral => 2 triangles │ │ │ │ │ +1193 subElements.resize(2); │ │ │ │ │ +1194 faceIds.resize(2); │ │ │ │ │ +1195 │ │ │ │ │ +1196 subElements[0].push_back(0); │ │ │ │ │ +1197 subElements[0].push_back(1); │ │ │ │ │ +1198 subElements[0].push_back(2); │ │ │ │ │ +1199 │ │ │ │ │ +1200 subElements[1].push_back(1); │ │ │ │ │ +1201 subElements[1].push_back(2); │ │ │ │ │ +1202 subElements[1].push_back(3); │ │ │ │ │ +1203 │ │ │ │ │ +1204 faceIds[0].push_back(2); │ │ │ │ │ +1205 faceIds[0].push_back(0); │ │ │ │ │ +1206 faceIds[0].push_back(-1); │ │ │ │ │ +1207 │ │ │ │ │ +1208 faceIds[1].push_back(-1); │ │ │ │ │ +1209 faceIds[1].push_back(1); │ │ │ │ │ +1210 faceIds[1].push_back(3); │ │ │ │ │ +1211 } │ │ │ │ │ +1212} │ │ │ │ │ +1213 │ │ │ │ │ +1214template │ │ │ │ │ +1215inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ +1216 const std::vector >& elementCorners, │ │ │ │ │ +1217 std::vector >& subElements, │ │ │ │ │ +1218 std::vector >& faceIds) │ │ │ │ │ +1219{ │ │ │ │ │ +1220 subElements.clear(); │ │ │ │ │ +1221 faceIds.clear(); │ │ │ │ │ +1222 │ │ │ │ │ +1223 if (elementCorners.size() == 4) { // tetrahedron │ │ │ │ │ +1224 subElements.resize(1); │ │ │ │ │ +1225 faceIds.resize(1); │ │ │ │ │ +1226 │ │ │ │ │ +1227 subElements[0].push_back(0); │ │ │ │ │ +1228 subElements[0].push_back(1); │ │ │ │ │ +1229 subElements[0].push_back(2); │ │ │ │ │ +1230 subElements[0].push_back(3); │ │ │ │ │ +1231 │ │ │ │ │ +1232 faceIds[0].push_back(0); │ │ │ │ │ +1233 faceIds[0].push_back(1); │ │ │ │ │ +1234 faceIds[0].push_back(2); │ │ │ │ │ +1235 faceIds[0].push_back(3); │ │ │ │ │ +1236 │ │ │ │ │ +1237 } else if (elementCorners.size() == 8) { // cube => 5 tetrahedra │ │ │ │ │ +1238 subElements.resize(5); │ │ │ │ │ +1239 faceIds.resize(5); │ │ │ │ │ +1240 │ │ │ │ │ +1241 subElements[0].push_back(0); │ │ │ │ │ +1242 subElements[0].push_back(2); │ │ │ │ │ +1243 subElements[0].push_back(3); │ │ │ │ │ +1244 subElements[0].push_back(6); │ │ │ │ │ +1245 │ │ │ │ │ +1246 subElements[1].push_back(0); │ │ │ │ │ +1247 subElements[1].push_back(1); │ │ │ │ │ +1248 subElements[1].push_back(3); │ │ │ │ │ +1249 subElements[1].push_back(5); │ │ │ │ │ +1250 │ │ │ │ │ +1251 subElements[2].push_back(0); │ │ │ │ │ +1252 subElements[2].push_back(3); │ │ │ │ │ +1253 subElements[2].push_back(5); │ │ │ │ │ +1254 subElements[2].push_back(6); │ │ │ │ │ +1255 │ │ │ │ │ +1256 subElements[3].push_back(0); │ │ │ │ │ +1257 subElements[3].push_back(4); │ │ │ │ │ +1258 subElements[3].push_back(5); │ │ │ │ │ +1259 subElements[3].push_back(6); │ │ │ │ │ +1260 │ │ │ │ │ +1261 subElements[4].push_back(3); │ │ │ │ │ +1262 subElements[4].push_back(5); │ │ │ │ │ +1263 subElements[4].push_back(6); │ │ │ │ │ +1264 subElements[4].push_back(7); │ │ │ │ │ +1265 │ │ │ │ │ +1266 faceIds[0].push_back(4); │ │ │ │ │ +1267 faceIds[0].push_back(0); │ │ │ │ │ +1268 faceIds[0].push_back(-1); │ │ │ │ │ +1269 faceIds[0].push_back(3); │ │ │ │ │ +1270 │ │ │ │ │ +1271 faceIds[1].push_back(4); │ │ │ │ │ +1272 faceIds[1].push_back(2); │ │ │ │ │ +1273 faceIds[1].push_back(-1); │ │ │ │ │ +1274 faceIds[1].push_back(1); │ │ │ │ │ +1275 │ │ │ │ │ +1276 faceIds[2].push_back(-1); │ │ │ │ │ +1277 faceIds[2].push_back(-1); │ │ │ │ │ +1278 faceIds[2].push_back(-1); │ │ │ │ │ +1279 faceIds[2].push_back(-1); │ │ │ │ │ +1280 │ │ │ │ │ +1281 faceIds[3].push_back(2); │ │ │ │ │ +1282 faceIds[3].push_back(0); │ │ │ │ │ +1283 faceIds[3].push_back(-1); │ │ │ │ │ +1284 faceIds[3].push_back(5); │ │ │ │ │ +1285 │ │ │ │ │ +1286 faceIds[4].push_back(-1); │ │ │ │ │ +1287 faceIds[4].push_back(1); │ │ │ │ │ +1288 faceIds[4].push_back(3); │ │ │ │ │ +1289 faceIds[4].push_back(5); │ │ │ │ │ +1290 } │ │ │ │ │ +1291} │ │ │ │ │ +1292 │ │ │ │ │ +1293} /* namespace Dune::GridGlue */ │ │ │ │ │ +1294} /* namespace Dune */ │ │ │ │ │ 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::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::ProjectionImplementation::corner │ │ │ │ │ -Coordinate corner(unsigned c) │ │ │ │ │ -Definition projection_impl.hh:24 │ │ │ │ │ -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::removeDoubles │ │ │ │ │ -void removeDoubles(std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ -&polytopeCorners) │ │ │ │ │ -Remove all multiples. │ │ │ │ │ -Definition contactmerge.cc:335 │ │ │ │ │ -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::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::LocalCoords │ │ │ │ │ -Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition contactmerge.hh:62 │ │ │ │ │ +Dune::GridGlue::insertPoint │ │ │ │ │ +int insertPoint(const V p, std::vector< V > &P) │ │ │ │ │ +Definition computeintersection.hh:164 │ │ │ │ │ +Dune::GridGlue::simplexSubdivision │ │ │ │ │ +void 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) │ │ │ │ │ +Definition simplexintersection.cc:1145 │ │ │ │ │ +Dune::GridGlue::ComputationMethod │ │ │ │ │ +Definition computeintersection.hh:13 │ │ │ │ │ +Dune::GridGlue::SimplexMethod │ │ │ │ │ +Definition simplexintersection.cc:30 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::grid1Dimension │ │ │ │ │ +static const int grid1Dimension │ │ │ │ │ +Definition simplexintersection.cc:35 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::grid2Dimension │ │ │ │ │ +static const int grid2Dimension │ │ │ │ │ +Definition simplexintersection.cc:36 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:34 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::intersectionDimension │ │ │ │ │ +static const int intersectionDimension │ │ │ │ │ +Definition simplexintersection.cc:37 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:39 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:48 │ │ │ │ │ +Dune::GridGlue::SimplexMethod::grid2_subdivisions │ │ │ │ │ +static void grid2_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:56 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:104 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:78 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:73 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:181 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:129 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:134 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:206 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:211 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:262 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:291 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:286 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:332 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:360 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:542 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:355 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:570 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:684 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:565 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:779 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:712 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:707 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:802 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:875 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:807 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:903 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:983 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:898 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::grid1_subdivisions │ │ │ │ │ +static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:1127 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::computeIntersectionPoints │ │ │ │ │ +static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ +dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ +vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ +vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ +Definition simplexintersection.cc:1010 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::Vector │ │ │ │ │ +FieldVector< T, dimWorld > Vector │ │ │ │ │ +Definition simplexintersection.cc:1005 │ │ │ │ │ +Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::grid2_subdivisions │ │ │ │ │ +static void grid2_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ +vector< int > > &faceIds) │ │ │ │ │ +Definition simplexintersection.cc:1135 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: merger.hh File Reference │ │ │ │ +dune-grid-glue: conformingmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,37 +72,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
merger.hh File Reference
│ │ │ │ +
conformingmerge.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <vector>
│ │ │ │ + │ │ │ │ +

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/type.hh>
│ │ │ │ -#include <dune/grid-glue/merging/intersectionlist.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::Merger< ctype, grid1Dim, grid2Dim, dimworld >
 Abstract base for all classes that take extracted grids and build sets of intersections. More...
class  Dune::GridGlue::ConformingMerge< dim, dimworld, T >
 Implementation of the Merger concept for conforming interfaces. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

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

Detailed Description

│ │ │ │ +

Implementation of the Merger concept for conforming interfaces.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,25 +2,31 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -merger.hh File Reference │ │ │ │ │ +conformingmerge.hh File Reference │ │ │ │ │ +Implementation of the Merger concept for conforming interfaces. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ 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::ConformingMerge<_dim,_dimworld,_T_> │ │ │ │ │ +  Implementation of the Merger concept for conforming interfaces. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Implementation of the Merger concept for conforming interfaces. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00074_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: merger.hh Source File │ │ │ │ +dune-grid-glue: conformingmerge.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,110 +74,220 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
merger.hh
│ │ │ │ +
conformingmerge.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>
│ │ │ │ -
12
│ │ │ │ - │ │ │ │ -
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
│ │ │ │ -
34 typedef Dune::FieldVector<ctype, grid2Dim> Grid2Coords;
│ │ │ │ +
5/*
│ │ │ │ +
6 * Filename: conformingmerge.hh
│ │ │ │ +
7 * Version: 1.0
│ │ │ │ +
8 * Created on: Sep 14, 2009
│ │ │ │ +
9 * Author: Oliver Sander
│ │ │ │ +
10 * ---------------------------------
│ │ │ │ +
11 * Project: dune-grid-glue
│ │ │ │ +
12 * Description: implementation of the Merger concept for conforming interfaces
│ │ │ │ +
13 *
│ │ │ │ +
14 */
│ │ │ │ +
21#ifndef DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ +
22#define DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ +
23
│ │ │ │ +
24#include <iomanip>
│ │ │ │ +
25#include <vector>
│ │ │ │ +
26#include <algorithm>
│ │ │ │ +
27#include <bitset>
│ │ │ │ +
28
│ │ │ │ +
29#include <dune/common/fmatrix.hh>
│ │ │ │ +
30#include <dune/common/fvector.hh>
│ │ │ │ +
31
│ │ │ │ +
32#include <dune/geometry/referenceelements.hh>
│ │ │ │ +
33
│ │ │ │ + │ │ │ │
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;
│ │ │ │ +
36namespace Dune {
│ │ │ │ +
37
│ │ │ │ +
38 namespace GridGlue {
│ │ │ │ +
39
│ │ │ │ +
46template<int dim, int dimworld, typename T = double>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
48 : public StandardMerge<T,dim,dim,dimworld>
│ │ │ │ +
49{
│ │ │ │ +
50
│ │ │ │ +
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>
│ │ │ │ +
62 typedef Dune::FieldVector<T, dim> LocalCoords;
│ │ │ │ +
63
│ │ │ │ +
64private:
│ │ │ │ +
65
│ │ │ │ +
66 /* M E M B E R V A R I A B L E S */
│ │ │ │ +
67
│ │ │ │ +
69 T tolerance_;
│ │ │ │ +
70
│ │ │ │ +
71 typedef typename StandardMerge<T,dim,dim,dimworld>::SimplicialIntersection SimplicialIntersection;
│ │ │ │ +
72
│ │ │ │ +
77 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
78 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
79 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ +
80 unsigned int grid1Index,
│ │ │ │ +
81 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
82 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
83 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ +
84 unsigned int grid2Index,
│ │ │ │ +
85 std::vector<SimplicialIntersection>& intersections);
│ │ │ │ +
86
│ │ │ │ +
87public:
│ │ │ │ +
88
│ │ │ │ +
89 static constexpr T default_tolerance = 1e-4;
│ │ │ │ +
90
│ │ │ │
│ │ │ │ -
91 unsigned int parent(unsigned int idx, unsigned int parId = 0) const
│ │ │ │ -
92 {
│ │ │ │ -
93 return intersectionList()->template parent<n>(idx, parId);
│ │ │ │ -
94 }
│ │ │ │ + │ │ │ │ +
92 tolerance_(tolerance)
│ │ │ │ +
93 {}
│ │ │ │ +
│ │ │ │ +
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
│ │ │ │ -
120#endif
│ │ │ │ - │ │ │ │ +
96template<int dim, int dimworld, typename T>
│ │ │ │ + │ │ │ │ +
98
│ │ │ │ +
99template<int dim, int dimworld, typename T>
│ │ │ │ +
100void ConformingMerge<dim, dimworld, T>::computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
101 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
102 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ +
103 unsigned int grid1Index,
│ │ │ │ +
104 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
105 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
106 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ +
107 unsigned int grid2Index,
│ │ │ │ +
108 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ +
109{
│ │ │ │ +
110 this->counter++;
│ │ │ │ +
111
│ │ │ │ +
112 // A few consistency checks
│ │ │ │ +
113 assert((unsigned int)(Dune::ReferenceElements<T,dim>::general(grid1ElementType).size(dim)) == grid1ElementCorners.size());
│ │ │ │ +
114 assert((unsigned int)(Dune::ReferenceElements<T,dim>::general(grid2ElementType).size(dim)) == grid2ElementCorners.size());
│ │ │ │ +
115 // any intersection we may find will be the entire elements.
│ │ │ │ +
116 neighborIntersects1.reset();
│ │ │ │ +
117 neighborIntersects2.reset();
│ │ │ │ +
118
│ │ │ │ +
119 // the intersection is either conforming or empty, hence the GeometryTypes have to match
│ │ │ │ +
120 if (grid1ElementType != grid2ElementType)
│ │ │ │ +
121 return;
│ │ │ │ +
122
│ │ │ │ +
123 // ////////////////////////////////////////////////////////////
│ │ │ │ +
124 // Find correspondences between the different corners
│ │ │ │ +
125 // ////////////////////////////////////////////////////////////
│ │ │ │ +
126 std::vector<int> other(grid1ElementCorners.size(), -1);
│ │ │ │ +
127
│ │ │ │ +
128 for (unsigned int i=0; i<grid1ElementCorners.size(); i++) {
│ │ │ │ +
129
│ │ │ │ +
130 for (unsigned int j=0; j<grid2ElementCorners.size(); j++) {
│ │ │ │ +
131
│ │ │ │ +
132 if ( (grid1ElementCorners[i]-grid2ElementCorners[j]).two_norm() < tolerance_ ) {
│ │ │ │ +
133
│ │ │ │ +
134 other[i] = j;
│ │ │ │ +
135 break;
│ │ │ │ +
136
│ │ │ │ +
137 }
│ │ │ │ +
138
│ │ │ │ +
139 }
│ │ │ │ +
140
│ │ │ │ +
141 // No corresponding grid2 vertex found for this grid1 vertex
│ │ │ │ +
142 if (other[i] == -1)
│ │ │ │ +
143 return;
│ │ │ │ +
144
│ │ │ │ +
145 }
│ │ │ │ +
146
│ │ │ │ +
147 // ////////////////////////////////////////////////////////////
│ │ │ │ +
148 // Set up the new remote intersection
│ │ │ │ +
149 // ////////////////////////////////////////////////////////////
│ │ │ │ +
150
│ │ │ │ +
151 const auto& refElement = Dune::ReferenceElements<T,dim>::general(grid1ElementType);
│ │ │ │ +
152
│ │ │ │ +
154 if (grid1ElementType.isSimplex()) {
│ │ │ │ +
155
│ │ │ │ +
156 intersections.emplace_back(grid1Index, grid2Index);
│ │ │ │ +
157
│ │ │ │ +
158 for (int i=0; i<refElement.size(dim); i++) {
│ │ │ │ +
159 intersections.back().corners0[0][i] = refElement.position(i,dim);
│ │ │ │ +
160 intersections.back().corners1[0][i] = refElement.position(other[i],dim);
│ │ │ │ +
161 }
│ │ │ │ +
162
│ │ │ │ +
163 } else if (dim == 2 && grid1ElementType.isQuadrilateral()) {
│ │ │ │ +
164
│ │ │ │ +
165 // split the quadrilateral into two triangles
│ │ │ │ +
166 const unsigned int subVertices[2][3] = {{0,1,3}, {0,3,2}};
│ │ │ │ +
167
│ │ │ │ +
168 for (int i=0; i<2; i++) {
│ │ │ │ +
169
│ │ │ │ +
170 SimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
│ │ │ │ +
171
│ │ │ │ +
172 for (int j=0; j<dim+1; j++) {
│ │ │ │ +
173 newSimplicialIntersection.corners0[0][j] = refElement.position(subVertices[i][j],dim);
│ │ │ │ +
174 newSimplicialIntersection.corners1[0][j] = refElement.position(subVertices[i][other[j]],dim);
│ │ │ │ +
175 }
│ │ │ │ +
176
│ │ │ │ +
177 intersections.push_back(newSimplicialIntersection);
│ │ │ │ +
178
│ │ │ │ +
179 }
│ │ │ │ +
180
│ │ │ │ +
181 } else if (grid1ElementType.isHexahedron()) {
│ │ │ │ +
182
│ │ │ │ +
183 // split the hexahedron into five tetrahedra
│ │ │ │ +
184 // This can be removed if ever we allow Intersections that are not simplices
│ │ │ │ +
185 const unsigned int subVertices[5][4] = {{0,1,3,5}, {0,3,2,6}, {4,5,0,6}, {6,7,6,3}, {6,0,5,3}};
│ │ │ │ +
186
│ │ │ │ +
187 for (int i=0; i<5; i++) {
│ │ │ │ +
188
│ │ │ │ +
189 SimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
│ │ │ │ +
190
│ │ │ │ +
191 for (int j=0; j<dim+1; j++) {
│ │ │ │ +
192 newSimplicialIntersection.corners0[0][j] = refElement.position(subVertices[i][j],dim);
│ │ │ │ +
193 newSimplicialIntersection.corners1[0][j] = refElement.position(subVertices[i][other[j]],dim);
│ │ │ │ +
194 }
│ │ │ │ +
195
│ │ │ │ +
196 intersections.push_back(newSimplicialIntersection);
│ │ │ │ +
197
│ │ │ │ +
198 }
│ │ │ │ +
199
│ │ │ │ +
200 } else
│ │ │ │ +
201 DUNE_THROW(Dune::GridError, "Unsupported element type");
│ │ │ │ +
202
│ │ │ │ +
203}
│ │ │ │ +
204
│ │ │ │ +
205} // namespace GridGlue
│ │ │ │ +
206
│ │ │ │ +
207} // namespace Dune
│ │ │ │ +
208
│ │ │ │ +
209#endif // DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ +
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │
Definition gridglue.hh:37
│ │ │ │ -
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
│ │ │ │ +
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ +
Implementation of the Merger concept for conforming interfaces.
Definition conformingmerge.hh:49
│ │ │ │ +
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition conformingmerge.hh:62
│ │ │ │ +
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition conformingmerge.hh:59
│ │ │ │ +
static constexpr T default_tolerance
Definition conformingmerge.hh:89
│ │ │ │ +
T ctype
the numeric type used in this interface
Definition conformingmerge.hh:56
│ │ │ │ +
ConformingMerge(T tolerance=default_tolerance)
Definition conformingmerge.hh:91
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,139 +1,253 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -merger.hh │ │ │ │ │ +conformingmerge.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 │ │ │ │ │ -12 │ │ │ │ │ -13#include │ │ │ │ │ -14 │ │ │ │ │ -15namespace Dune { │ │ │ │ │ -16namespace GridGlue { │ │ │ │ │ -17 │ │ │ │ │ -25template │ │ │ │ │ -26class Merger │ │ │ │ │ -27{ │ │ │ │ │ -28public: │ │ │ │ │ -29 │ │ │ │ │ -31 typedef Dune::FieldVector Grid1Coords; │ │ │ │ │ -32 │ │ │ │ │ -34 typedef Dune::FieldVector Grid2Coords; │ │ │ │ │ +5/* │ │ │ │ │ +6 * Filename: conformingmerge.hh │ │ │ │ │ +7 * Version: 1.0 │ │ │ │ │ +8 * Created on: Sep 14, 2009 │ │ │ │ │ +9 * Author: Oliver Sander │ │ │ │ │ +10 * --------------------------------- │ │ │ │ │ +11 * Project: dune-grid-glue │ │ │ │ │ +12 * Description: implementation of the Merger concept for conforming │ │ │ │ │ +interfaces │ │ │ │ │ +13 * │ │ │ │ │ +14 */ │ │ │ │ │ +21#ifndef DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH │ │ │ │ │ +22#define DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH │ │ │ │ │ +23 │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28 │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31 │ │ │ │ │ +32#include │ │ │ │ │ +33 │ │ │ │ │ +34#include │ │ │ │ │ 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; │ │ │ │ │ +36namespace Dune { │ │ │ │ │ +37 │ │ │ │ │ +38 namespace GridGlue { │ │ │ │ │ +39 │ │ │ │ │ +46template │ │ │ │ │ +47class ConformingMerge │ │ │ │ │ +48 : public StandardMerge │ │ │ │ │ +49{ │ │ │ │ │ +50 │ │ │ │ │ +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 } │ │ │ │ │ +62 typedef Dune::FieldVector LocalCoords; │ │ │ │ │ +63 │ │ │ │ │ +64private: │ │ │ │ │ +65 │ │ │ │ │ +66 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ +67 │ │ │ │ │ +69 T tolerance_; │ │ │ │ │ +70 │ │ │ │ │ +71 typedef typename StandardMerge::SimplicialIntersection │ │ │ │ │ +SimplicialIntersection; │ │ │ │ │ +72 │ │ │ │ │ +77 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ +78 const std::vector >& grid1ElementCorners, │ │ │ │ │ +79 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +80 unsigned int grid1Index, │ │ │ │ │ +81 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ +82 const std::vector >& grid2ElementCorners, │ │ │ │ │ +83 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +84 unsigned int grid2Index, │ │ │ │ │ +85 std::vector& intersections); │ │ │ │ │ +86 │ │ │ │ │ +87public: │ │ │ │ │ +88 │ │ │ │ │ +89 static constexpr T default_tolerance = 1e-4; │ │ │ │ │ +90 │ │ │ │ │ +91 ConformingMerge(T tolerance = default_tolerance) : │ │ │ │ │ +92 tolerance_(tolerance) │ │ │ │ │ +93 {} │ │ │ │ │ +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 │ │ │ │ │ -120#endif │ │ │ │ │ -intersectionlist.hh │ │ │ │ │ +96template │ │ │ │ │ +97constexpr T ConformingMerge::default_tolerance; │ │ │ │ │ +98 │ │ │ │ │ +99template │ │ │ │ │ +100void ConformingMerge::computeIntersections(const Dune:: │ │ │ │ │ +GeometryType& grid1ElementType, │ │ │ │ │ +101 const std::vector >& grid1ElementCorners, │ │ │ │ │ +102 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +103 unsigned int grid1Index, │ │ │ │ │ +104 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ +105 const std::vector >& grid2ElementCorners, │ │ │ │ │ +106 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +107 unsigned int grid2Index, │ │ │ │ │ +108 std::vector& intersections) │ │ │ │ │ +109{ │ │ │ │ │ +110 this->counter++; │ │ │ │ │ +111 │ │ │ │ │ +112 // A few consistency checks │ │ │ │ │ +113 assert((unsigned int)(Dune::ReferenceElements::general │ │ │ │ │ +(grid1ElementType).size(dim)) == grid1ElementCorners.size()); │ │ │ │ │ +114 assert((unsigned int)(Dune::ReferenceElements::general │ │ │ │ │ +(grid2ElementType).size(dim)) == grid2ElementCorners.size()); │ │ │ │ │ +115 // any intersection we may find will be the entire elements. │ │ │ │ │ +116 neighborIntersects1.reset(); │ │ │ │ │ +117 neighborIntersects2.reset(); │ │ │ │ │ +118 │ │ │ │ │ +119 // the intersection is either conforming or empty, hence the GeometryTypes │ │ │ │ │ +have to match │ │ │ │ │ +120 if (grid1ElementType != grid2ElementType) │ │ │ │ │ +121 return; │ │ │ │ │ +122 │ │ │ │ │ +123 // //////////////////////////////////////////////////////////// │ │ │ │ │ +124 // Find correspondences between the different corners │ │ │ │ │ +125 // //////////////////////////////////////////////////////////// │ │ │ │ │ +126 std::vector other(grid1ElementCorners.size(), -1); │ │ │ │ │ +127 │ │ │ │ │ +128 for (unsigned int i=0; i::general │ │ │ │ │ +(grid1ElementType); │ │ │ │ │ +152 │ │ │ │ │ +154 if (grid1ElementType.isSimplex()) { │ │ │ │ │ +155 │ │ │ │ │ +156 intersections.emplace_back(grid1Index, grid2Index); │ │ │ │ │ +157 │ │ │ │ │ +158 for (int i=0; i WorldCoords │ │ │ │ │ +Dune::GridGlue::intersections │ │ │ │ │ +IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ +> &reverse=!reversed) │ │ │ │ │ +Iterate over all intersections of a GridGlue. │ │ │ │ │ +Dune::GridGlue::ConformingMerge │ │ │ │ │ +Implementation of the Merger concept for conforming interfaces. │ │ │ │ │ +Definition conformingmerge.hh:49 │ │ │ │ │ +Dune::GridGlue::ConformingMerge::LocalCoords │ │ │ │ │ +Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ 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) │ │ │ │ │ -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 │ │ │ │ │ -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 conformingmerge.hh:62 │ │ │ │ │ +Dune::GridGlue::ConformingMerge::WorldCoords │ │ │ │ │ +Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition conformingmerge.hh:59 │ │ │ │ │ +Dune::GridGlue::ConformingMerge::default_tolerance │ │ │ │ │ +static constexpr T default_tolerance │ │ │ │ │ +Definition conformingmerge.hh:89 │ │ │ │ │ +Dune::GridGlue::ConformingMerge::ctype │ │ │ │ │ +T ctype │ │ │ │ │ +the numeric type used in this interface │ │ │ │ │ +Definition conformingmerge.hh:56 │ │ │ │ │ +Dune::GridGlue::ConformingMerge::ConformingMerge │ │ │ │ │ +ConformingMerge(T tolerance=default_tolerance) │ │ │ │ │ +Definition conformingmerge.hh:91 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00077.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.cc File Reference │ │ │ │ +dune-grid-glue: standardmerge.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,28 +70,110 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces
│ │ │ │ -
computeintersection.cc File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
│ │ │ │ +
standardmerge.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ +
#include "config.h"
│ │ │ │ +#include "standardmerge.hh"
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ 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
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,17 +1,52 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces │ │ │ │ │ -computeintersection.cc File Reference │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ +Namespaces | Macros | Functions │ │ │ │ │ +standardmerge.cc File Reference │ │ │ │ │ +#include "config.h" │ │ │ │ │ +#include "standardmerge.hh" │ │ │ │ │ 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 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: conformingmerge.hh File Reference │ │ │ │ +dune-grid-glue: merger.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,46 +72,37 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
conformingmerge.hh File Reference
│ │ │ │ +
merger.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

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

│ │ │ │ -
#include <iomanip>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <bitset>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ +
#include <vector>
│ │ │ │ #include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/geometry/referenceelements.hh>
│ │ │ │ -#include <dune/grid-glue/merging/standardmerge.hh>
│ │ │ │ +#include <dune/geometry/type.hh>
│ │ │ │ +#include <dune/grid-glue/merging/intersectionlist.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...
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

│ │ │ │ -

Implementation of the Merger concept for conforming interfaces.

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,31 +2,25 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -conformingmerge.hh File Reference │ │ │ │ │ -Implementation of the Merger concept for conforming interfaces. More... │ │ │ │ │ -#include │ │ │ │ │ +merger.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#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... │ │ │ │ │ +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 ***** │ │ │ │ │ -Implementation of the Merger concept for conforming interfaces. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00080_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: conformingmerge.hh Source File │ │ │ │ +dune-grid-glue: merger.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,220 +74,110 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
conformingmerge.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
│ │ │ │ -
5/*
│ │ │ │ -
6 * Filename: conformingmerge.hh
│ │ │ │ -
7 * Version: 1.0
│ │ │ │ -
8 * Created on: Sep 14, 2009
│ │ │ │ -
9 * Author: Oliver Sander
│ │ │ │ -
10 * ---------------------------------
│ │ │ │ -
11 * Project: dune-grid-glue
│ │ │ │ -
12 * Description: implementation of the Merger concept for conforming interfaces
│ │ │ │ -
13 *
│ │ │ │ -
14 */
│ │ │ │ -
21#ifndef DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ -
22#define DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ -
23
│ │ │ │ -
24#include <iomanip>
│ │ │ │ -
25#include <vector>
│ │ │ │ -
26#include <algorithm>
│ │ │ │ -
27#include <bitset>
│ │ │ │ -
28
│ │ │ │ -
29#include <dune/common/fmatrix.hh>
│ │ │ │ -
30#include <dune/common/fvector.hh>
│ │ │ │ -
31
│ │ │ │ -
32#include <dune/geometry/referenceelements.hh>
│ │ │ │ -
33
│ │ │ │ - │ │ │ │ +
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
│ │ │ │ + │ │ │ │ +
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
│ │ │ │ +
34 typedef Dune::FieldVector<ctype, grid2Dim> Grid2Coords;
│ │ │ │
35
│ │ │ │ -
36namespace Dune {
│ │ │ │ -
37
│ │ │ │ -
38 namespace GridGlue {
│ │ │ │ -
39
│ │ │ │ -
46template<int dim, int dimworld, typename T = double>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
48 : public StandardMerge<T,dim,dim,dimworld>
│ │ │ │ -
49{
│ │ │ │ -
50
│ │ │ │ -
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
│ │ │ │ -
64private:
│ │ │ │ -
65
│ │ │ │ -
66 /* M E M B E R V A R I A B L E S */
│ │ │ │ -
67
│ │ │ │ -
69 T tolerance_;
│ │ │ │ -
70
│ │ │ │ -
71 typedef typename StandardMerge<T,dim,dim,dimworld>::SimplicialIntersection SimplicialIntersection;
│ │ │ │ -
72
│ │ │ │ -
77 void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
78 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
79 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ -
80 unsigned int grid1Index,
│ │ │ │ -
81 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
82 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
83 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ -
84 unsigned int grid2Index,
│ │ │ │ -
85 std::vector<SimplicialIntersection>& intersections);
│ │ │ │ -
86
│ │ │ │ -
87public:
│ │ │ │ -
88
│ │ │ │ -
89 static constexpr T default_tolerance = 1e-4;
│ │ │ │ -
90
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
92 tolerance_(tolerance)
│ │ │ │ -
93 {}
│ │ │ │ +
│ │ │ │ +
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 }
│ │ │ │
│ │ │ │ -
94};
│ │ │ │ +
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
│ │ │ │ -
96template<int dim, int dimworld, typename T>
│ │ │ │ - │ │ │ │ -
98
│ │ │ │ -
99template<int dim, int dimworld, typename T>
│ │ │ │ -
100void ConformingMerge<dim, dimworld, T>::computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ -
101 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ -
102 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ -
103 unsigned int grid1Index,
│ │ │ │ -
104 const Dune::GeometryType& grid2ElementType,
│ │ │ │ -
105 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ -
106 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ -
107 unsigned int grid2Index,
│ │ │ │ -
108 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ -
109{
│ │ │ │ -
110 this->counter++;
│ │ │ │ -
111
│ │ │ │ -
112 // A few consistency checks
│ │ │ │ -
113 assert((unsigned int)(Dune::ReferenceElements<T,dim>::general(grid1ElementType).size(dim)) == grid1ElementCorners.size());
│ │ │ │ -
114 assert((unsigned int)(Dune::ReferenceElements<T,dim>::general(grid2ElementType).size(dim)) == grid2ElementCorners.size());
│ │ │ │ -
115 // any intersection we may find will be the entire elements.
│ │ │ │ -
116 neighborIntersects1.reset();
│ │ │ │ -
117 neighborIntersects2.reset();
│ │ │ │ -
118
│ │ │ │ -
119 // the intersection is either conforming or empty, hence the GeometryTypes have to match
│ │ │ │ -
120 if (grid1ElementType != grid2ElementType)
│ │ │ │ -
121 return;
│ │ │ │ -
122
│ │ │ │ -
123 // ////////////////////////////////////////////////////////////
│ │ │ │ -
124 // Find correspondences between the different corners
│ │ │ │ -
125 // ////////////////////////////////////////////////////////////
│ │ │ │ -
126 std::vector<int> other(grid1ElementCorners.size(), -1);
│ │ │ │ -
127
│ │ │ │ -
128 for (unsigned int i=0; i<grid1ElementCorners.size(); i++) {
│ │ │ │ -
129
│ │ │ │ -
130 for (unsigned int j=0; j<grid2ElementCorners.size(); j++) {
│ │ │ │ -
131
│ │ │ │ -
132 if ( (grid1ElementCorners[i]-grid2ElementCorners[j]).two_norm() < tolerance_ ) {
│ │ │ │ -
133
│ │ │ │ -
134 other[i] = j;
│ │ │ │ -
135 break;
│ │ │ │ -
136
│ │ │ │ -
137 }
│ │ │ │ -
138
│ │ │ │ -
139 }
│ │ │ │ -
140
│ │ │ │ -
141 // No corresponding grid2 vertex found for this grid1 vertex
│ │ │ │ -
142 if (other[i] == -1)
│ │ │ │ -
143 return;
│ │ │ │ -
144
│ │ │ │ -
145 }
│ │ │ │ -
146
│ │ │ │ -
147 // ////////////////////////////////////////////////////////////
│ │ │ │ -
148 // Set up the new remote intersection
│ │ │ │ -
149 // ////////////////////////////////////////////////////////////
│ │ │ │ -
150
│ │ │ │ -
151 const auto& refElement = Dune::ReferenceElements<T,dim>::general(grid1ElementType);
│ │ │ │ -
152
│ │ │ │ -
154 if (grid1ElementType.isSimplex()) {
│ │ │ │ -
155
│ │ │ │ -
156 intersections.emplace_back(grid1Index, grid2Index);
│ │ │ │ -
157
│ │ │ │ -
158 for (int i=0; i<refElement.size(dim); i++) {
│ │ │ │ -
159 intersections.back().corners0[0][i] = refElement.position(i,dim);
│ │ │ │ -
160 intersections.back().corners1[0][i] = refElement.position(other[i],dim);
│ │ │ │ -
161 }
│ │ │ │ -
162
│ │ │ │ -
163 } else if (dim == 2 && grid1ElementType.isQuadrilateral()) {
│ │ │ │ -
164
│ │ │ │ -
165 // split the quadrilateral into two triangles
│ │ │ │ -
166 const unsigned int subVertices[2][3] = {{0,1,3}, {0,3,2}};
│ │ │ │ -
167
│ │ │ │ -
168 for (int i=0; i<2; i++) {
│ │ │ │ -
169
│ │ │ │ -
170 SimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
│ │ │ │ -
171
│ │ │ │ -
172 for (int j=0; j<dim+1; j++) {
│ │ │ │ -
173 newSimplicialIntersection.corners0[0][j] = refElement.position(subVertices[i][j],dim);
│ │ │ │ -
174 newSimplicialIntersection.corners1[0][j] = refElement.position(subVertices[i][other[j]],dim);
│ │ │ │ -
175 }
│ │ │ │ -
176
│ │ │ │ -
177 intersections.push_back(newSimplicialIntersection);
│ │ │ │ -
178
│ │ │ │ -
179 }
│ │ │ │ -
180
│ │ │ │ -
181 } else if (grid1ElementType.isHexahedron()) {
│ │ │ │ -
182
│ │ │ │ -
183 // split the hexahedron into five tetrahedra
│ │ │ │ -
184 // This can be removed if ever we allow Intersections that are not simplices
│ │ │ │ -
185 const unsigned int subVertices[5][4] = {{0,1,3,5}, {0,3,2,6}, {4,5,0,6}, {6,7,6,3}, {6,0,5,3}};
│ │ │ │ -
186
│ │ │ │ -
187 for (int i=0; i<5; i++) {
│ │ │ │ -
188
│ │ │ │ -
189 SimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
│ │ │ │ -
190
│ │ │ │ -
191 for (int j=0; j<dim+1; j++) {
│ │ │ │ -
192 newSimplicialIntersection.corners0[0][j] = refElement.position(subVertices[i][j],dim);
│ │ │ │ -
193 newSimplicialIntersection.corners1[0][j] = refElement.position(subVertices[i][other[j]],dim);
│ │ │ │ -
194 }
│ │ │ │ -
195
│ │ │ │ -
196 intersections.push_back(newSimplicialIntersection);
│ │ │ │ -
197
│ │ │ │ -
198 }
│ │ │ │ -
199
│ │ │ │ -
200 } else
│ │ │ │ -
201 DUNE_THROW(Dune::GridError, "Unsupported element type");
│ │ │ │ -
202
│ │ │ │ -
203}
│ │ │ │ -
204
│ │ │ │ -
205} // namespace GridGlue
│ │ │ │ -
206
│ │ │ │ -
207} // namespace Dune
│ │ │ │ -
208
│ │ │ │ -
209#endif // DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
│ │ │ │ -
Common base class for many merger implementations: produce pairs of entities that may intersect.
│ │ │ │ +
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
│ │ │ │ +
120#endif
│ │ │ │ + │ │ │ │
Definition gridglue.hh:37
│ │ │ │ -
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ -
Implementation of the Merger concept for conforming interfaces.
Definition conformingmerge.hh:49
│ │ │ │ -
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition conformingmerge.hh:62
│ │ │ │ -
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition conformingmerge.hh:59
│ │ │ │ -
static constexpr T default_tolerance
Definition conformingmerge.hh:89
│ │ │ │ -
T ctype
the numeric type used in this interface
Definition conformingmerge.hh:56
│ │ │ │ -
ConformingMerge(T tolerance=default_tolerance)
Definition conformingmerge.hh:91
│ │ │ │ -
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
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,253 +1,139 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -conformingmerge.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 │ │ │ │ │ -5/* │ │ │ │ │ -6 * Filename: conformingmerge.hh │ │ │ │ │ -7 * Version: 1.0 │ │ │ │ │ -8 * Created on: Sep 14, 2009 │ │ │ │ │ -9 * Author: Oliver Sander │ │ │ │ │ -10 * --------------------------------- │ │ │ │ │ -11 * Project: dune-grid-glue │ │ │ │ │ -12 * Description: implementation of the Merger concept for conforming │ │ │ │ │ -interfaces │ │ │ │ │ -13 * │ │ │ │ │ -14 */ │ │ │ │ │ -21#ifndef DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH │ │ │ │ │ -22#define DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH │ │ │ │ │ -23 │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28 │ │ │ │ │ -29#include │ │ │ │ │ -30#include │ │ │ │ │ -31 │ │ │ │ │ -32#include │ │ │ │ │ -33 │ │ │ │ │ -34#include │ │ │ │ │ +5#ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ +6#define DUNE_GRIDGLUE_MERGING_MERGER_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9 │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13#include │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune { │ │ │ │ │ +16namespace GridGlue { │ │ │ │ │ +17 │ │ │ │ │ +25template │ │ │ │ │ +26class Merger │ │ │ │ │ +27{ │ │ │ │ │ +28public: │ │ │ │ │ +29 │ │ │ │ │ +31 typedef Dune::FieldVector Grid1Coords; │ │ │ │ │ +32 │ │ │ │ │ +34 typedef Dune::FieldVector Grid2Coords; │ │ │ │ │ 35 │ │ │ │ │ -36namespace Dune { │ │ │ │ │ -37 │ │ │ │ │ -38 namespace GridGlue { │ │ │ │ │ -39 │ │ │ │ │ -46template │ │ │ │ │ -47class ConformingMerge │ │ │ │ │ -48 : public StandardMerge │ │ │ │ │ -49{ │ │ │ │ │ -50 │ │ │ │ │ -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 │ │ │ │ │ -64private: │ │ │ │ │ -65 │ │ │ │ │ -66 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ -67 │ │ │ │ │ -69 T tolerance_; │ │ │ │ │ -70 │ │ │ │ │ -71 typedef typename StandardMerge::SimplicialIntersection │ │ │ │ │ -SimplicialIntersection; │ │ │ │ │ -72 │ │ │ │ │ -77 void computeIntersections(const Dune::GeometryType& grid1ElementType, │ │ │ │ │ -78 const std::vector >& grid1ElementCorners, │ │ │ │ │ -79 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -80 unsigned int grid1Index, │ │ │ │ │ -81 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ -82 const std::vector >& grid2ElementCorners, │ │ │ │ │ -83 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -84 unsigned int grid2Index, │ │ │ │ │ -85 std::vector& intersections); │ │ │ │ │ -86 │ │ │ │ │ -87public: │ │ │ │ │ -88 │ │ │ │ │ -89 static constexpr T default_tolerance = 1e-4; │ │ │ │ │ -90 │ │ │ │ │ -91 ConformingMerge(T tolerance = default_tolerance) : │ │ │ │ │ -92 tolerance_(tolerance) │ │ │ │ │ -93 {} │ │ │ │ │ -94}; │ │ │ │ │ +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 │ │ │ │ │ -96template │ │ │ │ │ -97constexpr T ConformingMerge::default_tolerance; │ │ │ │ │ -98 │ │ │ │ │ -99template │ │ │ │ │ -100void ConformingMerge::computeIntersections(const Dune:: │ │ │ │ │ -GeometryType& grid1ElementType, │ │ │ │ │ -101 const std::vector >& grid1ElementCorners, │ │ │ │ │ -102 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ -103 unsigned int grid1Index, │ │ │ │ │ -104 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ -105 const std::vector >& grid2ElementCorners, │ │ │ │ │ -106 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ -107 unsigned int grid2Index, │ │ │ │ │ -108 std::vector& intersections) │ │ │ │ │ -109{ │ │ │ │ │ -110 this->counter++; │ │ │ │ │ -111 │ │ │ │ │ -112 // A few consistency checks │ │ │ │ │ -113 assert((unsigned int)(Dune::ReferenceElements::general │ │ │ │ │ -(grid1ElementType).size(dim)) == grid1ElementCorners.size()); │ │ │ │ │ -114 assert((unsigned int)(Dune::ReferenceElements::general │ │ │ │ │ -(grid2ElementType).size(dim)) == grid2ElementCorners.size()); │ │ │ │ │ -115 // any intersection we may find will be the entire elements. │ │ │ │ │ -116 neighborIntersects1.reset(); │ │ │ │ │ -117 neighborIntersects2.reset(); │ │ │ │ │ -118 │ │ │ │ │ -119 // the intersection is either conforming or empty, hence the GeometryTypes │ │ │ │ │ -have to match │ │ │ │ │ -120 if (grid1ElementType != grid2ElementType) │ │ │ │ │ -121 return; │ │ │ │ │ -122 │ │ │ │ │ -123 // //////////////////////////////////////////////////////////// │ │ │ │ │ -124 // Find correspondences between the different corners │ │ │ │ │ -125 // //////////////////////////////////////////////////////////// │ │ │ │ │ -126 std::vector other(grid1ElementCorners.size(), -1); │ │ │ │ │ -127 │ │ │ │ │ -128 for (unsigned int i=0; i::general │ │ │ │ │ -(grid1ElementType); │ │ │ │ │ -152 │ │ │ │ │ -154 if (grid1ElementType.isSimplex()) { │ │ │ │ │ -155 │ │ │ │ │ -156 intersections.emplace_back(grid1Index, grid2Index); │ │ │ │ │ -157 │ │ │ │ │ -158 for (int i=0; i │ │ │ │ │ +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 │ │ │ │ │ +120#endif │ │ │ │ │ +intersectionlist.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::ConformingMerge │ │ │ │ │ -Implementation of the Merger concept for conforming interfaces. │ │ │ │ │ -Definition conformingmerge.hh:49 │ │ │ │ │ -Dune::GridGlue::ConformingMerge::LocalCoords │ │ │ │ │ -Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ +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 conformingmerge.hh:62 │ │ │ │ │ -Dune::GridGlue::ConformingMerge::WorldCoords │ │ │ │ │ -Dune::FieldVector< T, dimworld > WorldCoords │ │ │ │ │ -the coordinate type used in this interface │ │ │ │ │ -Definition conformingmerge.hh:59 │ │ │ │ │ -Dune::GridGlue::ConformingMerge::default_tolerance │ │ │ │ │ -static constexpr T default_tolerance │ │ │ │ │ -Definition conformingmerge.hh:89 │ │ │ │ │ -Dune::GridGlue::ConformingMerge::ctype │ │ │ │ │ -T ctype │ │ │ │ │ -the numeric type used in this interface │ │ │ │ │ -Definition conformingmerge.hh:56 │ │ │ │ │ -Dune::GridGlue::ConformingMerge::ConformingMerge │ │ │ │ │ -ConformingMerge(T tolerance=default_tolerance) │ │ │ │ │ -Definition conformingmerge.hh:91 │ │ │ │ │ -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 │ │ │ │ │ +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 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: simplexintersection.cc File Reference │ │ │ │ +dune-grid-glue: computeintersection.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -73,66 +73,44 @@ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ -
simplexintersection.cc File Reference
│ │ │ │ +
computeintersection.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ +
#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/common/fmatrix.hh>
│ │ │ │ +#include "simplexintersection.cc"
│ │ │ │ +#include "computeintersection.cc"
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

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

│ │ │ │ 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::ComputationMethod< dimWorld, dim1, dim2, T >
 
class  Dune::GridGlue::SimplexMethod< dimWorld, 3, 3, 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 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)
 
template<class V >
int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -2,64 +2,31 @@ │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ Classes | Namespaces | Functions │ │ │ │ │ -simplexintersection.cc File Reference │ │ │ │ │ +computeintersection.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include "simplexintersection.cc" │ │ │ │ │ +#include "computeintersection.cc" │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::GridGlue::SimplexMethod<_dimWorld,_dim1,_dim2,_T_> │ │ │ │ │ +class   Dune::GridGlue::ComputationMethod<_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_> │ │ │ │ │ +class   Dune::GridGlue::IntersectionComputation<_CM_> │ │ │ │ │ +  Intersection computation method for two elements of arbitrary │ │ │ │ │ + dimension. More... │ │ │ │ │   │ │ │ │ │ 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) │ │ │ │ │ +template │ │ │ │ │ +int  Dune::GridGlue::insertPoint (const V p, std::vector< V > &P) │ │ │ │ │   │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00086_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: simplexintersection.cc Source File │ │ │ │ +dune-grid-glue: computeintersection.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,1430 +74,190 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
simplexintersection.cc
│ │ │ │ +
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
│ │ │ │ +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
│ │ │ │ -
6namespace Dune {
│ │ │ │ -
7namespace GridGlue {
│ │ │ │ +
6#include <dune/common/fvector.hh>
│ │ │ │ +
7#include <dune/common/fmatrix.hh>
│ │ │ │
8
│ │ │ │ -
9template <int dimworld, typename T>
│ │ │ │ -
10inline void simplexSubdivision(std::integral_constant<int,0>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
11 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
12 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
13template <int dimworld, typename T>
│ │ │ │ -
14inline void simplexSubdivision(std::integral_constant<int,1>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
15 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
16 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
17template <int dimworld, typename T>
│ │ │ │ -
18inline void simplexSubdivision(std::integral_constant<int,2>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
19 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
20 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
21template <int dimworld, typename T>
│ │ │ │ -
22inline void simplexSubdivision(std::integral_constant<int,3>,const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
23 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
24 std::vector<std::vector<int> >& faceIds);
│ │ │ │ -
25
│ │ │ │ -
26
│ │ │ │ -
27
│ │ │ │ -
28// *****************SIMPLEX INTERSECTION COMPUTATION METHODS ***************************
│ │ │ │ -
29template<int dimWorld,int dim1, int dim2, typename T>
│ │ │ │ -
│ │ │ │ -
30class SimplexMethod : public ComputationMethod<dimWorld,dim1,dim2,T>{
│ │ │ │ -
31 static_assert(dim1 > dim2, "Specialization missing");
│ │ │ │ -
32 friend class ComputationMethod<dimWorld,dim1,dim2,T>;
│ │ │ │ -
33public:
│ │ │ │ -
34 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
35 static const int grid1Dimension = dim1;
│ │ │ │ -
36 static const int grid2Dimension = dim2;
│ │ │ │ -
37 static const int intersectionDimension = dim2;
│ │ │ │ -
38
│ │ │ │ -
│ │ │ │ -
39 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
40 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
41 std::vector<std::vector<int> > & SX,
│ │ │ │ -
42 std::vector<std::vector<int> > & SY,
│ │ │ │ -
43 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
44 {
│ │ │ │ - │ │ │ │ -
46 }
│ │ │ │ -
│ │ │ │ -
47
│ │ │ │ -
│ │ │ │ -
48 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
49 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
50 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
51 {
│ │ │ │ -
52 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
53 elementCorners,subElements, faceIds);
│ │ │ │ -
54 }
│ │ │ │ -
│ │ │ │ -
55
│ │ │ │ -
56 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
57 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
58 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
59 {
│ │ │ │ -
60 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
61 elementCorners, subElements, faceIds);
│ │ │ │ -
62 }
│ │ │ │ -
63};
│ │ │ │ -
│ │ │ │ +
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
│ │ │ │ -
65
│ │ │ │ -
66
│ │ │ │ -
67// POINTS ARE EQUAL
│ │ │ │ -
68template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
69class SimplexMethod<dimWorld,0,0,T> : public ComputationMethod<dimWorld,0,0,T>{
│ │ │ │ -
70 friend class ComputationMethod<dimWorld,0,0,T>;
│ │ │ │ -
71
│ │ │ │ -
72public:
│ │ │ │ -
73 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
74 static const int grid1Dimension = 0;
│ │ │ │ -
75 static const int grid2Dimension = 0;
│ │ │ │ -
76 static const int intersectionDimension = 0;
│ │ │ │ -
77
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
79 const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
80 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
81 std::vector<std::vector<int> > & SX,
│ │ │ │ -
82 std::vector<std::vector<int> > & SY,
│ │ │ │ -
83 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
84 {
│ │ │ │ -
85 assert(X.size() == 1 && Y.size() == 1);
│ │ │ │ -
86
│ │ │ │ -
87 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
88 int k;
│ │ │ │ -
89
│ │ │ │ -
90 T eps = 1e-8;
│ │ │ │ -
91 T a = X[0].infinity_norm();
│ │ │ │ -
92 T b = Y[0].infinity_norm();
│ │ │ │ -
93 T c = (X[0] - Y[0]).infinity_norm();
│ │ │ │ -
94
│ │ │ │ -
95 if (c <= eps*a || c <= eps*b ||
│ │ │ │ -
96 (a<eps && b< eps && c < 0.5*eps) ) {
│ │ │ │ -
97 k = insertPoint(X[0],P);
│ │ │ │ -
98
│ │ │ │ -
99 return true;
│ │ │ │ -
100 }
│ │ │ │ -
101 return false;
│ │ │ │ -
102 }
│ │ │ │ -
│ │ │ │ -
103
│ │ │ │ -
│ │ │ │ -
104 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
105 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
106 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
107 {
│ │ │ │ -
108 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
109 elementCorners,subElements, faceIds);
│ │ │ │ -
110 }
│ │ │ │ -
│ │ │ │ -
111
│ │ │ │ -
112 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
113 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
114 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
115 {
│ │ │ │ -
116 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
117 elementCorners, subElements, faceIds);
│ │ │ │ -
118 }
│ │ │ │ -
119
│ │ │ │ -
120};
│ │ │ │ -
│ │ │ │ -
121
│ │ │ │ -
122
│ │ │ │ -
123// POINT ON LINE SEGMENT - :)
│ │ │ │ -
124template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
125class SimplexMethod<dimWorld,0,1,T> : public ComputationMethod<dimWorld,0,1,T>{
│ │ │ │ -
126 friend class ComputationMethod<dimWorld,0,1,T>;
│ │ │ │ -
127
│ │ │ │ -
128public:
│ │ │ │ -
129 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
130 static const int grid1Dimension = 0;
│ │ │ │ -
131 static const int grid2Dimension = 1;
│ │ │ │ -
132 static const int intersectionDimension = 0;
│ │ │ │ -
133
│ │ │ │ -
│ │ │ │ -
134 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
135 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
136 std::vector<std::vector<int> > & SX,
│ │ │ │ -
137 std::vector<std::vector<int> > & SY,
│ │ │ │ -
138 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
139 {
│ │ │ │ -
140 assert(X.size() == 1 && Y.size() == 2);
│ │ │ │ -
141
│ │ │ │ -
142 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
143 SY.resize(2);
│ │ │ │ -
144
│ │ │ │ -
145 if (dimWorld == 1) {
│ │ │ │ -
146 T lowerBound = std::max(X[0][0], std::min(Y[0][0],Y[1][0]));
│ │ │ │ -
147 T upperBound = std::min(X[0][0], std::max(Y[0][0],Y[1][0]));
│ │ │ │ -
148
│ │ │ │ -
149 if (lowerBound <= upperBound) { // Intersection is non-empty
│ │ │ │ -
150 insertPoint(X[0],P);
│ │ │ │ -
151 return true;
│ │ │ │ -
152 }
│ │ │ │ -
153 } else {
│ │ │ │ -
154
│ │ │ │ -
155 T eps = 1e-8;
│ │ │ │ -
156
│ │ │ │ -
157 // check whether the point is on the segment
│ │ │ │ -
158 FieldVector<T,dimWorld> v0 = X[0] - Y[0];
│ │ │ │ -
159 FieldVector<T,dimWorld> v1 = X[0] - Y[1];
│ │ │ │ -
160 FieldVector<T,dimWorld> v2 = Y[1] - Y[0];
│ │ │ │ -
161
│ │ │ │ -
162 T s = v0.dot(v1);
│ │ │ │ -
163 T t = v0.two_norm()/v2.two_norm();
│ │ │ │ -
164 v2*=t;
│ │ │ │ -
165 v2+=Y[0];
│ │ │ │ -
166 v2-=X[0];
│ │ │ │ -
167
│ │ │ │ -
168 if (v2.infinity_norm() < eps && s<=eps && t<=1+eps) {
│ │ │ │ -
169
│ │ │ │ -
170 int k = insertPoint(X[0],P);
│ │ │ │ -
171 if (s < eps && t < eps)
│ │ │ │ -
172 SY[0].push_back(k);
│ │ │ │ -
173 else if (s < eps && t>1-eps)
│ │ │ │ -
174 SY[1].push_back(k);
│ │ │ │ -
175 return true;
│ │ │ │ -
176 }
│ │ │ │ -
177 }
│ │ │ │ -
178 return false;
│ │ │ │ -
179 }
│ │ │ │ -
│ │ │ │ +
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 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
182 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
183 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
184 {
│ │ │ │ -
185 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
186 elementCorners,subElements, faceIds);
│ │ │ │ -
187 }
│ │ │ │ +
181 }
│ │ │ │ +
182 else
│ │ │ │ +
183 P.push_back(p);
│ │ │ │ +
184
│ │ │ │ +
185 return k ;
│ │ │ │ +
186}
│ │ │ │
│ │ │ │ +
187
│ │ │ │
188
│ │ │ │ -
189 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
190 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
191 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
192 {
│ │ │ │ -
193 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
194 elementCorners, subElements, faceIds);
│ │ │ │ -
195 }
│ │ │ │ -
196
│ │ │ │ -
197};
│ │ │ │ -
│ │ │ │ -
198
│ │ │ │ -
199
│ │ │ │ -
200// POINT IN TRIANGLE - :)
│ │ │ │ -
201template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
202class SimplexMethod<dimWorld,0,2,T> : public ComputationMethod<dimWorld,0,2,T>{
│ │ │ │ -
203 friend class ComputationMethod<dimWorld,0,2,T>;
│ │ │ │ -
204
│ │ │ │ -
205public:
│ │ │ │ -
206 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
207 static const int grid1Dimension = 0;
│ │ │ │ -
208 static const int grid2Dimension = 2;
│ │ │ │ -
209 static const int intersectionDimension = 0;
│ │ │ │ -
210
│ │ │ │ -
│ │ │ │ -
211 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
212 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
213 std::vector<std::vector<int> > & SX,
│ │ │ │ -
214 std::vector<std::vector<int> > & SY,
│ │ │ │ -
215 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
216 {
│ │ │ │ -
217 assert(X.size() == 1 && Y.size() == 3 && dimWorld > 1);
│ │ │ │ -
218
│ │ │ │ -
219 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
220 SY.resize(3);
│ │ │ │ -
221 int k;
│ │ │ │ -
222
│ │ │ │ -
223 // If not, check whether it is inside the triangle
│ │ │ │ -
224 double eps= 1e-8 ; // tolerance for relative error
│ │ │ │ -
225
│ │ │ │ -
226 FieldVector<T,dimWorld> v0,v1,v2,r;
│ │ │ │ -
227
│ │ │ │ -
228 v0 = Y[1] - Y[0];
│ │ │ │ -
229 v1 = Y[2] - Y[0];
│ │ │ │ -
230 v2 = X[0] - Y[0];
│ │ │ │ -
231
│ │ │ │ -
232 T s,t,d;
│ │ │ │ -
233
│ │ │ │ -
234 d = ((v0.dot(v0))*(v1.dot(v1)) - (v0.dot(v1))*(v0.dot(v1)));
│ │ │ │ -
235
│ │ │ │ -
236 s = ((v1.dot(v1))*(v0.dot(v2)) - (v0.dot(v1))*(v1.dot(v2))) / d;
│ │ │ │ -
237 t = ((v0.dot(v0))*(v1.dot(v2)) - (v0.dot(v1))*(v0.dot(v2))) / d;
│ │ │ │ -
238
│ │ │ │ -
239 v0*=s;
│ │ │ │ -
240 v1*=t;
│ │ │ │ -
241 r = Y[0] + v0 + v1;
│ │ │ │ -
242
│ │ │ │ -
243 if (s > -eps && t > -eps && (s+t)< 1+eps && (r-X[0]).infinity_norm() < eps) {
│ │ │ │ -
244 k = insertPoint(X[0],P);
│ │ │ │ -
245
│ │ │ │ -
246 if (t < eps) { // t ~ 0, s varies -> edge 0
│ │ │ │ -
247 SY[0].push_back(k);
│ │ │ │ -
248 }
│ │ │ │ -
249 if (s < eps) { // s ~ 0, t varies -> edge 1
│ │ │ │ -
250 SY[1].push_back(k);
│ │ │ │ -
251 }
│ │ │ │ -
252 if (s+t > 1-eps) { // s+t ~ 1 -> edge 2
│ │ │ │ -
253 SY[2].push_back(k);
│ │ │ │ -
254 }
│ │ │ │ -
255
│ │ │ │ -
256 return true;
│ │ │ │ -
257 }
│ │ │ │ -
258
│ │ │ │ -
259 return false;
│ │ │ │ -
260 }
│ │ │ │ -
│ │ │ │ -
261
│ │ │ │ -
│ │ │ │ -
262 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
263 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
264 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
265 {
│ │ │ │ -
266 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
267 elementCorners,subElements, faceIds);
│ │ │ │ -
268 }
│ │ │ │ -
│ │ │ │ -
269
│ │ │ │ -
270 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
271 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
272 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
273 {
│ │ │ │ -
274 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
275 elementCorners, subElements, faceIds);
│ │ │ │ -
276 }
│ │ │ │ -
277};
│ │ │ │ -
│ │ │ │ -
278
│ │ │ │ -
279
│ │ │ │ -
280// POINT IN TETRAHEDRON - : )
│ │ │ │ -
281template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
282class SimplexMethod<dimWorld,0,3,T> : public ComputationMethod<dimWorld,0,3,T>{
│ │ │ │ -
283 friend class ComputationMethod<dimWorld,0,3,T>;
│ │ │ │ -
284
│ │ │ │ -
285public:
│ │ │ │ -
286 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
287 static const int grid1Dimension = 0;
│ │ │ │ -
288 static const int grid2Dimension = 3;
│ │ │ │ -
289 static const int intersectionDimension = 0;
│ │ │ │ -
290
│ │ │ │ -
│ │ │ │ -
291 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
292 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
293 std::vector<std::vector<int> > & SX,
│ │ │ │ -
294 std::vector<std::vector<int> > & SY,
│ │ │ │ -
295 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
296 {
│ │ │ │ -
297 assert(X.size() == 1 && Y.size() == 4 && dimWorld == 3);
│ │ │ │ -
298
│ │ │ │ -
299 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
300 SY.resize(4);
│ │ │ │ -
301
│ │ │ │ -
302 T eps = 1e-8;
│ │ │ │ -
303 // if not, check whether its inside the tetrahedron
│ │ │ │ -
304 FieldMatrix<T,dimWorld+1,dimWorld+1> D,DD ;
│ │ │ │ -
305
│ │ │ │ -
306 D[0][0] = Y[0][0] ; D[0][1] = Y[1][0] ; D[0][2] = Y[2][0] ; D[0][3] = Y[3][0] ;
│ │ │ │ -
307 D[1][0] = Y[0][1] ; D[1][1] = Y[1][1] ; D[1][2] = Y[2][1] ; D[1][3] = Y[3][1] ;
│ │ │ │ -
308 D[2][0] = Y[0][2] ; D[2][1] = Y[1][2] ; D[2][2] = Y[2][2] ; D[2][3] = Y[3][2] ;
│ │ │ │ -
309 D[3][0] = 1 ; D[3][1] = 1 ; D[3][2] = 1 ; D[3][3] = 1 ;
│ │ │ │ -
310
│ │ │ │ -
311 std::array<T, 5> detD;
│ │ │ │ -
312 detD[0] = D.determinant();
│ │ │ │ -
313
│ │ │ │ -
314 for(unsigned i = 1; i < detD.size(); ++i) {
│ │ │ │ -
315 DD = D;
│ │ │ │ -
316 for (unsigned d = 0; d < dimWorld; ++d)
│ │ │ │ -
317 DD[d][i-1] = X[0][d];
│ │ │ │ -
318 detD[i] = DD.determinant();
│ │ │ │ -
319 if (std::abs(detD[i]) > eps && std::signbit(detD[0]) != std::signbit(detD[i]))
│ │ │ │ -
320 return false; // We are outside.
│ │ │ │ -
321 }
│ │ │ │ -
322
│ │ │ │ -
323 int k = insertPoint(X[0],P);
│ │ │ │ -
324 unsigned int faces[4] = {3,2,1,0};
│ │ │ │ -
325 for (unsigned i = 1; i < detD.size(); ++i)
│ │ │ │ -
326 if(std::abs(detD[i]) < eps)
│ │ │ │ -
327 SY[faces[i-1]].push_back(k); // on triangle not containing node i-1
│ │ │ │ -
328
│ │ │ │ -
329 return true;
│ │ │ │ -
330 }
│ │ │ │ -
│ │ │ │ -
331
│ │ │ │ -
│ │ │ │ -
332 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
333 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
334 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
335 {
│ │ │ │ -
336 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
337 elementCorners,subElements, faceIds);
│ │ │ │ -
338 }
│ │ │ │ -
│ │ │ │ -
339
│ │ │ │ -
340 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
341 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
342 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
343 {
│ │ │ │ -
344 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
345 elementCorners, subElements, faceIds);
│ │ │ │ -
346 }
│ │ │ │ -
347};
│ │ │ │ -
│ │ │ │ -
348
│ │ │ │ -
349// SEGEMENT-SEGMENT INTERSECTION - :)
│ │ │ │ -
350template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
351class SimplexMethod<dimWorld,1,1,T> : public ComputationMethod<dimWorld,1,1,T>{
│ │ │ │ -
352 friend class ComputationMethod<dimWorld,1,1,T>;
│ │ │ │ -
353
│ │ │ │ -
354public:
│ │ │ │ -
355 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
356 static const int grid1Dimension = 1;
│ │ │ │ -
357 static const int grid2Dimension = 1;
│ │ │ │ -
358 static const int intersectionDimension = 1;
│ │ │ │ -
359
│ │ │ │ -
│ │ │ │ -
360 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
361 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
362 std::vector<std::vector<int> > & SX,
│ │ │ │ -
363 std::vector<std::vector<int> > & SY,
│ │ │ │ -
364 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
365 {
│ │ │ │ -
366 assert(X.size() == 2 && Y.size() == 2);
│ │ │ │ -
367
│ │ │ │ -
368 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
369 SX.resize(2);
│ │ │ │ -
370 SY.resize(2);
│ │ │ │ -
371 T eps = 1e-8;
│ │ │ │ -
372 int k,idX_min=-1,idX_max=-1,idY_min=-1,idY_max=-1;
│ │ │ │ -
373
│ │ │ │ -
374 // compute intersections
│ │ │ │ -
375 switch (dimWorld) {
│ │ │ │ -
376 case 1: // d
│ │ │ │ -
377 {
│ │ │ │ -
378 FieldVector<T,dimWorld> lowerbound(std::max(std::min(X[0][0],X[1][0]), std::min(Y[0][0],X[1][0])));
│ │ │ │ -
379 FieldVector<T,dimWorld> upperbound(std::min(std::max(X[0][0],X[1][0]), std::max(Y[0][0],Y[1][0])));
│ │ │ │ -
380
│ │ │ │ -
381 if (lowerbound[0] < upperbound[0]) { // Intersection is non-empty
│ │ │ │ -
382
│ │ │ │ -
383 idX_min = (std::min(X[0][0],X[1][0]) < std::min(Y[0][0],Y[1][0]))?(-1):((X[0][0]<X[1][0])?(0):(1));
│ │ │ │ -
384 if (idX_min < 0)
│ │ │ │ -
385 idY_min = ((Y[0][0]<Y[1][0])?(0):(1));
│ │ │ │ -
386
│ │ │ │ -
387 idX_max = (std::max(X[0][0],X[1][0]) > std::max(Y[0][0],Y[1][0]))?(-1):((X[0][0]>X[1][0])?(0):(1));
│ │ │ │ -
388 if (idX_max < 0)
│ │ │ │ -
389 idY_max = ((Y[0][0]>Y[1][0])?(0):(1));
│ │ │ │ -
390
│ │ │ │ -
391 k = insertPoint(lowerbound,P);
│ │ │ │ -
392 if (idX_min >= 0)
│ │ │ │ -
393 SX[idX_min].push_back(k);
│ │ │ │ -
394 else
│ │ │ │ -
395 SY[idY_min].push_back(k);
│ │ │ │ -
396
│ │ │ │ -
397 k = insertPoint(upperbound,P);
│ │ │ │ -
398 if (idX_max >= 0)
│ │ │ │ -
399 SX[idX_max].push_back(k);
│ │ │ │ -
400 else
│ │ │ │ -
401 SY[idY_max].push_back(k);
│ │ │ │ -
402
│ │ │ │ -
403 return true;
│ │ │ │ -
404 }
│ │ │ │ -
405 return false;
│ │ │ │ -
406 }
│ │ │ │ -
407 case 2: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0)
│ │ │ │ -
408 { // get size_type for all the vectors we are using
│ │ │ │ -
409
│ │ │ │ -
410 FieldMatrix<T,dimWorld, dimWorld> A;
│ │ │ │ -
411 A[0][0] = X[1][0] - X[0][0]; A[0][1] = Y[0][0] - Y[1][0];
│ │ │ │ -
412 A[1][0] = X[1][1] - X[0][1]; A[1][1] = Y[0][1] - Y[1][1];
│ │ │ │ -
413
│ │ │ │ -
414 if (std::abs(A.determinant())>eps) {
│ │ │ │ -
415 // lines are non parallel and not degenerated
│ │ │ │ -
416 FieldVector<T,dimWorld> p,r,b = Y[0] - X[0];
│ │ │ │ -
417 A.solve(r,b) ;
│ │ │ │ -
418
│ │ │ │ -
419 if ((r[0]>-eps)&&(r[0]<=1+eps)&&(r[1]>-eps)&&(r[1]<1+eps)) {
│ │ │ │ -
420 p = X[1] - X[0];
│ │ │ │ -
421 p *= r[0] ;
│ │ │ │ -
422 p += X[0] ;
│ │ │ │ -
423 k = insertPoint(p,P);
│ │ │ │ -
424 if(r[0] < eps) { // X = X_0 + r_0 (X_1 - X_0) = X_0
│ │ │ │ -
425 SX[0].push_back(k);
│ │ │ │ -
426 P[k] = X[0];
│ │ │ │ -
427 }
│ │ │ │ -
428 else if(r[0] > 1-eps) { // X = X_0 + r_0 (X_1 - X_0) = X_1
│ │ │ │ -
429 SX[1].push_back(k);
│ │ │ │ -
430 P[k] = X[1];
│ │ │ │ -
431 }
│ │ │ │ -
432 if(r[1] < eps){ // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_0
│ │ │ │ -
433 SY[0].push_back(k);
│ │ │ │ -
434 P[k] = Y[0];
│ │ │ │ -
435 }
│ │ │ │ -
436 else if(r[1] > 1-eps) { // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_1
│ │ │ │ -
437 SY[1].push_back(k);
│ │ │ │ -
438 P[k] = Y[1];
│ │ │ │ -
439 }
│ │ │ │ -
440 return true;
│ │ │ │ -
441 }
│ │ │ │ -
442 } else if ((X[1]-X[0]).infinity_norm() > eps && (Y[1]-Y[0]).infinity_norm() > eps) {
│ │ │ │ -
443 // lines are parallels, but non degenerated
│ │ │ │ -
444 bool found = false;
│ │ │ │ -
445
│ │ │ │ -
446 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2 for non perpendicular lines
│ │ │ │ -
447 for (unsigned i = 0; i < 2; ++i) {
│ │ │ │ -
448 if (std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm())
│ │ │ │ -
449 - std::abs((X[1]-X[0]).two_norm())) < eps) {
│ │ │ │ -
450 k = insertPoint(Y[i],P);
│ │ │ │ -
451 SY[i].push_back(k);
│ │ │ │ -
452 found = true;
│ │ │ │ -
453 }
│ │ │ │ -
454 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm())
│ │ │ │ -
455 - std::abs((Y[1]-Y[0]).two_norm())) < eps) {
│ │ │ │ -
456 k = insertPoint(X[i],P);
│ │ │ │ -
457 SX[i].push_back(k);
│ │ │ │ -
458 found = true;
│ │ │ │ -
459 }
│ │ │ │ -
460 }
│ │ │ │ -
461 return found;
│ │ │ │ -
462 }
│ │ │ │ -
463 return false;
│ │ │ │ -
464 }
│ │ │ │ -
465 case 3: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0)
│ │ │ │ -
466 { FieldVector<T,dimWorld> dX, dY, dZ, cXY, cYZ;
│ │ │ │ -
467
│ │ │ │ -
468 dX = X[1]-X[0];
│ │ │ │ -
469 dY = Y[1]-Y[0];
│ │ │ │ -
470 dZ = Y[0]-X[0];
│ │ │ │ -
471
│ │ │ │ -
472 cXY[0] = dX[1]* dY[2] - dX[2]* dY[1];
│ │ │ │ -
473 cXY[1] = dX[2]* dY[0] - dX[0]* dY[2];
│ │ │ │ -
474 cXY[2] = dX[0]* dY[1] - dX[1]* dY[0];
│ │ │ │ -
475
│ │ │ │ -
476 if (fabs(dZ.dot(cXY)) < eps*1e+3 && cXY.infinity_norm()>eps) { // coplanar, but not aligned
│ │ │ │ -
477
│ │ │ │ -
478 cYZ[0] = dY[1]* dZ[2] - dY[2]* dZ[1];
│ │ │ │ -
479 cYZ[1] = dY[2]* dZ[0] - dY[0]* dZ[2];
│ │ │ │ -
480 cYZ[2] = dY[0]* dZ[1] - dY[1]* dZ[0];
│ │ │ │ -
481
│ │ │ │ -
482 T s = -cYZ.dot(cXY) / cXY.two_norm2();
│ │ │ │ -
483
│ │ │ │ -
484 if (s > -eps && s < 1+eps) {
│ │ │ │ -
485 dX*= s;
│ │ │ │ -
486 dX+= X[0];
│ │ │ │ -
487 T o = (dX - Y[0]).two_norm() + (dX- Y[1]).two_norm();
│ │ │ │ -
488
│ │ │ │ -
489 if (std::abs(o-dY.two_norm()) < eps) {
│ │ │ │ -
490 k = insertPoint(dX,P);
│ │ │ │ -
491 \
│ │ │ │ -
492 if (s<eps) {
│ │ │ │ -
493 P[k] = X[0];
│ │ │ │ -
494 SX[0].push_back(k);
│ │ │ │ -
495 } else if(s > 1-eps) {
│ │ │ │ -
496 P[k] = X[1];
│ │ │ │ -
497 SX[1].push_back(k);
│ │ │ │ -
498 } else if ((dX - Y[0]).two_norm() < eps) {
│ │ │ │ -
499 P[k] = Y[0];
│ │ │ │ -
500 SY[0].push_back(k);
│ │ │ │ -
501 } else if((dX - Y[1]).two_norm() < eps) {
│ │ │ │ -
502 P[k] = Y[1];
│ │ │ │ -
503 SY[1].push_back(k);
│ │ │ │ -
504 }
│ │ │ │ -
505
│ │ │ │ -
506 return true;
│ │ │ │ -
507 }
│ │ │ │ -
508 }
│ │ │ │ -
509 } else if (cXY.infinity_norm() <= eps) {// lines are parallel
│ │ │ │ -
510
│ │ │ │ -
511 bool found = false;
│ │ │ │ -
512
│ │ │ │ -
513 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2,
│ │ │ │ -
514 // under the assumption (a-c)*(c-b) > 0 or (a-c) = 0 or (c-b) = 0
│ │ │ │ -
515 for (unsigned i = 0; i < 2; ++i) {
│ │ │ │ -
516 if ((std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) // triangle equality
│ │ │ │ -
517 - std::abs((X[1]-X[0]).two_norm())) < eps) &&
│ │ │ │ -
518 (std::abs((Y[i]-X[0]).dot((Y[i]-X[1]))) > eps // assumption
│ │ │ │ -
519 || (Y[i]-X[0]).infinity_norm() < eps || (Y[i]-X[1]).infinity_norm() < eps)) {
│ │ │ │ -
520 k = insertPoint(Y[i],P);
│ │ │ │ -
521 SY[i].push_back(k);
│ │ │ │ -
522 found = true;
│ │ │ │ -
523 }
│ │ │ │ -
524 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) // triangle equality
│ │ │ │ -
525 - std::abs((Y[1]-Y[0]).two_norm())) < eps &&
│ │ │ │ -
526 (std::abs((X[i]-Y[0]).dot((X[i]-Y[1]))) > eps // assumption
│ │ │ │ -
527 || (X[i]-Y[0]).infinity_norm() < eps || (X[i]-Y[1]).infinity_norm() < eps)){
│ │ │ │ -
528 k = insertPoint(X[i],P);
│ │ │ │ -
529 SX[i].push_back(k);
│ │ │ │ -
530 found = true;
│ │ │ │ -
531 }
│ │ │ │ -
532 }
│ │ │ │ -
533 return found;
│ │ │ │ -
534 }
│ │ │ │ -
535
│ │ │ │ -
536 return false;
│ │ │ │ -
537 }
│ │ │ │ -
538 }
│ │ │ │ -
539 return false;
│ │ │ │ -
540 }
│ │ │ │ -
│ │ │ │ -
541
│ │ │ │ -
│ │ │ │ -
542 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
543 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
544 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
545 {
│ │ │ │ -
546 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
547 elementCorners,subElements, faceIds);
│ │ │ │ -
548 }
│ │ │ │ -
│ │ │ │ -
549
│ │ │ │ -
550 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
551 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
552 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
553 {
│ │ │ │ -
554 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
555 elementCorners, subElements, faceIds);
│ │ │ │ -
556 }
│ │ │ │ -
557};
│ │ │ │ -
│ │ │ │ -
558
│ │ │ │ -
559// SEGEMENT-TRIANGLE INTERSECTION - : )
│ │ │ │ -
560template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
561class SimplexMethod<dimWorld,1,2,T> : public ComputationMethod<dimWorld,1,2,T>{
│ │ │ │ -
562 friend class ComputationMethod<dimWorld,1,2,T>;
│ │ │ │ -
563
│ │ │ │ -
564public:
│ │ │ │ -
565 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
566 static const int grid1Dimension = 1;
│ │ │ │ -
567 static const int grid2Dimension = 2;
│ │ │ │ -
568 static const int intersectionDimension = 1;
│ │ │ │ -
569
│ │ │ │ -
│ │ │ │ -
570 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
571 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
572 std::vector<std::vector<int> > & SX,
│ │ │ │ -
573 std::vector<std::vector<int> > & SY,
│ │ │ │ -
574 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
575 {
│ │ │ │ -
576
│ │ │ │ -
577 assert(X.size() == 2 && Y.size() == 3 && dimWorld > 1);
│ │ │ │ -
578 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
579 SX.resize(2);
│ │ │ │ -
580 SY.resize(3);
│ │ │ │ -
581
│ │ │ │ -
582 int k;
│ │ │ │ -
583 std::vector<FieldVector<T,dimWorld> > surfPts, edge(2), pni(1);
│ │ │ │ -
584 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ -
585
│ │ │ │ -
586 // is any segment point inside the triangle?
│ │ │ │ -
587 for (unsigned ni = 0; ni < 2; ++ni) {
│ │ │ │ -
588 pni[0] = X[ni];
│ │ │ │ -
589
│ │ │ │ - │ │ │ │ -
591 k = insertPoint(X[ni],P);
│ │ │ │ -
592 SX[ni].push_back(k);
│ │ │ │ -
593 for (unsigned e=0; e < 3; ++e)
│ │ │ │ -
594 if (hSY[e].size() > 0)
│ │ │ │ -
595 SY[e].push_back(k);
│ │ │ │ -
596
│ │ │ │ -
597 }
│ │ │ │ -
598 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ -
599 }
│ │ │ │ -
600
│ │ │ │ -
601 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ -
602 return true;
│ │ │ │ -
603
│ │ │ │ -
604 unsigned int faces[3] = {0,2,1};
│ │ │ │ -
605 // do triangle faces intersect with the segment?
│ │ │ │ -
606 for (unsigned ni = 0; ni < 3; ++ni) {
│ │ │ │ -
607 edge[0] = Y[ni];
│ │ │ │ -
608 edge[1] = Y[(ni+1)%3];
│ │ │ │ -
609
│ │ │ │ - │ │ │ │ -
611 for (unsigned ne = 0; ne < surfPts.size(); ++ne) {
│ │ │ │ -
612 k = insertPoint(surfPts[ne],P);
│ │ │ │ -
613 SY[faces[ni]].push_back(k);
│ │ │ │ -
614 if (hSX[0].size() > 0)
│ │ │ │ -
615 SX[0].push_back(k);
│ │ │ │ -
616 if (hSX[1].size() > 0)
│ │ │ │ -
617 SX[1].push_back(k);
│ │ │ │ -
618 }
│ │ │ │ -
619
│ │ │ │ -
620 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ -
621 return true;
│ │ │ │ -
622
│ │ │ │ -
623 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ -
624 }
│ │ │ │ -
625 }
│ │ │ │ -
626
│ │ │ │ -
627 if (P.size() >= 2) // we cannot have more than two intersection points
│ │ │ │ -
628 return true;
│ │ │ │ -
629
│ │ │ │ -
630 // if line and triangle are not coplanar in 3d and do not intersect at boundaries
│ │ │ │ -
631 if (dimWorld == 3) {
│ │ │ │ -
632 T eps = 1e-8;
│ │ │ │ -
633
│ │ │ │ -
634 Dune::FieldVector<T,dimWorld> B,r,p ;
│ │ │ │ -
635 Dune::FieldMatrix<T,dimWorld,dimWorld> A ;
│ │ │ │ -
636
│ │ │ │ -
637 B = Y[0] - X[0] ;
│ │ │ │ -
638
│ │ │ │ -
639 for (unsigned i = 0; i < dimWorld; ++i) {
│ │ │ │ -
640 A[i][0] = (X[1][i] - X[0][i]);
│ │ │ │ -
641 A[i][1] = (Y[0][i] - Y[1][i]);
│ │ │ │ -
642 A[i][dimWorld-1] = (Y[0][i] - Y[dimWorld-1][i]);
│ │ │ │ -
643 }
│ │ │ │ -
644
│ │ │ │ -
645 if (std::abs(A.determinant())>eps) {
│ │ │ │ -
646
│ │ │ │ -
647 A.solve(r,B) ;
│ │ │ │ -
648
│ │ │ │ -
649 if ((r[0]>=-eps)&&(r[0]<=1+eps)
│ │ │ │ -
650 &&(r[1]>=-eps)&&(r[1]<=1+eps)
│ │ │ │ -
651 &&(r[2]>=-eps)&&(r[2]<=1+eps)
│ │ │ │ -
652 &&(r[1]+r[2]>=-eps) &&(r[1]+r[2]<=1+eps)) {
│ │ │ │ -
653 p = X[1] - X[0] ;
│ │ │ │ -
654 p *= r[0] ;
│ │ │ │ -
655 p += X[0] ;
│ │ │ │ -
656 k = insertPoint(p,P);
│ │ │ │ -
657
│ │ │ │ -
658 if (std::abs(r[0]) < eps) // we prefer exact locations
│ │ │ │ -
659 P[k] = X[0];
│ │ │ │ -
660 else if (std::abs(r[0]) > 1-eps)
│ │ │ │ -
661 P[k] = X[1];
│ │ │ │ -
662 else if (std::abs(r[1]) < eps && std::abs(r[2]) < eps)
│ │ │ │ -
663 P[k] = Y[0];
│ │ │ │ -
664 else if (std::abs(r[1]) < eps && std::abs(r[2]) > 1-eps)
│ │ │ │ -
665 P[k] = Y[2];
│ │ │ │ -
666 else if (std::abs(r[1]) > 1-eps && std::abs(r[2]) < eps)
│ │ │ │ -
667 P[k] = Y[1];
│ │ │ │ -
668
│ │ │ │ -
669 if (std::abs(r[1]) < eps)
│ │ │ │ -
670 SY[1].push_back(k);
│ │ │ │ -
671 if (std::fabs(r[dimWorld-1]) < eps)
│ │ │ │ -
672 SY[0].push_back(k);
│ │ │ │ -
673 if (std::fabs(r[1]+r[dimWorld-1] - 1) < eps)
│ │ │ │ -
674 SY[2].push_back(k);
│ │ │ │ -
675
│ │ │ │ -
676
│ │ │ │ -
677 return true ;
│ │ │ │ -
678 }
│ │ │ │ -
679 }
│ │ │ │ -
680 }
│ │ │ │ -
681 return false ;
│ │ │ │ -
682 }
│ │ │ │ -
│ │ │ │ -
683
│ │ │ │ -
│ │ │ │ -
684 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
685 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
686 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
687 {
│ │ │ │ -
688 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
689 elementCorners,subElements, faceIds);
│ │ │ │ -
690 }
│ │ │ │ -
│ │ │ │ -
691
│ │ │ │ -
692 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
693 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
694 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
695 {
│ │ │ │ -
696 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
697 elementCorners, subElements, faceIds);
│ │ │ │ -
698 }
│ │ │ │ -
699};
│ │ │ │ -
│ │ │ │ -
700
│ │ │ │ -
701// SEGEMENT-TETRAHEDRON INTERSECTION - : )
│ │ │ │ -
702template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
703class SimplexMethod<dimWorld,1,3,T> : public ComputationMethod<dimWorld,1,3,T>{
│ │ │ │ -
704 friend class ComputationMethod<dimWorld,1,3,T>;
│ │ │ │ -
705
│ │ │ │ -
706public:
│ │ │ │ -
707 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
708 static const int grid1Dimension = 1;
│ │ │ │ -
709 static const int grid2Dimension = 3;
│ │ │ │ -
710 static const int intersectionDimension = 1;
│ │ │ │ -
711
│ │ │ │ -
│ │ │ │ -
712 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
713 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
714 std::vector<std::vector<int> > & SX,
│ │ │ │ -
715 std::vector<std::vector<int> > & SY,
│ │ │ │ -
716 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
717 {
│ │ │ │ -
718 assert(X.size() == 2 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ -
719
│ │ │ │ -
720 std::vector<int> indices;
│ │ │ │ -
721 std::vector<FieldVector<T,dimWorld> > surfPts;
│ │ │ │ -
722 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ -
723
│ │ │ │ -
724 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
725 SX.resize(2);
│ │ │ │ -
726 SY.resize(4);
│ │ │ │ -
727
│ │ │ │ -
728 std::vector<FieldVector<T,dimWorld> > pni(1);
│ │ │ │ -
729
│ │ │ │ -
730 bool b = false;
│ │ │ │ -
731
│ │ │ │ -
732 // check whether the corners of the segment are contained in the tetrahedron
│ │ │ │ -
733 for (unsigned int ci = 0; ci < 2; ++ ci) {
│ │ │ │ -
734
│ │ │ │ -
735 pni[0] = X[ci];
│ │ │ │ - │ │ │ │ -
737 int k = insertPoint(X[ci],P);
│ │ │ │ -
738 SX[ci].push_back(k);
│ │ │ │ -
739 b=true;
│ │ │ │ -
740 }
│ │ │ │ -
741 surfPts.clear();
│ │ │ │ -
742 hSX.clear(); hSY.clear();
│ │ │ │ -
743 }
│ │ │ │ -
744
│ │ │ │ -
745 if (P.size() == 2)
│ │ │ │ -
746 return true;
│ │ │ │ -
747
│ │ │ │ -
748 unsigned int faces[4] = {0,3,2,1};
│ │ │ │ -
749 // check whether tetrahedron faces intersect with segment
│ │ │ │ -
750 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ -
751 for (unsigned int ci = 0; ci < 4; ++ci) { // iterate over all faces
│ │ │ │ -
752 triangle[0] = Y[ci];
│ │ │ │ -
753 triangle[1] = Y[(ci+1)%4];
│ │ │ │ -
754 triangle[2] = Y[(ci+2)%4];
│ │ │ │ -
755
│ │ │ │ -
756 if (SimplexMethod<dimWorld,1,2,T>::computeIntersectionPoints(X,triangle,hSX,hSY,surfPts)) { // seg - triangle intersection
│ │ │ │ -
757 std::vector<int> indices(surfPts.size());
│ │ │ │ -
758 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
759 int k = insertPoint(surfPts[np],P);
│ │ │ │ -
760 indices[np]=k;
│ │ │ │ -
761 SY[faces[ci]].push_back(k);
│ │ │ │ -
762 }
│ │ │ │ -
763
│ │ │ │ -
764 // hSX[*] is nonempty if the intersection point is on an edge of the current face of Y
│ │ │ │ -
765 for (unsigned int np = 0; np < hSX[0].size(); ++np)
│ │ │ │ -
766 SX[0].push_back(indices[hSX[0][np]]);
│ │ │ │ -
767 for (unsigned int np = 0; np < hSX[1].size(); ++np)
│ │ │ │ -
768 SX[0].push_back(indices[hSX[1][np]]);
│ │ │ │ -
769
│ │ │ │ -
770 b = true;
│ │ │ │ -
771 }
│ │ │ │ -
772 surfPts.clear();
│ │ │ │ -
773 hSX.clear(); hSY.clear();
│ │ │ │ -
774 }
│ │ │ │ -
775
│ │ │ │ -
776 return b;
│ │ │ │ -
777 }
│ │ │ │ -
│ │ │ │ -
778
│ │ │ │ -
│ │ │ │ -
779 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
780 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
781 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
782 {
│ │ │ │ -
783 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
784 elementCorners,subElements, faceIds);
│ │ │ │ -
785 }
│ │ │ │ -
│ │ │ │ -
786
│ │ │ │ -
787 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
788 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
789 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
790 {
│ │ │ │ -
791 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
792 elementCorners, subElements, faceIds);
│ │ │ │ -
793 }
│ │ │ │ -
794};
│ │ │ │ -
│ │ │ │ -
795
│ │ │ │ -
796// TRIANGLE -TRIANGLE INTERSECTION
│ │ │ │ -
797template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
798class SimplexMethod<dimWorld,2,2,T> : public ComputationMethod<dimWorld,2,2,T>{
│ │ │ │ -
799 friend class ComputationMethod<dimWorld,2,2,T>;
│ │ │ │ -
800
│ │ │ │ -
801public:
│ │ │ │ -
802 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
803 static const int grid1Dimension = 2;
│ │ │ │ -
804 static const int grid2Dimension = 2;
│ │ │ │ -
805 static const int intersectionDimension = 2;
│ │ │ │ -
806
│ │ │ │ -
│ │ │ │ -
807 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
808 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
809 std::vector<std::vector<int> > & SX,
│ │ │ │ -
810 std::vector<std::vector<int> > & SY,
│ │ │ │ -
811 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
812 {
│ │ │ │ -
813 assert(X.size() == 3 && Y.size() == 3 && dimWorld > 1);
│ │ │ │ -
814
│ │ │ │ -
815 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
816
│ │ │ │ -
817 SX.resize(3);
│ │ │ │ -
818 SY.resize(3);
│ │ │ │ -
819
│ │ │ │ -
820 bool b = false;
│ │ │ │ -
821
│ │ │ │ -
822 std::vector<FieldVector<T,dimWorld> > edge(2);
│ │ │ │ -
823 std::vector<FieldVector<T,dimWorld> > surfPts;
│ │ │ │ -
824 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ -
825 std::vector<int> indices;
│ │ │ │ -
826
│ │ │ │ -
827 unsigned int faces[3] = {0,2,1};
│ │ │ │ -
828
│ │ │ │ -
829 for (unsigned int ni = 0; ni < 3; ++ni) {
│ │ │ │ -
830 // check whether the faces of triangle Y intersect the triangle X
│ │ │ │ -
831 edge[0] = Y[ni];
│ │ │ │ -
832 edge[1] = Y[(ni+1)%3];
│ │ │ │ -
833
│ │ │ │ - │ │ │ │ -
835
│ │ │ │ -
836 indices.resize(surfPts.size());
│ │ │ │ -
837 // add intersections of edges of Y with triangle X
│ │ │ │ -
838 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
839 int k = insertPoint(surfPts[np],P);
│ │ │ │ -
840 indices[np] = k;
│ │ │ │ -
841 SY[faces[ni]].push_back(k); // add edge data
│ │ │ │ -
842 }
│ │ │ │ -
843
│ │ │ │ -
844 b=true;
│ │ │ │ -
845 }
│ │ │ │ -
846 if (P.size() >= 6)
│ │ │ │ -
847 return true;
│ │ │ │ -
848
│ │ │ │ -
849 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ -
850 // check whether the faces of triangle X intersect the triangle Y
│ │ │ │ -
851 edge[0] = X[ni];
│ │ │ │ -
852 edge[1] = X[(ni+1)%3];
│ │ │ │ -
853
│ │ │ │ - │ │ │ │ -
855
│ │ │ │ -
856 indices.resize(surfPts.size());
│ │ │ │ -
857 // add intersections of edges of X with triangle Y
│ │ │ │ -
858 for (unsigned int np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
859 int k = insertPoint(surfPts[np],P);
│ │ │ │ -
860 indices[np] = k;
│ │ │ │ -
861 SX[faces[ni]].push_back(k); // add edge data
│ │ │ │ -
862 }
│ │ │ │ -
863
│ │ │ │ -
864 b=true;
│ │ │ │ -
865 }
│ │ │ │ -
866 if (P.size() >= 6)
│ │ │ │ -
867 return true;
│ │ │ │ -
868
│ │ │ │ -
869 surfPts.clear(); hSX.clear(); hSY.clear();
│ │ │ │ -
870 }
│ │ │ │ -
871
│ │ │ │ -
872 return b;
│ │ │ │ -
873 }
│ │ │ │ -
│ │ │ │ -
874
│ │ │ │ -
│ │ │ │ -
875 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
876 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
877 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
878 {
│ │ │ │ -
879 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
880 elementCorners,subElements, faceIds);
│ │ │ │ -
881 }
│ │ │ │ -
│ │ │ │ -
882
│ │ │ │ -
883 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
884 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
885 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
886 {
│ │ │ │ -
887 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
888 elementCorners, subElements, faceIds);
│ │ │ │ -
889 }
│ │ │ │ -
890};
│ │ │ │ -
│ │ │ │ -
891
│ │ │ │ -
892// TRIANGLE -TETRAHEDRON INTERSECTION -: )
│ │ │ │ -
893template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
894class SimplexMethod<dimWorld,2,3,T> : public ComputationMethod<dimWorld,2,3,T>{
│ │ │ │ -
895 friend class ComputationMethod<dimWorld,2,3,T>;
│ │ │ │ -
896
│ │ │ │ -
897public:
│ │ │ │ -
898 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
899 static const int grid1Dimension = 2;
│ │ │ │ -
900 static const int grid2Dimension = 3;
│ │ │ │ -
901 static const int intersectionDimension = 2;
│ │ │ │ -
902
│ │ │ │ -
│ │ │ │ -
903 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
904 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
905 std::vector<std::vector<int> > & SX,
│ │ │ │ -
906 std::vector<std::vector<int> > & SY,
│ │ │ │ -
907 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
908 {
│ │ │ │ -
909 assert(X.size() == 3 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ -
910 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
911 SX.resize(3);
│ │ │ │ -
912 SY.resize(4);
│ │ │ │ -
913
│ │ │ │ -
914 bool b = false;
│ │ │ │ -
915 int k,ni,np, ep;
│ │ │ │ -
916 std::vector<FieldVector<T,dimWorld> > surfPts, xni(1);
│ │ │ │ -
917 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ -
918
│ │ │ │ -
919 unsigned int fiX[3][2];
│ │ │ │ -
920
│ │ │ │ -
921 fiX[0][0] = 0; fiX[1][0] = 0; fiX[2][0] = 1; // faces to node
│ │ │ │ -
922 fiX[0][1] = 1; fiX[1][1] = 2; fiX[2][1] = 2;
│ │ │ │ -
923 // 1st step: check whether the points of the triangle are contained in the tetrahedron
│ │ │ │ -
924 for (ni = 0; ni < 3; ++ni) {
│ │ │ │ -
925
│ │ │ │ -
926 xni[0] = X[ni];
│ │ │ │ - │ │ │ │ -
928 std::vector<int> indices(surfPts.size());
│ │ │ │ -
929 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
930 k = insertPoint(X[ni],P);
│ │ │ │ -
931 indices[np] = k;
│ │ │ │ -
932 SX[fiX[ni][0]].push_back(k); // the corresponding edges to the node are ni and (ni+2)%3
│ │ │ │ -
933 SX[fiX[ni][1]].push_back(k);
│ │ │ │ -
934 }
│ │ │ │ -
935
│ │ │ │ -
936 for (ep = 0; ep < 4; ++ep) {
│ │ │ │ -
937 for (np = 0; np < hSY[ep].size();++np) {
│ │ │ │ -
938 SY[ep].push_back(indices[hSY[ep][np]]);
│ │ │ │ -
939 }
│ │ │ │ -
940 }
│ │ │ │ -
941 b = true;
│ │ │ │ -
942 }
│ │ │ │ -
943 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
944 }
│ │ │ │ -
945
│ │ │ │ -
946 if (P.size() == 3) // intersection is given by all three corners of the triangle
│ │ │ │ -
947 return true;
│ │ │ │ -
948
│ │ │ │ -
949 // note: points of Y in X is called indirectly via triangle-triangle intesection
│ │ │ │ -
950
│ │ │ │ -
951 // check whether the triangles of the one tetrahedron intersect the triangle
│ │ │ │ -
952 unsigned int facesY[4] = {0,3,2,1}; // face ordering
│ │ │ │ -
953
│ │ │ │ -
954 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ -
955 for (ni = 0; ni < 4; ++ni) {
│ │ │ │ -
956
│ │ │ │ -
957 triangle[0] = Y[ni];
│ │ │ │ -
958 triangle[1] = Y[(ni+1)%4];
│ │ │ │ -
959 triangle[2] = Y[(ni+2)%4];
│ │ │ │ -
960
│ │ │ │ -
961 if (SimplexMethod<dimWorld,2,2,T>::computeIntersectionPoints(X,triangle,hSX,hSY,surfPts)) {
│ │ │ │ -
962 std::vector<int> indices(surfPts.size());
│ │ │ │ -
963 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
964 k = insertPoint(surfPts[np],P);
│ │ │ │ -
965 indices[np]=k;
│ │ │ │ -
966 SY[facesY[ni]].push_back(k);
│ │ │ │ -
967 }
│ │ │ │ -
968
│ │ │ │ -
969 // SX[*] is nonempty if the face * of X is intersected
│ │ │ │ -
970 for (np = 0; np < 3; ++np) {
│ │ │ │ -
971 for (ep = 0; ep < hSX[np].size(); ++ep) {
│ │ │ │ -
972 SX[np].push_back(indices[hSX[np][ep]]);
│ │ │ │ -
973 }
│ │ │ │ -
974 }
│ │ │ │ -
975
│ │ │ │ -
976 b = true;
│ │ │ │ -
977 }
│ │ │ │ -
978 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
979 }
│ │ │ │ -
980 return b;
│ │ │ │ -
981 }
│ │ │ │ -
│ │ │ │ -
982
│ │ │ │ -
│ │ │ │ -
983 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
984 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
985 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
986 {
│ │ │ │ -
987 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
988 elementCorners,subElements, faceIds);
│ │ │ │ -
989 }
│ │ │ │ -
│ │ │ │ -
990
│ │ │ │ -
991 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
992 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
993 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
994 {
│ │ │ │ -
995 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
996 elementCorners, subElements, faceIds);
│ │ │ │ -
997 }
│ │ │ │ -
998};
│ │ │ │ -
│ │ │ │ -
999
│ │ │ │ -
1000template<int dimWorld,typename T>
│ │ │ │ -
│ │ │ │ -
1001class SimplexMethod<dimWorld,3,3,T> : public ComputationMethod<dimWorld,3,3,T>{
│ │ │ │ -
1002 friend class ComputationMethod<dimWorld,3,3,T>;
│ │ │ │ -
1003
│ │ │ │ -
1004public:
│ │ │ │ -
1005 typedef FieldVector<T, dimWorld> Vector;
│ │ │ │ -
1006 static const int grid1Dimension = 3;
│ │ │ │ -
1007 static const int grid2Dimension = 3;
│ │ │ │ -
1008 static const int intersectionDimension = 3;
│ │ │ │ -
1009
│ │ │ │ -
│ │ │ │ -
1010 static bool computeIntersectionPoints(const std::vector<FieldVector<T,dimWorld> >& X,
│ │ │ │ -
1011 const std::vector<FieldVector<T,dimWorld> >& Y,
│ │ │ │ -
1012 std::vector<std::vector<int> > & SX,
│ │ │ │ -
1013 std::vector<std::vector<int> > & SY,
│ │ │ │ -
1014 std::vector<FieldVector<T,dimWorld> > & P)
│ │ │ │ -
1015 {
│ │ │ │ -
1016 assert(X.size() == 4 && Y.size() == 4 && dimWorld > 2);
│ │ │ │ -
1017 P.clear(); SX.clear(); SY.clear();
│ │ │ │ -
1018
│ │ │ │ -
1019 SX.resize(4);
│ │ │ │ -
1020 SY.resize(4);
│ │ │ │ -
1021
│ │ │ │ -
1022 bool b = false;
│ │ │ │ -
1023 int ci,np,ne,k,ni[4][3];
│ │ │ │ -
1024
│ │ │ │ -
1025 ni[0][0]= 0 ; ni[0][1]= 1 ; ni[0][2]= 2 ; // faces touching each node
│ │ │ │ -
1026 ni[1][0]= 0 ; ni[1][1]= 1 ; ni[1][2]= 3 ;
│ │ │ │ -
1027 ni[2][0]= 0 ; ni[2][1]= 2 ; ni[2][2]= 3 ;
│ │ │ │ -
1028 ni[3][0]= 1 ; ni[3][1]= 2 ; ni[3][2]= 3 ;
│ │ │ │ -
1029
│ │ │ │ -
1030 // temporal data container
│ │ │ │ -
1031 std::vector<FieldVector<T,dimWorld> > surfPts, pci(1);
│ │ │ │ -
1032 std::vector<std::vector<int> > hSX, hSY;
│ │ │ │ -
1033
│ │ │ │ -
1034 // check whether the points of the one tetrahedron are contained in the other tetrahedron
│ │ │ │ -
1035 for (ci = 0; ci < 3; ++ci) {
│ │ │ │ -
1036 pci[0] = X[ci];
│ │ │ │ -
1037 // point of X is inside Y
│ │ │ │ - │ │ │ │ -
1039 std::vector<int> indices(surfPts.size());
│ │ │ │ -
1040
│ │ │ │ -
1041 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
1042
│ │ │ │ -
1043 k = insertPoint(X[ci],P);
│ │ │ │ -
1044 indices[np]=k;
│ │ │ │ -
1045 SX[ni[ci][0]].push_back(k); // add face data
│ │ │ │ -
1046 SX[ni[ci][1]].push_back(k);
│ │ │ │ -
1047 SX[ni[ci][2]].push_back(k);
│ │ │ │ -
1048 }
│ │ │ │ -
1049
│ │ │ │ -
1050 // hSY[*] is nonempty if X[ci] is on the face * of Y
│ │ │ │ -
1051 for (ne = 0; ne < 4; ++ne) {
│ │ │ │ -
1052 for (np = 0; np < hSY[ne].size(); ++np) {
│ │ │ │ -
1053 SY[ne].push_back(indices[hSY[ne][np]]);
│ │ │ │ -
1054 }
│ │ │ │ -
1055 }
│ │ │ │ -
1056
│ │ │ │ -
1057 b = true;
│ │ │ │ -
1058 }
│ │ │ │ -
1059 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
1060
│ │ │ │ -
1061 // probably one point of Y is inside X
│ │ │ │ -
1062 surfPts.resize(0);
│ │ │ │ -
1063 pci[0]=Y[ci];
│ │ │ │ - │ │ │ │ -
1065 std::vector<int> indices(surfPts.size());
│ │ │ │ -
1066
│ │ │ │ -
1067 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
1068 k = insertPoint(Y[ci],P);
│ │ │ │ -
1069 indices[np]=k;
│ │ │ │ -
1070 SY[ni[ci][0]].push_back(k); // add face data
│ │ │ │ -
1071 SY[ni[ci][1]].push_back(k);
│ │ │ │ -
1072 SY[ni[ci][2]].push_back(k);
│ │ │ │ -
1073 }
│ │ │ │ -
1074
│ │ │ │ -
1075 // hSX[*] is nonempty if the point Y[ci] is on the face * of X
│ │ │ │ -
1076 for (ne = 0; ne < 4; ++ne) {
│ │ │ │ -
1077 for (np = 0; np < hSX[ne].size(); ++np) {
│ │ │ │ -
1078 SX[ne].push_back(indices[hSX[ne][np]]);
│ │ │ │ -
1079 }
│ │ │ │ -
1080 }
│ │ │ │ -
1081 b = true;
│ │ │ │ -
1082 }
│ │ │ │ -
1083 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
1084 }
│ │ │ │ -
1085
│ │ │ │ -
1086 // check whether the triangles of the one tetrahedron intersect the triangles
│ │ │ │ -
1087 // of the other tetrahedron
│ │ │ │ -
1088 unsigned int faces[4] = {0,3,2,1}; // face ordering
│ │ │ │ -
1089
│ │ │ │ -
1090 std::vector<FieldVector<T,dimWorld> > triangle(3);
│ │ │ │ -
1091 for (ci = 0; ci < 4; ++ci) { // iterate over faces of Y
│ │ │ │ -
1092
│ │ │ │ -
1093 triangle[0] = Y[ci];
│ │ │ │ -
1094 triangle[1] = Y[(ci+1)%4];
│ │ │ │ -
1095 triangle[2] = Y[(ci+2)%4];
│ │ │ │ -
1096
│ │ │ │ -
1097 if(SimplexMethod<dimWorld,3,2,T>::computeIntersectionPoints(X, triangle,hSX,hSY,surfPts)) {
│ │ │ │ -
1098
│ │ │ │ -
1099 // add Triangle of Y intersects tetrahedron Y data
│ │ │ │ -
1100 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
1101 k = insertPoint(surfPts[np],P);
│ │ │ │ -
1102 SY[faces[ci]].push_back(k); // add face data
│ │ │ │ -
1103 }
│ │ │ │ -
1104 b = true;
│ │ │ │ -
1105 }
│ │ │ │ -
1106 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
1107
│ │ │ │ -
1108 triangle[0] = X[ci];
│ │ │ │ -
1109 triangle[1] = X[(ci+1)%4];
│ │ │ │ -
1110 triangle[2] = X[(ci+2)%4];
│ │ │ │ -
1111
│ │ │ │ -
1112 if(SimplexMethod<dimWorld,3,2,T>::computeIntersectionPoints(Y, triangle,hSY,hSX,surfPts)) {
│ │ │ │ -
1113
│ │ │ │ -
1114 // add Triangle of Y intersects tetrahedron Y data
│ │ │ │ -
1115 for (np = 0; np < surfPts.size(); ++np) {
│ │ │ │ -
1116 k = insertPoint(surfPts[np],P);
│ │ │ │ -
1117 SX[faces[ci]].push_back(k); // add face data
│ │ │ │ -
1118 }
│ │ │ │ -
1119 b = true;
│ │ │ │ -
1120 }
│ │ │ │ -
1121 hSX.clear(); hSY.clear(); surfPts.clear();
│ │ │ │ -
1122 }
│ │ │ │ -
1123
│ │ │ │ -
1124 return b;
│ │ │ │ -
1125 }
│ │ │ │ -
│ │ │ │ -
1126
│ │ │ │ -
│ │ │ │ -
1127 static void grid1_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
1128 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1129 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1130 {
│ │ │ │ -
1131 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid1Dimension>(),
│ │ │ │ -
1132 elementCorners,subElements, faceIds);
│ │ │ │ -
1133 }
│ │ │ │ -
│ │ │ │ -
1134
│ │ │ │ -
│ │ │ │ -
1135 static void grid2_subdivisions(const std::vector<Vector>& elementCorners,
│ │ │ │ -
1136 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1137 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1138 {
│ │ │ │ -
1139 simplexSubdivision<dimWorld,T>(std::integral_constant<int,grid2Dimension>(),
│ │ │ │ -
1140 elementCorners, subElements, faceIds);
│ │ │ │ -
1141 }
│ │ │ │ -
│ │ │ │ -
1142};
│ │ │ │ -
│ │ │ │ -
1143
│ │ │ │ -
1144template <int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
1145inline void simplexSubdivision(std::integral_constant<int,0>,
│ │ │ │ -
1146 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
1147 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1148 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1149{
│ │ │ │ -
1150 subElements.resize(1);
│ │ │ │ -
1151 faceIds.resize(0);
│ │ │ │ -
1152
│ │ │ │ -
1153 subElements[0].push_back(0);
│ │ │ │ -
1154}
│ │ │ │ -
│ │ │ │ -
1155
│ │ │ │ -
1156template <int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
1157inline void simplexSubdivision(std::integral_constant<int,1>,
│ │ │ │ -
1158 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
1159 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1160 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1161{
│ │ │ │ -
1162 subElements.resize(1);
│ │ │ │ -
1163 faceIds.resize(1);
│ │ │ │ -
1164
│ │ │ │ -
1165 subElements[0].push_back(0);
│ │ │ │ -
1166 subElements[0].push_back(1);
│ │ │ │ -
1167
│ │ │ │ -
1168 faceIds[0].push_back(0);
│ │ │ │ -
1169 faceIds[0].push_back(1);
│ │ │ │ -
1170}
│ │ │ │ -
│ │ │ │ -
1171
│ │ │ │ -
1172template <int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
1173inline void simplexSubdivision(std::integral_constant<int,2>,
│ │ │ │ -
1174 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
1175 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1176 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1177{
│ │ │ │ -
1178 subElements.clear();
│ │ │ │ -
1179 faceIds.clear();
│ │ │ │ -
1180
│ │ │ │ -
1181 if (elementCorners.size() == 3) { // triangle
│ │ │ │ -
1182 subElements.resize(1);
│ │ │ │ -
1183 faceIds.resize(1);
│ │ │ │ -
1184
│ │ │ │ -
1185 subElements[0].push_back(0);
│ │ │ │ -
1186 subElements[0].push_back(1);
│ │ │ │ -
1187 subElements[0].push_back(2);
│ │ │ │ -
1188
│ │ │ │ -
1189 faceIds[0].push_back(0);
│ │ │ │ -
1190 faceIds[0].push_back(1);
│ │ │ │ -
1191 faceIds[0].push_back(2);
│ │ │ │ -
1192 } else if (elementCorners.size() == 4) { // quadrilateral => 2 triangles
│ │ │ │ -
1193 subElements.resize(2);
│ │ │ │ -
1194 faceIds.resize(2);
│ │ │ │ -
1195
│ │ │ │ -
1196 subElements[0].push_back(0);
│ │ │ │ -
1197 subElements[0].push_back(1);
│ │ │ │ -
1198 subElements[0].push_back(2);
│ │ │ │ -
1199
│ │ │ │ -
1200 subElements[1].push_back(1);
│ │ │ │ -
1201 subElements[1].push_back(2);
│ │ │ │ -
1202 subElements[1].push_back(3);
│ │ │ │ -
1203
│ │ │ │ -
1204 faceIds[0].push_back(2);
│ │ │ │ -
1205 faceIds[0].push_back(0);
│ │ │ │ -
1206 faceIds[0].push_back(-1);
│ │ │ │ -
1207
│ │ │ │ -
1208 faceIds[1].push_back(-1);
│ │ │ │ -
1209 faceIds[1].push_back(1);
│ │ │ │ -
1210 faceIds[1].push_back(3);
│ │ │ │ -
1211 }
│ │ │ │ -
1212}
│ │ │ │ -
│ │ │ │ -
1213
│ │ │ │ -
1214template <int dimworld, typename T>
│ │ │ │ -
│ │ │ │ -
1215inline void simplexSubdivision(std::integral_constant<int,3>,
│ │ │ │ -
1216 const std::vector<Dune::FieldVector<T, dimworld> >& elementCorners,
│ │ │ │ -
1217 std::vector<std::vector<unsigned int> >& subElements,
│ │ │ │ -
1218 std::vector<std::vector<int> >& faceIds)
│ │ │ │ -
1219{
│ │ │ │ -
1220 subElements.clear();
│ │ │ │ -
1221 faceIds.clear();
│ │ │ │ -
1222
│ │ │ │ -
1223 if (elementCorners.size() == 4) { // tetrahedron
│ │ │ │ -
1224 subElements.resize(1);
│ │ │ │ -
1225 faceIds.resize(1);
│ │ │ │ -
1226
│ │ │ │ -
1227 subElements[0].push_back(0);
│ │ │ │ -
1228 subElements[0].push_back(1);
│ │ │ │ -
1229 subElements[0].push_back(2);
│ │ │ │ -
1230 subElements[0].push_back(3);
│ │ │ │ -
1231
│ │ │ │ -
1232 faceIds[0].push_back(0);
│ │ │ │ -
1233 faceIds[0].push_back(1);
│ │ │ │ -
1234 faceIds[0].push_back(2);
│ │ │ │ -
1235 faceIds[0].push_back(3);
│ │ │ │ -
1236
│ │ │ │ -
1237 } else if (elementCorners.size() == 8) { // cube => 5 tetrahedra
│ │ │ │ -
1238 subElements.resize(5);
│ │ │ │ -
1239 faceIds.resize(5);
│ │ │ │ -
1240
│ │ │ │ -
1241 subElements[0].push_back(0);
│ │ │ │ -
1242 subElements[0].push_back(2);
│ │ │ │ -
1243 subElements[0].push_back(3);
│ │ │ │ -
1244 subElements[0].push_back(6);
│ │ │ │ -
1245
│ │ │ │ -
1246 subElements[1].push_back(0);
│ │ │ │ -
1247 subElements[1].push_back(1);
│ │ │ │ -
1248 subElements[1].push_back(3);
│ │ │ │ -
1249 subElements[1].push_back(5);
│ │ │ │ -
1250
│ │ │ │ -
1251 subElements[2].push_back(0);
│ │ │ │ -
1252 subElements[2].push_back(3);
│ │ │ │ -
1253 subElements[2].push_back(5);
│ │ │ │ -
1254 subElements[2].push_back(6);
│ │ │ │ -
1255
│ │ │ │ -
1256 subElements[3].push_back(0);
│ │ │ │ -
1257 subElements[3].push_back(4);
│ │ │ │ -
1258 subElements[3].push_back(5);
│ │ │ │ -
1259 subElements[3].push_back(6);
│ │ │ │ -
1260
│ │ │ │ -
1261 subElements[4].push_back(3);
│ │ │ │ -
1262 subElements[4].push_back(5);
│ │ │ │ -
1263 subElements[4].push_back(6);
│ │ │ │ -
1264 subElements[4].push_back(7);
│ │ │ │ -
1265
│ │ │ │ -
1266 faceIds[0].push_back(4);
│ │ │ │ -
1267 faceIds[0].push_back(0);
│ │ │ │ -
1268 faceIds[0].push_back(-1);
│ │ │ │ -
1269 faceIds[0].push_back(3);
│ │ │ │ -
1270
│ │ │ │ -
1271 faceIds[1].push_back(4);
│ │ │ │ -
1272 faceIds[1].push_back(2);
│ │ │ │ -
1273 faceIds[1].push_back(-1);
│ │ │ │ -
1274 faceIds[1].push_back(1);
│ │ │ │ -
1275
│ │ │ │ -
1276 faceIds[2].push_back(-1);
│ │ │ │ -
1277 faceIds[2].push_back(-1);
│ │ │ │ -
1278 faceIds[2].push_back(-1);
│ │ │ │ -
1279 faceIds[2].push_back(-1);
│ │ │ │ -
1280
│ │ │ │ -
1281 faceIds[3].push_back(2);
│ │ │ │ -
1282 faceIds[3].push_back(0);
│ │ │ │ -
1283 faceIds[3].push_back(-1);
│ │ │ │ -
1284 faceIds[3].push_back(5);
│ │ │ │ -
1285
│ │ │ │ -
1286 faceIds[4].push_back(-1);
│ │ │ │ -
1287 faceIds[4].push_back(1);
│ │ │ │ -
1288 faceIds[4].push_back(3);
│ │ │ │ -
1289 faceIds[4].push_back(5);
│ │ │ │ -
1290 }
│ │ │ │ -
1291}
│ │ │ │ -
│ │ │ │ -
1292
│ │ │ │ -
1293} /* namespace Dune::GridGlue */
│ │ │ │ -
1294} /* namespace Dune */
│ │ │ │ +
189} /* namespace Dune::GridGlue */
│ │ │ │ +
190} /* namespace Dune */
│ │ │ │ +
191
│ │ │ │ +
192#include "simplexintersection.cc"
│ │ │ │ +
193#include "computeintersection.cc"
│ │ │ │ +
194
│ │ │ │ +
195#endif
│ │ │ │ + │ │ │ │ + │ │ │ │
Definition gridglue.hh:37
│ │ │ │
int insertPoint(const V p, std::vector< V > &P)
Definition computeintersection.hh:164
│ │ │ │ -
void 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)
Definition simplexintersection.cc:1145
│ │ │ │
Definition computeintersection.hh:13
│ │ │ │ -
Definition simplexintersection.cc:30
│ │ │ │ -
static const int grid1Dimension
Definition simplexintersection.cc:35
│ │ │ │ -
static const int grid2Dimension
Definition simplexintersection.cc:36
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:34
│ │ │ │ -
static const int intersectionDimension
Definition simplexintersection.cc:37
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:39
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:48
│ │ │ │ -
static void grid2_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:56
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:104
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:78
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:73
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:181
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:129
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:134
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:206
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:211
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:262
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:291
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:286
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:332
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:360
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:542
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:355
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:570
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:684
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:565
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:779
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:712
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:707
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:802
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:875
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:807
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:903
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:983
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:898
│ │ │ │ -
static void grid1_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:1127
│ │ │ │ -
static bool computeIntersectionPoints(const std::vector< FieldVector< T, dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< FieldVector< T, dimWorld > > &P)
Definition simplexintersection.cc:1010
│ │ │ │ -
FieldVector< T, dimWorld > Vector
Definition simplexintersection.cc:1005
│ │ │ │ -
static void grid2_subdivisions(const std::vector< Vector > &elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Definition simplexintersection.cc:1135
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,1578 +1,214 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -simplexintersection.cc │ │ │ │ │ +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-with- │ │ │ │ │ +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 │ │ │ │ │ -6namespace Dune { │ │ │ │ │ -7namespace GridGlue { │ │ │ │ │ +6#include │ │ │ │ │ +7#include │ │ │ │ │ 8 │ │ │ │ │ -9template │ │ │ │ │ -10inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ -vector >& elementCorners, │ │ │ │ │ -11 std::vector >& subElements, │ │ │ │ │ -12 std::vector >& faceIds); │ │ │ │ │ -13template │ │ │ │ │ -14inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ -vector >& elementCorners, │ │ │ │ │ -15 std::vector >& subElements, │ │ │ │ │ -16 std::vector >& faceIds); │ │ │ │ │ -17template │ │ │ │ │ -18inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ -vector >& elementCorners, │ │ │ │ │ -19 std::vector >& subElements, │ │ │ │ │ -20 std::vector >& faceIds); │ │ │ │ │ -21template │ │ │ │ │ -22inline void simplexSubdivision(std::integral_constant,const std:: │ │ │ │ │ -vector >& elementCorners, │ │ │ │ │ -23 std::vector >& subElements, │ │ │ │ │ -24 std::vector >& faceIds); │ │ │ │ │ -25 │ │ │ │ │ -26 │ │ │ │ │ -27 │ │ │ │ │ -28// *****************SIMPLEX INTERSECTION COMPUTATION METHODS │ │ │ │ │ -*************************** │ │ │ │ │ -29template │ │ │ │ │ -30class SimplexMethod : public ComputationMethod{ │ │ │ │ │ -31 static_assert(dim1 > dim2, "Specialization missing"); │ │ │ │ │ -32 friend class ComputationMethod; │ │ │ │ │ -33public: │ │ │ │ │ -34 typedef FieldVector Vector; │ │ │ │ │ -35 static const int grid1Dimension = dim1; │ │ │ │ │ -36 static const int grid2Dimension = dim2; │ │ │ │ │ -37 static const int intersectionDimension = dim2; │ │ │ │ │ -38 │ │ │ │ │ -39 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -40 const std::vector >& Y, │ │ │ │ │ -41 std::vector > & SX, │ │ │ │ │ -42 std::vector > & SY, │ │ │ │ │ -43 std::vector > & P) │ │ │ │ │ -44 { │ │ │ │ │ -45 return SimplexMethod::computeIntersectionPoints(Y, X, │ │ │ │ │ -SY, SX, P); │ │ │ │ │ -46 } │ │ │ │ │ -47 │ │ │ │ │ -48 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -49 std::vector >& subElements, │ │ │ │ │ -50 std::vector >& faceIds) │ │ │ │ │ -51 { │ │ │ │ │ -52 simplexSubdivision(std::integral_constant(), │ │ │ │ │ -53 elementCorners,subElements, faceIds); │ │ │ │ │ -54 } │ │ │ │ │ -55 │ │ │ │ │ -56 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -57 std::vector >& subElements, │ │ │ │ │ -58 std::vector >& faceIds) │ │ │ │ │ -59 { │ │ │ │ │ -60 simplexSubdivision(std::integral_constant(), │ │ │ │ │ -61 elementCorners, subElements, faceIds); │ │ │ │ │ -62 } │ │ │ │ │ -63}; │ │ │ │ │ +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 │ │ │ │ │ -65 │ │ │ │ │ -66 │ │ │ │ │ -67// POINTS ARE EQUAL │ │ │ │ │ -68template │ │ │ │ │ -69class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -70 friend class ComputationMethod; │ │ │ │ │ -71 │ │ │ │ │ -72public: │ │ │ │ │ -73 typedef FieldVector Vector; │ │ │ │ │ -74 static const int grid1Dimension = 0; │ │ │ │ │ -75 static const int grid2Dimension = 0; │ │ │ │ │ -76 static const int intersectionDimension = 0; │ │ │ │ │ -77 │ │ │ │ │ -78 static bool computeIntersectionPoints( │ │ │ │ │ -79 const std::vector >& X, │ │ │ │ │ -80 const std::vector >& Y, │ │ │ │ │ -81 std::vector > & SX, │ │ │ │ │ -82 std::vector > & SY, │ │ │ │ │ -83 std::vector > & P) │ │ │ │ │ -84 { │ │ │ │ │ -85 assert(X.size() == 1 && Y.size() == 1); │ │ │ │ │ -86 │ │ │ │ │ -87 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -88 int k; │ │ │ │ │ -89 │ │ │ │ │ -90 T eps = 1e-8; │ │ │ │ │ -91 T a = X[0].infinity_norm(); │ │ │ │ │ -92 T b = Y[0].infinity_norm(); │ │ │ │ │ -93 T c = (X[0] - Y[0]).infinity_norm(); │ │ │ │ │ -94 │ │ │ │ │ -95 if (c <= eps*a || c <= eps*b || │ │ │ │ │ -96 (a& elementCorners, │ │ │ │ │ -105 std::vector >& subElements, │ │ │ │ │ -106 std::vector >& faceIds) │ │ │ │ │ -107 { │ │ │ │ │ -108 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -109 elementCorners,subElements, faceIds); │ │ │ │ │ -110 } │ │ │ │ │ -111 │ │ │ │ │ -112 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -113 std::vector >& subElements, │ │ │ │ │ -114 std::vector >& faceIds) │ │ │ │ │ -115 { │ │ │ │ │ -116 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -117 elementCorners, subElements, faceIds); │ │ │ │ │ -118 } │ │ │ │ │ -119 │ │ │ │ │ -120}; │ │ │ │ │ -121 │ │ │ │ │ -122 │ │ │ │ │ -123// POINT ON LINE SEGMENT - :) │ │ │ │ │ -124template │ │ │ │ │ -125class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -126 friend class ComputationMethod; │ │ │ │ │ -127 │ │ │ │ │ -128public: │ │ │ │ │ -129 typedef FieldVector Vector; │ │ │ │ │ -130 static const int grid1Dimension = 0; │ │ │ │ │ -131 static const int grid2Dimension = 1; │ │ │ │ │ -132 static const int intersectionDimension = 0; │ │ │ │ │ -133 │ │ │ │ │ -134 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -135 const std::vector >& Y, │ │ │ │ │ -136 std::vector > & SX, │ │ │ │ │ -137 std::vector > & SY, │ │ │ │ │ -138 std::vector > & P) │ │ │ │ │ -139 { │ │ │ │ │ -140 assert(X.size() == 1 && Y.size() == 2); │ │ │ │ │ -141 │ │ │ │ │ -142 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -143 SY.resize(2); │ │ │ │ │ -144 │ │ │ │ │ -145 if (dimWorld == 1) { │ │ │ │ │ -146 T lowerBound = std::max(X[0][0], std::min(Y[0][0],Y[1][0])); │ │ │ │ │ -147 T upperBound = std::min(X[0][0], std::max(Y[0][0],Y[1][0])); │ │ │ │ │ -148 │ │ │ │ │ -149 if (lowerBound <= upperBound) { // Intersection is non-empty │ │ │ │ │ -150 insertPoint(X[0],P); │ │ │ │ │ -151 return true; │ │ │ │ │ -152 } │ │ │ │ │ -153 } else { │ │ │ │ │ -154 │ │ │ │ │ -155 T eps = 1e-8; │ │ │ │ │ -156 │ │ │ │ │ -157 // check whether the point is on the segment │ │ │ │ │ -158 FieldVector v0 = X[0] - Y[0]; │ │ │ │ │ -159 FieldVector v1 = X[0] - Y[1]; │ │ │ │ │ -160 FieldVector v2 = Y[1] - Y[0]; │ │ │ │ │ -161 │ │ │ │ │ -162 T s = v0.dot(v1); │ │ │ │ │ -163 T t = v0.two_norm()/v2.two_norm(); │ │ │ │ │ -164 v2*=t; │ │ │ │ │ -165 v2+=Y[0]; │ │ │ │ │ -166 v2-=X[0]; │ │ │ │ │ -167 │ │ │ │ │ -168 if (v2.infinity_norm() < eps && s<=eps && t<=1+eps) { │ │ │ │ │ -169 │ │ │ │ │ -170 int k = insertPoint(X[0],P); │ │ │ │ │ -171 if (s < eps && t < eps) │ │ │ │ │ -172 SY[0].push_back(k); │ │ │ │ │ -173 else if (s < eps && t>1-eps) │ │ │ │ │ -174 SY[1].push_back(k); │ │ │ │ │ -175 return true; │ │ │ │ │ -176 } │ │ │ │ │ -177 } │ │ │ │ │ -178 return false; │ │ │ │ │ -179 } │ │ │ │ │ +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 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -182 std::vector >& subElements, │ │ │ │ │ -183 std::vector >& faceIds) │ │ │ │ │ -184 { │ │ │ │ │ -185 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -186 elementCorners,subElements, faceIds); │ │ │ │ │ -187 } │ │ │ │ │ +181 } │ │ │ │ │ +182 else │ │ │ │ │ +183 P.push_back(p); │ │ │ │ │ +184 │ │ │ │ │ +185 return k ; │ │ │ │ │ +186} │ │ │ │ │ +187 │ │ │ │ │ 188 │ │ │ │ │ -189 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -190 std::vector >& subElements, │ │ │ │ │ -191 std::vector >& faceIds) │ │ │ │ │ -192 { │ │ │ │ │ -193 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -194 elementCorners, subElements, faceIds); │ │ │ │ │ -195 } │ │ │ │ │ -196 │ │ │ │ │ -197}; │ │ │ │ │ -198 │ │ │ │ │ -199 │ │ │ │ │ -200// POINT IN TRIANGLE - :) │ │ │ │ │ -201template │ │ │ │ │ -202class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -203 friend class ComputationMethod; │ │ │ │ │ -204 │ │ │ │ │ -205public: │ │ │ │ │ -206 typedef FieldVector Vector; │ │ │ │ │ -207 static const int grid1Dimension = 0; │ │ │ │ │ -208 static const int grid2Dimension = 2; │ │ │ │ │ -209 static const int intersectionDimension = 0; │ │ │ │ │ -210 │ │ │ │ │ -211 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -212 const std::vector >& Y, │ │ │ │ │ -213 std::vector > & SX, │ │ │ │ │ -214 std::vector > & SY, │ │ │ │ │ -215 std::vector > & P) │ │ │ │ │ -216 { │ │ │ │ │ -217 assert(X.size() == 1 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ -218 │ │ │ │ │ -219 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -220 SY.resize(3); │ │ │ │ │ -221 int k; │ │ │ │ │ -222 │ │ │ │ │ -223 // If not, check whether it is inside the triangle │ │ │ │ │ -224 double eps= 1e-8 ; // tolerance for relative error │ │ │ │ │ -225 │ │ │ │ │ -226 FieldVector v0,v1,v2,r; │ │ │ │ │ -227 │ │ │ │ │ -228 v0 = Y[1] - Y[0]; │ │ │ │ │ -229 v1 = Y[2] - Y[0]; │ │ │ │ │ -230 v2 = X[0] - Y[0]; │ │ │ │ │ -231 │ │ │ │ │ -232 T s,t,d; │ │ │ │ │ -233 │ │ │ │ │ -234 d = ((v0.dot(v0))*(v1.dot(v1)) - (v0.dot(v1))*(v0.dot(v1))); │ │ │ │ │ -235 │ │ │ │ │ -236 s = ((v1.dot(v1))*(v0.dot(v2)) - (v0.dot(v1))*(v1.dot(v2))) / d; │ │ │ │ │ -237 t = ((v0.dot(v0))*(v1.dot(v2)) - (v0.dot(v1))*(v0.dot(v2))) / d; │ │ │ │ │ -238 │ │ │ │ │ -239 v0*=s; │ │ │ │ │ -240 v1*=t; │ │ │ │ │ -241 r = Y[0] + v0 + v1; │ │ │ │ │ -242 │ │ │ │ │ -243 if (s > -eps && t > -eps && (s+t)< 1+eps && (r-X[0]).infinity_norm() < eps) │ │ │ │ │ -{ │ │ │ │ │ -244 k = insertPoint(X[0],P); │ │ │ │ │ -245 │ │ │ │ │ -246 if (t < eps) { // t ~ 0, s varies -> edge 0 │ │ │ │ │ -247 SY[0].push_back(k); │ │ │ │ │ -248 } │ │ │ │ │ -249 if (s < eps) { // s ~ 0, t varies -> edge 1 │ │ │ │ │ -250 SY[1].push_back(k); │ │ │ │ │ -251 } │ │ │ │ │ -252 if (s+t > 1-eps) { // s+t ~ 1 -> edge 2 │ │ │ │ │ -253 SY[2].push_back(k); │ │ │ │ │ -254 } │ │ │ │ │ -255 │ │ │ │ │ -256 return true; │ │ │ │ │ -257 } │ │ │ │ │ -258 │ │ │ │ │ -259 return false; │ │ │ │ │ -260 } │ │ │ │ │ -261 │ │ │ │ │ -262 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -263 std::vector >& subElements, │ │ │ │ │ -264 std::vector >& faceIds) │ │ │ │ │ -265 { │ │ │ │ │ -266 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -267 elementCorners,subElements, faceIds); │ │ │ │ │ -268 } │ │ │ │ │ -269 │ │ │ │ │ -270 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -271 std::vector >& subElements, │ │ │ │ │ -272 std::vector >& faceIds) │ │ │ │ │ -273 { │ │ │ │ │ -274 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -275 elementCorners, subElements, faceIds); │ │ │ │ │ -276 } │ │ │ │ │ -277}; │ │ │ │ │ -278 │ │ │ │ │ -279 │ │ │ │ │ -280// POINT IN TETRAHEDRON - : ) │ │ │ │ │ -281template │ │ │ │ │ -282class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -283 friend class ComputationMethod; │ │ │ │ │ -284 │ │ │ │ │ -285public: │ │ │ │ │ -286 typedef FieldVector Vector; │ │ │ │ │ -287 static const int grid1Dimension = 0; │ │ │ │ │ -288 static const int grid2Dimension = 3; │ │ │ │ │ -289 static const int intersectionDimension = 0; │ │ │ │ │ -290 │ │ │ │ │ -291 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -292 const std::vector >& Y, │ │ │ │ │ -293 std::vector > & SX, │ │ │ │ │ -294 std::vector > & SY, │ │ │ │ │ -295 std::vector > & P) │ │ │ │ │ -296 { │ │ │ │ │ -297 assert(X.size() == 1 && Y.size() == 4 && dimWorld == 3); │ │ │ │ │ -298 │ │ │ │ │ -299 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -300 SY.resize(4); │ │ │ │ │ -301 │ │ │ │ │ -302 T eps = 1e-8; │ │ │ │ │ -303 // if not, check whether its inside the tetrahedron │ │ │ │ │ -304 FieldMatrix D,DD ; │ │ │ │ │ -305 │ │ │ │ │ -306 D[0][0] = Y[0][0] ; D[0][1] = Y[1][0] ; D[0][2] = Y[2][0] ; D[0][3] = Y[3] │ │ │ │ │ -[0] ; │ │ │ │ │ -307 D[1][0] = Y[0][1] ; D[1][1] = Y[1][1] ; D[1][2] = Y[2][1] ; D[1][3] = Y[3] │ │ │ │ │ -[1] ; │ │ │ │ │ -308 D[2][0] = Y[0][2] ; D[2][1] = Y[1][2] ; D[2][2] = Y[2][2] ; D[2][3] = Y[3] │ │ │ │ │ -[2] ; │ │ │ │ │ -309 D[3][0] = 1 ; D[3][1] = 1 ; D[3][2] = 1 ; D[3][3] = 1 ; │ │ │ │ │ -310 │ │ │ │ │ -311 std::array detD; │ │ │ │ │ -312 detD[0] = D.determinant(); │ │ │ │ │ -313 │ │ │ │ │ -314 for(unsigned i = 1; i < detD.size(); ++i) { │ │ │ │ │ -315 DD = D; │ │ │ │ │ -316 for (unsigned d = 0; d < dimWorld; ++d) │ │ │ │ │ -317 DD[d][i-1] = X[0][d]; │ │ │ │ │ -318 detD[i] = DD.determinant(); │ │ │ │ │ -319 if (std::abs(detD[i]) > eps && std::signbit(detD[0]) != std::signbit(detD │ │ │ │ │ -[i])) │ │ │ │ │ -320 return false; // We are outside. │ │ │ │ │ -321 } │ │ │ │ │ -322 │ │ │ │ │ -323 int k = insertPoint(X[0],P); │ │ │ │ │ -324 unsigned int faces[4] = {3,2,1,0}; │ │ │ │ │ -325 for (unsigned i = 1; i < detD.size(); ++i) │ │ │ │ │ -326 if(std::abs(detD[i]) < eps) │ │ │ │ │ -327 SY[faces[i-1]].push_back(k); // on triangle not containing node i-1 │ │ │ │ │ -328 │ │ │ │ │ -329 return true; │ │ │ │ │ -330 } │ │ │ │ │ -331 │ │ │ │ │ -332 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -333 std::vector >& subElements, │ │ │ │ │ -334 std::vector >& faceIds) │ │ │ │ │ -335 { │ │ │ │ │ -336 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -337 elementCorners,subElements, faceIds); │ │ │ │ │ -338 } │ │ │ │ │ -339 │ │ │ │ │ -340 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -341 std::vector >& subElements, │ │ │ │ │ -342 std::vector >& faceIds) │ │ │ │ │ -343 { │ │ │ │ │ -344 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -345 elementCorners, subElements, faceIds); │ │ │ │ │ -346 } │ │ │ │ │ -347}; │ │ │ │ │ -348 │ │ │ │ │ -349// SEGEMENT-SEGMENT INTERSECTION - :) │ │ │ │ │ -350template │ │ │ │ │ -351class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -352 friend class ComputationMethod; │ │ │ │ │ -353 │ │ │ │ │ -354public: │ │ │ │ │ -355 typedef FieldVector Vector; │ │ │ │ │ -356 static const int grid1Dimension = 1; │ │ │ │ │ -357 static const int grid2Dimension = 1; │ │ │ │ │ -358 static const int intersectionDimension = 1; │ │ │ │ │ -359 │ │ │ │ │ -360 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -361 const std::vector >& Y, │ │ │ │ │ -362 std::vector > & SX, │ │ │ │ │ -363 std::vector > & SY, │ │ │ │ │ -364 std::vector > & P) │ │ │ │ │ -365 { │ │ │ │ │ -366 assert(X.size() == 2 && Y.size() == 2); │ │ │ │ │ -367 │ │ │ │ │ -368 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -369 SX.resize(2); │ │ │ │ │ -370 SY.resize(2); │ │ │ │ │ -371 T eps = 1e-8; │ │ │ │ │ -372 int k,idX_min=-1,idX_max=-1,idY_min=-1,idY_max=-1; │ │ │ │ │ -373 │ │ │ │ │ -374 // compute intersections │ │ │ │ │ -375 switch (dimWorld) { │ │ │ │ │ -376 case 1: // d │ │ │ │ │ -377 { │ │ │ │ │ -378 FieldVector lowerbound(std::max(std::min(X[0][0],X[1][0]), │ │ │ │ │ -std::min(Y[0][0],X[1][0]))); │ │ │ │ │ -379 FieldVector upperbound(std::min(std::max(X[0][0],X[1][0]), │ │ │ │ │ -std::max(Y[0][0],Y[1][0]))); │ │ │ │ │ -380 │ │ │ │ │ -381 if (lowerbound[0] < upperbound[0]) { // Intersection is non-empty │ │ │ │ │ -382 │ │ │ │ │ -383 idX_min = (std::min(X[0][0],X[1][0]) < std::min(Y[0][0],Y[1][0]))?(-1):((X │ │ │ │ │ -[0][0] std::max(Y[0][0],Y[1][0]))?(-1):((X │ │ │ │ │ -[0][0]>X[1][0])?(0):(1)); │ │ │ │ │ -388 if (idX_max < 0) │ │ │ │ │ -389 idY_max = ((Y[0][0]>Y[1][0])?(0):(1)); │ │ │ │ │ -390 │ │ │ │ │ -391 k = insertPoint(lowerbound,P); │ │ │ │ │ -392 if (idX_min >= 0) │ │ │ │ │ -393 SX[idX_min].push_back(k); │ │ │ │ │ -394 else │ │ │ │ │ -395 SY[idY_min].push_back(k); │ │ │ │ │ -396 │ │ │ │ │ -397 k = insertPoint(upperbound,P); │ │ │ │ │ -398 if (idX_max >= 0) │ │ │ │ │ -399 SX[idX_max].push_back(k); │ │ │ │ │ -400 else │ │ │ │ │ -401 SY[idY_max].push_back(k); │ │ │ │ │ -402 │ │ │ │ │ -403 return true; │ │ │ │ │ -404 } │ │ │ │ │ -405 return false; │ │ │ │ │ -406 } │ │ │ │ │ -407 case 2: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0) │ │ │ │ │ -408 { // get size_type for all the vectors we are using │ │ │ │ │ -409 │ │ │ │ │ -410 FieldMatrix A; │ │ │ │ │ -411 A[0][0] = X[1][0] - X[0][0]; A[0][1] = Y[0][0] - Y[1][0]; │ │ │ │ │ -412 A[1][0] = X[1][1] - X[0][1]; A[1][1] = Y[0][1] - Y[1][1]; │ │ │ │ │ -413 │ │ │ │ │ -414 if (std::abs(A.determinant())>eps) { │ │ │ │ │ -415 // lines are non parallel and not degenerated │ │ │ │ │ -416 FieldVector p,r,b = Y[0] - X[0]; │ │ │ │ │ -417 A.solve(r,b) ; │ │ │ │ │ -418 │ │ │ │ │ -419 if ((r[0]>-eps)&&(r[0]<=1+eps)&&(r[1]>-eps)&&(r[1]<1+eps)) { │ │ │ │ │ -420 p = X[1] - X[0]; │ │ │ │ │ -421 p *= r[0] ; │ │ │ │ │ -422 p += X[0] ; │ │ │ │ │ -423 k = insertPoint(p,P); │ │ │ │ │ -424 if(r[0] < eps) { // X = X_0 + r_0 (X_1 - X_0) = X_0 │ │ │ │ │ -425 SX[0].push_back(k); │ │ │ │ │ -426 P[k] = X[0]; │ │ │ │ │ -427 } │ │ │ │ │ -428 else if(r[0] > 1-eps) { // X = X_0 + r_0 (X_1 - X_0) = X_1 │ │ │ │ │ -429 SX[1].push_back(k); │ │ │ │ │ -430 P[k] = X[1]; │ │ │ │ │ -431 } │ │ │ │ │ -432 if(r[1] < eps){ // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_0 │ │ │ │ │ -433 SY[0].push_back(k); │ │ │ │ │ -434 P[k] = Y[0]; │ │ │ │ │ -435 } │ │ │ │ │ -436 else if(r[1] > 1-eps) { // Y = Y_0 + r_1 (Y_1 - Y_0) = Y_1 │ │ │ │ │ -437 SY[1].push_back(k); │ │ │ │ │ -438 P[k] = Y[1]; │ │ │ │ │ -439 } │ │ │ │ │ -440 return true; │ │ │ │ │ -441 } │ │ │ │ │ -442 } else if ((X[1]-X[0]).infinity_norm() > eps && (Y[1]-Y[0]).infinity_norm() │ │ │ │ │ -> eps) { │ │ │ │ │ -443 // lines are parallels, but non degenerated │ │ │ │ │ -444 bool found = false; │ │ │ │ │ -445 │ │ │ │ │ -446 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2 for non │ │ │ │ │ -perpendicular lines │ │ │ │ │ -447 for (unsigned i = 0; i < 2; ++i) { │ │ │ │ │ -448 if (std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) │ │ │ │ │ -449 - std::abs((X[1]-X[0]).two_norm())) < eps) { │ │ │ │ │ -450 k = insertPoint(Y[i],P); │ │ │ │ │ -451 SY[i].push_back(k); │ │ │ │ │ -452 found = true; │ │ │ │ │ -453 } │ │ │ │ │ -454 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) │ │ │ │ │ -455 - std::abs((Y[1]-Y[0]).two_norm())) < eps) { │ │ │ │ │ -456 k = insertPoint(X[i],P); │ │ │ │ │ -457 SX[i].push_back(k); │ │ │ │ │ -458 found = true; │ │ │ │ │ -459 } │ │ │ │ │ -460 } │ │ │ │ │ -461 return found; │ │ │ │ │ -462 } │ │ │ │ │ -463 return false; │ │ │ │ │ -464 } │ │ │ │ │ -465 case 3: // solve X0 + r_0 * (X1 - X0) = Y0 + r_1 * (Y1 - Y0) │ │ │ │ │ -466 { FieldVector dX, dY, dZ, cXY, cYZ; │ │ │ │ │ -467 │ │ │ │ │ -468 dX = X[1]-X[0]; │ │ │ │ │ -469 dY = Y[1]-Y[0]; │ │ │ │ │ -470 dZ = Y[0]-X[0]; │ │ │ │ │ -471 │ │ │ │ │ -472 cXY[0] = dX[1]* dY[2] - dX[2]* dY[1]; │ │ │ │ │ -473 cXY[1] = dX[2]* dY[0] - dX[0]* dY[2]; │ │ │ │ │ -474 cXY[2] = dX[0]* dY[1] - dX[1]* dY[0]; │ │ │ │ │ -475 │ │ │ │ │ -476 if (fabs(dZ.dot(cXY)) < eps*1e+3 && cXY.infinity_norm()>eps) { // coplanar, │ │ │ │ │ -but not aligned │ │ │ │ │ -477 │ │ │ │ │ -478 cYZ[0] = dY[1]* dZ[2] - dY[2]* dZ[1]; │ │ │ │ │ -479 cYZ[1] = dY[2]* dZ[0] - dY[0]* dZ[2]; │ │ │ │ │ -480 cYZ[2] = dY[0]* dZ[1] - dY[1]* dZ[0]; │ │ │ │ │ -481 │ │ │ │ │ -482 T s = -cYZ.dot(cXY) / cXY.two_norm2(); │ │ │ │ │ -483 │ │ │ │ │ -484 if (s > -eps && s < 1+eps) { │ │ │ │ │ -485 dX*= s; │ │ │ │ │ -486 dX+= X[0]; │ │ │ │ │ -487 T o = (dX - Y[0]).two_norm() + (dX- Y[1]).two_norm(); │ │ │ │ │ -488 │ │ │ │ │ -489 if (std::abs(o-dY.two_norm()) < eps) { │ │ │ │ │ -490 k = insertPoint(dX,P); │ │ │ │ │ -491 \ │ │ │ │ │ -492 if (s 1-eps) { │ │ │ │ │ -496 P[k] = X[1]; │ │ │ │ │ -497 SX[1].push_back(k); │ │ │ │ │ -498 } else if ((dX - Y[0]).two_norm() < eps) { │ │ │ │ │ -499 P[k] = Y[0]; │ │ │ │ │ -500 SY[0].push_back(k); │ │ │ │ │ -501 } else if((dX - Y[1]).two_norm() < eps) { │ │ │ │ │ -502 P[k] = Y[1]; │ │ │ │ │ -503 SY[1].push_back(k); │ │ │ │ │ -504 } │ │ │ │ │ -505 │ │ │ │ │ -506 return true; │ │ │ │ │ -507 } │ │ │ │ │ -508 } │ │ │ │ │ -509 } else if (cXY.infinity_norm() <= eps) {// lines are parallel │ │ │ │ │ -510 │ │ │ │ │ -511 bool found = false; │ │ │ │ │ -512 │ │ │ │ │ -513 // use triangle equality ||a - b||_2 = || a -c ||_2 + || c - b ||_2, │ │ │ │ │ -514 // under the assumption (a-c)*(c-b) > 0 or (a-c) = 0 or (c-b) = 0 │ │ │ │ │ -515 for (unsigned i = 0; i < 2; ++i) { │ │ │ │ │ -516 if ((std::abs((Y[i]-X[0]).two_norm() + std::abs((Y[i]-X[1]).two_norm()) / │ │ │ │ │ -/ triangle equality │ │ │ │ │ -517 - std::abs((X[1]-X[0]).two_norm())) < eps) && │ │ │ │ │ -518 (std::abs((Y[i]-X[0]).dot((Y[i]-X[1]))) > eps // assumption │ │ │ │ │ -519 || (Y[i]-X[0]).infinity_norm() < eps || (Y[i]-X[1]).infinity_norm() < eps)) │ │ │ │ │ -{ │ │ │ │ │ -520 k = insertPoint(Y[i],P); │ │ │ │ │ -521 SY[i].push_back(k); │ │ │ │ │ -522 found = true; │ │ │ │ │ -523 } │ │ │ │ │ -524 if (std::abs((X[i]-Y[0]).two_norm() + std::abs((X[i]-Y[1]).two_norm()) / │ │ │ │ │ -/ triangle equality │ │ │ │ │ -525 - std::abs((Y[1]-Y[0]).two_norm())) < eps && │ │ │ │ │ -526 (std::abs((X[i]-Y[0]).dot((X[i]-Y[1]))) > eps // assumption │ │ │ │ │ -527 || (X[i]-Y[0]).infinity_norm() < eps || (X[i]-Y[1]).infinity_norm() < eps)) │ │ │ │ │ -{ │ │ │ │ │ -528 k = insertPoint(X[i],P); │ │ │ │ │ -529 SX[i].push_back(k); │ │ │ │ │ -530 found = true; │ │ │ │ │ -531 } │ │ │ │ │ -532 } │ │ │ │ │ -533 return found; │ │ │ │ │ -534 } │ │ │ │ │ -535 │ │ │ │ │ -536 return false; │ │ │ │ │ -537 } │ │ │ │ │ -538 } │ │ │ │ │ -539 return false; │ │ │ │ │ -540 } │ │ │ │ │ -541 │ │ │ │ │ -542 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -543 std::vector >& subElements, │ │ │ │ │ -544 std::vector >& faceIds) │ │ │ │ │ -545 { │ │ │ │ │ -546 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -547 elementCorners,subElements, faceIds); │ │ │ │ │ -548 } │ │ │ │ │ -549 │ │ │ │ │ -550 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -551 std::vector >& subElements, │ │ │ │ │ -552 std::vector >& faceIds) │ │ │ │ │ -553 { │ │ │ │ │ -554 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -555 elementCorners, subElements, faceIds); │ │ │ │ │ -556 } │ │ │ │ │ -557}; │ │ │ │ │ -558 │ │ │ │ │ -559// SEGEMENT-TRIANGLE INTERSECTION - : ) │ │ │ │ │ -560template │ │ │ │ │ -561class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -562 friend class ComputationMethod; │ │ │ │ │ -563 │ │ │ │ │ -564public: │ │ │ │ │ -565 typedef FieldVector Vector; │ │ │ │ │ -566 static const int grid1Dimension = 1; │ │ │ │ │ -567 static const int grid2Dimension = 2; │ │ │ │ │ -568 static const int intersectionDimension = 1; │ │ │ │ │ -569 │ │ │ │ │ -570 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -571 const std::vector >& Y, │ │ │ │ │ -572 std::vector > & SX, │ │ │ │ │ -573 std::vector > & SY, │ │ │ │ │ -574 std::vector > & P) │ │ │ │ │ -575 { │ │ │ │ │ -576 │ │ │ │ │ -577 assert(X.size() == 2 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ -578 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -579 SX.resize(2); │ │ │ │ │ -580 SY.resize(3); │ │ │ │ │ -581 │ │ │ │ │ -582 int k; │ │ │ │ │ -583 std::vector > surfPts, edge(2), pni(1); │ │ │ │ │ -584 std::vector > hSX, hSY; │ │ │ │ │ -585 │ │ │ │ │ -586 // is any segment point inside the triangle? │ │ │ │ │ -587 for (unsigned ni = 0; ni < 2; ++ni) { │ │ │ │ │ -588 pni[0] = X[ni]; │ │ │ │ │ -589 │ │ │ │ │ -590 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(pni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ -591 k = insertPoint(X[ni],P); │ │ │ │ │ -592 SX[ni].push_back(k); │ │ │ │ │ -593 for (unsigned e=0; e < 3; ++e) │ │ │ │ │ -594 if (hSY[e].size() > 0) │ │ │ │ │ -595 SY[e].push_back(k); │ │ │ │ │ -596 │ │ │ │ │ -597 } │ │ │ │ │ -598 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ -599 } │ │ │ │ │ -600 │ │ │ │ │ -601 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ -602 return true; │ │ │ │ │ -603 │ │ │ │ │ -604 unsigned int faces[3] = {0,2,1}; │ │ │ │ │ -605 // do triangle faces intersect with the segment? │ │ │ │ │ -606 for (unsigned ni = 0; ni < 3; ++ni) { │ │ │ │ │ -607 edge[0] = Y[ni]; │ │ │ │ │ -608 edge[1] = Y[(ni+1)%3]; │ │ │ │ │ -609 │ │ │ │ │ -610 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(X,edge,hSX,hSY,surfPts)) { │ │ │ │ │ -611 for (unsigned ne = 0; ne < surfPts.size(); ++ne) { │ │ │ │ │ -612 k = insertPoint(surfPts[ne],P); │ │ │ │ │ -613 SY[faces[ni]].push_back(k); │ │ │ │ │ -614 if (hSX[0].size() > 0) │ │ │ │ │ -615 SX[0].push_back(k); │ │ │ │ │ -616 if (hSX[1].size() > 0) │ │ │ │ │ -617 SX[1].push_back(k); │ │ │ │ │ -618 } │ │ │ │ │ -619 │ │ │ │ │ -620 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ -621 return true; │ │ │ │ │ -622 │ │ │ │ │ -623 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ -624 } │ │ │ │ │ -625 } │ │ │ │ │ -626 │ │ │ │ │ -627 if (P.size() >= 2) // we cannot have more than two intersection points │ │ │ │ │ -628 return true; │ │ │ │ │ -629 │ │ │ │ │ -630 // if line and triangle are not coplanar in 3d and do not intersect at │ │ │ │ │ -boundaries │ │ │ │ │ -631 if (dimWorld == 3) { │ │ │ │ │ -632 T eps = 1e-8; │ │ │ │ │ -633 │ │ │ │ │ -634 Dune::FieldVector B,r,p ; │ │ │ │ │ -635 Dune::FieldMatrix A ; │ │ │ │ │ -636 │ │ │ │ │ -637 B = Y[0] - X[0] ; │ │ │ │ │ -638 │ │ │ │ │ -639 for (unsigned i = 0; i < dimWorld; ++i) { │ │ │ │ │ -640 A[i][0] = (X[1][i] - X[0][i]); │ │ │ │ │ -641 A[i][1] = (Y[0][i] - Y[1][i]); │ │ │ │ │ -642 A[i][dimWorld-1] = (Y[0][i] - Y[dimWorld-1][i]); │ │ │ │ │ -643 } │ │ │ │ │ -644 │ │ │ │ │ -645 if (std::abs(A.determinant())>eps) { │ │ │ │ │ -646 │ │ │ │ │ -647 A.solve(r,B) ; │ │ │ │ │ -648 │ │ │ │ │ -649 if ((r[0]>=-eps)&&(r[0]<=1+eps) │ │ │ │ │ -650 &&(r[1]>=-eps)&&(r[1]<=1+eps) │ │ │ │ │ -651 &&(r[2]>=-eps)&&(r[2]<=1+eps) │ │ │ │ │ -652 &&(r[1]+r[2]>=-eps) &&(r[1]+r[2]<=1+eps)) { │ │ │ │ │ -653 p = X[1] - X[0] ; │ │ │ │ │ -654 p *= r[0] ; │ │ │ │ │ -655 p += X[0] ; │ │ │ │ │ -656 k = insertPoint(p,P); │ │ │ │ │ -657 │ │ │ │ │ -658 if (std::abs(r[0]) < eps) // we prefer exact locations │ │ │ │ │ -659 P[k] = X[0]; │ │ │ │ │ -660 else if (std::abs(r[0]) > 1-eps) │ │ │ │ │ -661 P[k] = X[1]; │ │ │ │ │ -662 else if (std::abs(r[1]) < eps && std::abs(r[2]) < eps) │ │ │ │ │ -663 P[k] = Y[0]; │ │ │ │ │ -664 else if (std::abs(r[1]) < eps && std::abs(r[2]) > 1-eps) │ │ │ │ │ -665 P[k] = Y[2]; │ │ │ │ │ -666 else if (std::abs(r[1]) > 1-eps && std::abs(r[2]) < eps) │ │ │ │ │ -667 P[k] = Y[1]; │ │ │ │ │ -668 │ │ │ │ │ -669 if (std::abs(r[1]) < eps) │ │ │ │ │ -670 SY[1].push_back(k); │ │ │ │ │ -671 if (std::fabs(r[dimWorld-1]) < eps) │ │ │ │ │ -672 SY[0].push_back(k); │ │ │ │ │ -673 if (std::fabs(r[1]+r[dimWorld-1] - 1) < eps) │ │ │ │ │ -674 SY[2].push_back(k); │ │ │ │ │ -675 │ │ │ │ │ -676 │ │ │ │ │ -677 return true ; │ │ │ │ │ -678 } │ │ │ │ │ -679 } │ │ │ │ │ -680 } │ │ │ │ │ -681 return false ; │ │ │ │ │ -682 } │ │ │ │ │ -683 │ │ │ │ │ -684 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -685 std::vector >& subElements, │ │ │ │ │ -686 std::vector >& faceIds) │ │ │ │ │ -687 { │ │ │ │ │ -688 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -689 elementCorners,subElements, faceIds); │ │ │ │ │ -690 } │ │ │ │ │ -691 │ │ │ │ │ -692 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -693 std::vector >& subElements, │ │ │ │ │ -694 std::vector >& faceIds) │ │ │ │ │ -695 { │ │ │ │ │ -696 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -697 elementCorners, subElements, faceIds); │ │ │ │ │ -698 } │ │ │ │ │ -699}; │ │ │ │ │ -700 │ │ │ │ │ -701// SEGEMENT-TETRAHEDRON INTERSECTION - : ) │ │ │ │ │ -702template │ │ │ │ │ -703class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -704 friend class ComputationMethod; │ │ │ │ │ -705 │ │ │ │ │ -706public: │ │ │ │ │ -707 typedef FieldVector Vector; │ │ │ │ │ -708 static const int grid1Dimension = 1; │ │ │ │ │ -709 static const int grid2Dimension = 3; │ │ │ │ │ -710 static const int intersectionDimension = 1; │ │ │ │ │ -711 │ │ │ │ │ -712 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -713 const std::vector >& Y, │ │ │ │ │ -714 std::vector > & SX, │ │ │ │ │ -715 std::vector > & SY, │ │ │ │ │ -716 std::vector > & P) │ │ │ │ │ -717 { │ │ │ │ │ -718 assert(X.size() == 2 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ -719 │ │ │ │ │ -720 std::vector indices; │ │ │ │ │ -721 std::vector > surfPts; │ │ │ │ │ -722 std::vector > hSX, hSY; │ │ │ │ │ -723 │ │ │ │ │ -724 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -725 SX.resize(2); │ │ │ │ │ -726 SY.resize(4); │ │ │ │ │ -727 │ │ │ │ │ -728 std::vector > pni(1); │ │ │ │ │ -729 │ │ │ │ │ -730 bool b = false; │ │ │ │ │ -731 │ │ │ │ │ -732 // check whether the corners of the segment are contained in the │ │ │ │ │ -tetrahedron │ │ │ │ │ -733 for (unsigned int ci = 0; ci < 2; ++ ci) { │ │ │ │ │ -734 │ │ │ │ │ -735 pni[0] = X[ci]; │ │ │ │ │ -736 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(pni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ -737 int k = insertPoint(X[ci],P); │ │ │ │ │ -738 SX[ci].push_back(k); │ │ │ │ │ -739 b=true; │ │ │ │ │ -740 } │ │ │ │ │ -741 surfPts.clear(); │ │ │ │ │ -742 hSX.clear(); hSY.clear(); │ │ │ │ │ -743 } │ │ │ │ │ -744 │ │ │ │ │ -745 if (P.size() == 2) │ │ │ │ │ -746 return true; │ │ │ │ │ -747 │ │ │ │ │ -748 unsigned int faces[4] = {0,3,2,1}; │ │ │ │ │ -749 // check whether tetrahedron faces intersect with segment │ │ │ │ │ -750 std::vector > triangle(3); │ │ │ │ │ -751 for (unsigned int ci = 0; ci < 4; ++ci) { // iterate over all faces │ │ │ │ │ -752 triangle[0] = Y[ci]; │ │ │ │ │ -753 triangle[1] = Y[(ci+1)%4]; │ │ │ │ │ -754 triangle[2] = Y[(ci+2)%4]; │ │ │ │ │ -755 │ │ │ │ │ -756 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(X,triangle,hSX,hSY,surfPts)) { // seg - triangle intersection │ │ │ │ │ -757 std::vector indices(surfPts.size()); │ │ │ │ │ -758 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -759 int k = insertPoint(surfPts[np],P); │ │ │ │ │ -760 indices[np]=k; │ │ │ │ │ -761 SY[faces[ci]].push_back(k); │ │ │ │ │ -762 } │ │ │ │ │ -763 │ │ │ │ │ -764 // hSX[*] is nonempty if the intersection point is on an edge of the │ │ │ │ │ -current face of Y │ │ │ │ │ -765 for (unsigned int np = 0; np < hSX[0].size(); ++np) │ │ │ │ │ -766 SX[0].push_back(indices[hSX[0][np]]); │ │ │ │ │ -767 for (unsigned int np = 0; np < hSX[1].size(); ++np) │ │ │ │ │ -768 SX[0].push_back(indices[hSX[1][np]]); │ │ │ │ │ -769 │ │ │ │ │ -770 b = true; │ │ │ │ │ -771 } │ │ │ │ │ -772 surfPts.clear(); │ │ │ │ │ -773 hSX.clear(); hSY.clear(); │ │ │ │ │ -774 } │ │ │ │ │ -775 │ │ │ │ │ -776 return b; │ │ │ │ │ -777 } │ │ │ │ │ -778 │ │ │ │ │ -779 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -780 std::vector >& subElements, │ │ │ │ │ -781 std::vector >& faceIds) │ │ │ │ │ -782 { │ │ │ │ │ -783 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -784 elementCorners,subElements, faceIds); │ │ │ │ │ -785 } │ │ │ │ │ -786 │ │ │ │ │ -787 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -788 std::vector >& subElements, │ │ │ │ │ -789 std::vector >& faceIds) │ │ │ │ │ -790 { │ │ │ │ │ -791 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -792 elementCorners, subElements, faceIds); │ │ │ │ │ -793 } │ │ │ │ │ -794}; │ │ │ │ │ -795 │ │ │ │ │ -796// TRIANGLE -TRIANGLE INTERSECTION │ │ │ │ │ -797template │ │ │ │ │ -798class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -799 friend class ComputationMethod; │ │ │ │ │ -800 │ │ │ │ │ -801public: │ │ │ │ │ -802 typedef FieldVector Vector; │ │ │ │ │ -803 static const int grid1Dimension = 2; │ │ │ │ │ -804 static const int grid2Dimension = 2; │ │ │ │ │ -805 static const int intersectionDimension = 2; │ │ │ │ │ -806 │ │ │ │ │ -807 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -808 const std::vector >& Y, │ │ │ │ │ -809 std::vector > & SX, │ │ │ │ │ -810 std::vector > & SY, │ │ │ │ │ -811 std::vector > & P) │ │ │ │ │ -812 { │ │ │ │ │ -813 assert(X.size() == 3 && Y.size() == 3 && dimWorld > 1); │ │ │ │ │ -814 │ │ │ │ │ -815 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -816 │ │ │ │ │ -817 SX.resize(3); │ │ │ │ │ -818 SY.resize(3); │ │ │ │ │ -819 │ │ │ │ │ -820 bool b = false; │ │ │ │ │ -821 │ │ │ │ │ -822 std::vector > edge(2); │ │ │ │ │ -823 std::vector > surfPts; │ │ │ │ │ -824 std::vector > hSX, hSY; │ │ │ │ │ -825 std::vector indices; │ │ │ │ │ -826 │ │ │ │ │ -827 unsigned int faces[3] = {0,2,1}; │ │ │ │ │ -828 │ │ │ │ │ -829 for (unsigned int ni = 0; ni < 3; ++ni) { │ │ │ │ │ -830 // check whether the faces of triangle Y intersect the triangle X │ │ │ │ │ -831 edge[0] = Y[ni]; │ │ │ │ │ -832 edge[1] = Y[(ni+1)%3]; │ │ │ │ │ -833 │ │ │ │ │ -834 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(X,edge,hSX,hSY,surfPts)) { │ │ │ │ │ -835 │ │ │ │ │ -836 indices.resize(surfPts.size()); │ │ │ │ │ -837 // add intersections of edges of Y with triangle X │ │ │ │ │ -838 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -839 int k = insertPoint(surfPts[np],P); │ │ │ │ │ -840 indices[np] = k; │ │ │ │ │ -841 SY[faces[ni]].push_back(k); // add edge data │ │ │ │ │ -842 } │ │ │ │ │ -843 │ │ │ │ │ -844 b=true; │ │ │ │ │ -845 } │ │ │ │ │ -846 if (P.size() >= 6) │ │ │ │ │ -847 return true; │ │ │ │ │ -848 │ │ │ │ │ -849 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ -850 // check whether the faces of triangle X intersect the triangle Y │ │ │ │ │ -851 edge[0] = X[ni]; │ │ │ │ │ -852 edge[1] = X[(ni+1)%3]; │ │ │ │ │ -853 │ │ │ │ │ -854 if(SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(edge,Y,hSX,hSY,surfPts)) { │ │ │ │ │ -855 │ │ │ │ │ -856 indices.resize(surfPts.size()); │ │ │ │ │ -857 // add intersections of edges of X with triangle Y │ │ │ │ │ -858 for (unsigned int np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -859 int k = insertPoint(surfPts[np],P); │ │ │ │ │ -860 indices[np] = k; │ │ │ │ │ -861 SX[faces[ni]].push_back(k); // add edge data │ │ │ │ │ -862 } │ │ │ │ │ -863 │ │ │ │ │ -864 b=true; │ │ │ │ │ -865 } │ │ │ │ │ -866 if (P.size() >= 6) │ │ │ │ │ -867 return true; │ │ │ │ │ -868 │ │ │ │ │ -869 surfPts.clear(); hSX.clear(); hSY.clear(); │ │ │ │ │ -870 } │ │ │ │ │ -871 │ │ │ │ │ -872 return b; │ │ │ │ │ -873 } │ │ │ │ │ -874 │ │ │ │ │ -875 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -876 std::vector >& subElements, │ │ │ │ │ -877 std::vector >& faceIds) │ │ │ │ │ -878 { │ │ │ │ │ -879 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -880 elementCorners,subElements, faceIds); │ │ │ │ │ -881 } │ │ │ │ │ -882 │ │ │ │ │ -883 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -884 std::vector >& subElements, │ │ │ │ │ -885 std::vector >& faceIds) │ │ │ │ │ -886 { │ │ │ │ │ -887 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -888 elementCorners, subElements, faceIds); │ │ │ │ │ -889 } │ │ │ │ │ -890}; │ │ │ │ │ -891 │ │ │ │ │ -892// TRIANGLE -TETRAHEDRON INTERSECTION -: ) │ │ │ │ │ -893template │ │ │ │ │ -894class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -895 friend class ComputationMethod; │ │ │ │ │ -896 │ │ │ │ │ -897public: │ │ │ │ │ -898 typedef FieldVector Vector; │ │ │ │ │ -899 static const int grid1Dimension = 2; │ │ │ │ │ -900 static const int grid2Dimension = 3; │ │ │ │ │ -901 static const int intersectionDimension = 2; │ │ │ │ │ -902 │ │ │ │ │ -903 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -904 const std::vector >& Y, │ │ │ │ │ -905 std::vector > & SX, │ │ │ │ │ -906 std::vector > & SY, │ │ │ │ │ -907 std::vector > & P) │ │ │ │ │ -908 { │ │ │ │ │ -909 assert(X.size() == 3 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ -910 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -911 SX.resize(3); │ │ │ │ │ -912 SY.resize(4); │ │ │ │ │ -913 │ │ │ │ │ -914 bool b = false; │ │ │ │ │ -915 int k,ni,np, ep; │ │ │ │ │ -916 std::vector > surfPts, xni(1); │ │ │ │ │ -917 std::vector > hSX, hSY; │ │ │ │ │ -918 │ │ │ │ │ -919 unsigned int fiX[3][2]; │ │ │ │ │ -920 │ │ │ │ │ -921 fiX[0][0] = 0; fiX[1][0] = 0; fiX[2][0] = 1; // faces to node │ │ │ │ │ -922 fiX[0][1] = 1; fiX[1][1] = 2; fiX[2][1] = 2; │ │ │ │ │ -923 // 1st step: check whether the points of the triangle are contained in the │ │ │ │ │ -tetrahedron │ │ │ │ │ -924 for (ni = 0; ni < 3; ++ni) { │ │ │ │ │ -925 │ │ │ │ │ -926 xni[0] = X[ni]; │ │ │ │ │ -927 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(xni,Y,hSX,hSY,surfPts)) { │ │ │ │ │ -928 std::vector indices(surfPts.size()); │ │ │ │ │ -929 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -930 k = insertPoint(X[ni],P); │ │ │ │ │ -931 indices[np] = k; │ │ │ │ │ -932 SX[fiX[ni][0]].push_back(k); // the corresponding edges to the node are ni │ │ │ │ │ -and (ni+2)%3 │ │ │ │ │ -933 SX[fiX[ni][1]].push_back(k); │ │ │ │ │ -934 } │ │ │ │ │ -935 │ │ │ │ │ -936 for (ep = 0; ep < 4; ++ep) { │ │ │ │ │ -937 for (np = 0; np < hSY[ep].size();++np) { │ │ │ │ │ -938 SY[ep].push_back(indices[hSY[ep][np]]); │ │ │ │ │ -939 } │ │ │ │ │ -940 } │ │ │ │ │ -941 b = true; │ │ │ │ │ -942 } │ │ │ │ │ -943 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -944 } │ │ │ │ │ -945 │ │ │ │ │ -946 if (P.size() == 3) // intersection is given by all three corners of the │ │ │ │ │ -triangle │ │ │ │ │ -947 return true; │ │ │ │ │ -948 │ │ │ │ │ -949 // note: points of Y in X is called indirectly via triangle-triangle │ │ │ │ │ -intesection │ │ │ │ │ -950 │ │ │ │ │ -951 // check whether the triangles of the one tetrahedron intersect the │ │ │ │ │ -triangle │ │ │ │ │ -952 unsigned int facesY[4] = {0,3,2,1}; // face ordering │ │ │ │ │ -953 │ │ │ │ │ -954 std::vector > triangle(3); │ │ │ │ │ -955 for (ni = 0; ni < 4; ++ni) { │ │ │ │ │ -956 │ │ │ │ │ -957 triangle[0] = Y[ni]; │ │ │ │ │ -958 triangle[1] = Y[(ni+1)%4]; │ │ │ │ │ -959 triangle[2] = Y[(ni+2)%4]; │ │ │ │ │ -960 │ │ │ │ │ -961 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(X,triangle,hSX,hSY,surfPts)) { │ │ │ │ │ -962 std::vector indices(surfPts.size()); │ │ │ │ │ -963 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -964 k = insertPoint(surfPts[np],P); │ │ │ │ │ -965 indices[np]=k; │ │ │ │ │ -966 SY[facesY[ni]].push_back(k); │ │ │ │ │ -967 } │ │ │ │ │ -968 │ │ │ │ │ -969 // SX[*] is nonempty if the face * of X is intersected │ │ │ │ │ -970 for (np = 0; np < 3; ++np) { │ │ │ │ │ -971 for (ep = 0; ep < hSX[np].size(); ++ep) { │ │ │ │ │ -972 SX[np].push_back(indices[hSX[np][ep]]); │ │ │ │ │ -973 } │ │ │ │ │ -974 } │ │ │ │ │ -975 │ │ │ │ │ -976 b = true; │ │ │ │ │ -977 } │ │ │ │ │ -978 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -979 } │ │ │ │ │ -980 return b; │ │ │ │ │ -981 } │ │ │ │ │ -982 │ │ │ │ │ -983 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -984 std::vector >& subElements, │ │ │ │ │ -985 std::vector >& faceIds) │ │ │ │ │ -986 { │ │ │ │ │ -987 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -988 elementCorners,subElements, faceIds); │ │ │ │ │ -989 } │ │ │ │ │ -990 │ │ │ │ │ -991 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -992 std::vector >& subElements, │ │ │ │ │ -993 std::vector >& faceIds) │ │ │ │ │ -994 { │ │ │ │ │ -995 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -996 elementCorners, subElements, faceIds); │ │ │ │ │ -997 } │ │ │ │ │ -998}; │ │ │ │ │ -999 │ │ │ │ │ -1000template │ │ │ │ │ -1001class SimplexMethod : public │ │ │ │ │ -ComputationMethod{ │ │ │ │ │ -1002 friend class ComputationMethod; │ │ │ │ │ -1003 │ │ │ │ │ -1004public: │ │ │ │ │ -1005 typedef FieldVector Vector; │ │ │ │ │ -1006 static const int grid1Dimension = 3; │ │ │ │ │ -1007 static const int grid2Dimension = 3; │ │ │ │ │ -1008 static const int intersectionDimension = 3; │ │ │ │ │ -1009 │ │ │ │ │ -1010 static bool computeIntersectionPoints(const std:: │ │ │ │ │ -vector >& X, │ │ │ │ │ -1011 const std::vector >& Y, │ │ │ │ │ -1012 std::vector > & SX, │ │ │ │ │ -1013 std::vector > & SY, │ │ │ │ │ -1014 std::vector > & P) │ │ │ │ │ -1015 { │ │ │ │ │ -1016 assert(X.size() == 4 && Y.size() == 4 && dimWorld > 2); │ │ │ │ │ -1017 P.clear(); SX.clear(); SY.clear(); │ │ │ │ │ -1018 │ │ │ │ │ -1019 SX.resize(4); │ │ │ │ │ -1020 SY.resize(4); │ │ │ │ │ -1021 │ │ │ │ │ -1022 bool b = false; │ │ │ │ │ -1023 int ci,np,ne,k,ni[4][3]; │ │ │ │ │ -1024 │ │ │ │ │ -1025 ni[0][0]= 0 ; ni[0][1]= 1 ; ni[0][2]= 2 ; // faces touching each node │ │ │ │ │ -1026 ni[1][0]= 0 ; ni[1][1]= 1 ; ni[1][2]= 3 ; │ │ │ │ │ -1027 ni[2][0]= 0 ; ni[2][1]= 2 ; ni[2][2]= 3 ; │ │ │ │ │ -1028 ni[3][0]= 1 ; ni[3][1]= 2 ; ni[3][2]= 3 ; │ │ │ │ │ -1029 │ │ │ │ │ -1030 // temporal data container │ │ │ │ │ -1031 std::vector > surfPts, pci(1); │ │ │ │ │ -1032 std::vector > hSX, hSY; │ │ │ │ │ -1033 │ │ │ │ │ -1034 // check whether the points of the one tetrahedron are contained in the │ │ │ │ │ -other tetrahedron │ │ │ │ │ -1035 for (ci = 0; ci < 3; ++ci) { │ │ │ │ │ -1036 pci[0] = X[ci]; │ │ │ │ │ -1037 // point of X is inside Y │ │ │ │ │ -1038 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(pci,Y,hSX,hSY,surfPts)) { │ │ │ │ │ -1039 std::vector indices(surfPts.size()); │ │ │ │ │ -1040 │ │ │ │ │ -1041 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -1042 │ │ │ │ │ -1043 k = insertPoint(X[ci],P); │ │ │ │ │ -1044 indices[np]=k; │ │ │ │ │ -1045 SX[ni[ci][0]].push_back(k); // add face data │ │ │ │ │ -1046 SX[ni[ci][1]].push_back(k); │ │ │ │ │ -1047 SX[ni[ci][2]].push_back(k); │ │ │ │ │ -1048 } │ │ │ │ │ -1049 │ │ │ │ │ -1050 // hSY[*] is nonempty if X[ci] is on the face * of Y │ │ │ │ │ -1051 for (ne = 0; ne < 4; ++ne) { │ │ │ │ │ -1052 for (np = 0; np < hSY[ne].size(); ++np) { │ │ │ │ │ -1053 SY[ne].push_back(indices[hSY[ne][np]]); │ │ │ │ │ -1054 } │ │ │ │ │ -1055 } │ │ │ │ │ -1056 │ │ │ │ │ -1057 b = true; │ │ │ │ │ -1058 } │ │ │ │ │ -1059 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -1060 │ │ │ │ │ -1061 // probably one point of Y is inside X │ │ │ │ │ -1062 surfPts.resize(0); │ │ │ │ │ -1063 pci[0]=Y[ci]; │ │ │ │ │ -1064 if (SimplexMethod::computeIntersectionPoints │ │ │ │ │ -(pci,X,hSY,hSX,surfPts)) { │ │ │ │ │ -1065 std::vector indices(surfPts.size()); │ │ │ │ │ -1066 │ │ │ │ │ -1067 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -1068 k = insertPoint(Y[ci],P); │ │ │ │ │ -1069 indices[np]=k; │ │ │ │ │ -1070 SY[ni[ci][0]].push_back(k); // add face data │ │ │ │ │ -1071 SY[ni[ci][1]].push_back(k); │ │ │ │ │ -1072 SY[ni[ci][2]].push_back(k); │ │ │ │ │ -1073 } │ │ │ │ │ -1074 │ │ │ │ │ -1075 // hSX[*] is nonempty if the point Y[ci] is on the face * of X │ │ │ │ │ -1076 for (ne = 0; ne < 4; ++ne) { │ │ │ │ │ -1077 for (np = 0; np < hSX[ne].size(); ++np) { │ │ │ │ │ -1078 SX[ne].push_back(indices[hSX[ne][np]]); │ │ │ │ │ -1079 } │ │ │ │ │ -1080 } │ │ │ │ │ -1081 b = true; │ │ │ │ │ -1082 } │ │ │ │ │ -1083 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -1084 } │ │ │ │ │ -1085 │ │ │ │ │ -1086 // check whether the triangles of the one tetrahedron intersect the │ │ │ │ │ -triangles │ │ │ │ │ -1087 // of the other tetrahedron │ │ │ │ │ -1088 unsigned int faces[4] = {0,3,2,1}; // face ordering │ │ │ │ │ -1089 │ │ │ │ │ -1090 std::vector > triangle(3); │ │ │ │ │ -1091 for (ci = 0; ci < 4; ++ci) { // iterate over faces of Y │ │ │ │ │ -1092 │ │ │ │ │ -1093 triangle[0] = Y[ci]; │ │ │ │ │ -1094 triangle[1] = Y[(ci+1)%4]; │ │ │ │ │ -1095 triangle[2] = Y[(ci+2)%4]; │ │ │ │ │ -1096 │ │ │ │ │ -1097 if(SimplexMethod::computeIntersectionPoints(X, │ │ │ │ │ -triangle,hSX,hSY,surfPts)) { │ │ │ │ │ -1098 │ │ │ │ │ -1099 // add Triangle of Y intersects tetrahedron Y data │ │ │ │ │ -1100 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -1101 k = insertPoint(surfPts[np],P); │ │ │ │ │ -1102 SY[faces[ci]].push_back(k); // add face data │ │ │ │ │ -1103 } │ │ │ │ │ -1104 b = true; │ │ │ │ │ -1105 } │ │ │ │ │ -1106 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -1107 │ │ │ │ │ -1108 triangle[0] = X[ci]; │ │ │ │ │ -1109 triangle[1] = X[(ci+1)%4]; │ │ │ │ │ -1110 triangle[2] = X[(ci+2)%4]; │ │ │ │ │ -1111 │ │ │ │ │ -1112 if(SimplexMethod::computeIntersectionPoints(Y, │ │ │ │ │ -triangle,hSY,hSX,surfPts)) { │ │ │ │ │ -1113 │ │ │ │ │ -1114 // add Triangle of Y intersects tetrahedron Y data │ │ │ │ │ -1115 for (np = 0; np < surfPts.size(); ++np) { │ │ │ │ │ -1116 k = insertPoint(surfPts[np],P); │ │ │ │ │ -1117 SX[faces[ci]].push_back(k); // add face data │ │ │ │ │ -1118 } │ │ │ │ │ -1119 b = true; │ │ │ │ │ -1120 } │ │ │ │ │ -1121 hSX.clear(); hSY.clear(); surfPts.clear(); │ │ │ │ │ -1122 } │ │ │ │ │ -1123 │ │ │ │ │ -1124 return b; │ │ │ │ │ -1125 } │ │ │ │ │ -1126 │ │ │ │ │ -1127 static void grid1_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -1128 std::vector >& subElements, │ │ │ │ │ -1129 std::vector >& faceIds) │ │ │ │ │ -1130 { │ │ │ │ │ -1131 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -1132 elementCorners,subElements, faceIds); │ │ │ │ │ -1133 } │ │ │ │ │ -1134 │ │ │ │ │ -1135 static void grid2_subdivisions(const std::vector& elementCorners, │ │ │ │ │ -1136 std::vector >& subElements, │ │ │ │ │ -1137 std::vector >& faceIds) │ │ │ │ │ -1138 { │ │ │ │ │ -1139 simplexSubdivision(std::integral_constant │ │ │ │ │ -(), │ │ │ │ │ -1140 elementCorners, subElements, faceIds); │ │ │ │ │ -1141 } │ │ │ │ │ -1142}; │ │ │ │ │ -1143 │ │ │ │ │ -1144template │ │ │ │ │ -1145inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ -1146 const std::vector >& elementCorners, │ │ │ │ │ -1147 std::vector >& subElements, │ │ │ │ │ -1148 std::vector >& faceIds) │ │ │ │ │ -1149{ │ │ │ │ │ -1150 subElements.resize(1); │ │ │ │ │ -1151 faceIds.resize(0); │ │ │ │ │ -1152 │ │ │ │ │ -1153 subElements[0].push_back(0); │ │ │ │ │ -1154} │ │ │ │ │ -1155 │ │ │ │ │ -1156template │ │ │ │ │ -1157inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ -1158 const std::vector >& elementCorners, │ │ │ │ │ -1159 std::vector >& subElements, │ │ │ │ │ -1160 std::vector >& faceIds) │ │ │ │ │ -1161{ │ │ │ │ │ -1162 subElements.resize(1); │ │ │ │ │ -1163 faceIds.resize(1); │ │ │ │ │ -1164 │ │ │ │ │ -1165 subElements[0].push_back(0); │ │ │ │ │ -1166 subElements[0].push_back(1); │ │ │ │ │ -1167 │ │ │ │ │ -1168 faceIds[0].push_back(0); │ │ │ │ │ -1169 faceIds[0].push_back(1); │ │ │ │ │ -1170} │ │ │ │ │ -1171 │ │ │ │ │ -1172template │ │ │ │ │ -1173inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ -1174 const std::vector >& elementCorners, │ │ │ │ │ -1175 std::vector >& subElements, │ │ │ │ │ -1176 std::vector >& faceIds) │ │ │ │ │ -1177{ │ │ │ │ │ -1178 subElements.clear(); │ │ │ │ │ -1179 faceIds.clear(); │ │ │ │ │ -1180 │ │ │ │ │ -1181 if (elementCorners.size() == 3) { // triangle │ │ │ │ │ -1182 subElements.resize(1); │ │ │ │ │ -1183 faceIds.resize(1); │ │ │ │ │ -1184 │ │ │ │ │ -1185 subElements[0].push_back(0); │ │ │ │ │ -1186 subElements[0].push_back(1); │ │ │ │ │ -1187 subElements[0].push_back(2); │ │ │ │ │ -1188 │ │ │ │ │ -1189 faceIds[0].push_back(0); │ │ │ │ │ -1190 faceIds[0].push_back(1); │ │ │ │ │ -1191 faceIds[0].push_back(2); │ │ │ │ │ -1192 } else if (elementCorners.size() == 4) { // quadrilateral => 2 triangles │ │ │ │ │ -1193 subElements.resize(2); │ │ │ │ │ -1194 faceIds.resize(2); │ │ │ │ │ -1195 │ │ │ │ │ -1196 subElements[0].push_back(0); │ │ │ │ │ -1197 subElements[0].push_back(1); │ │ │ │ │ -1198 subElements[0].push_back(2); │ │ │ │ │ -1199 │ │ │ │ │ -1200 subElements[1].push_back(1); │ │ │ │ │ -1201 subElements[1].push_back(2); │ │ │ │ │ -1202 subElements[1].push_back(3); │ │ │ │ │ -1203 │ │ │ │ │ -1204 faceIds[0].push_back(2); │ │ │ │ │ -1205 faceIds[0].push_back(0); │ │ │ │ │ -1206 faceIds[0].push_back(-1); │ │ │ │ │ -1207 │ │ │ │ │ -1208 faceIds[1].push_back(-1); │ │ │ │ │ -1209 faceIds[1].push_back(1); │ │ │ │ │ -1210 faceIds[1].push_back(3); │ │ │ │ │ -1211 } │ │ │ │ │ -1212} │ │ │ │ │ -1213 │ │ │ │ │ -1214template │ │ │ │ │ -1215inline void simplexSubdivision(std::integral_constant, │ │ │ │ │ -1216 const std::vector >& elementCorners, │ │ │ │ │ -1217 std::vector >& subElements, │ │ │ │ │ -1218 std::vector >& faceIds) │ │ │ │ │ -1219{ │ │ │ │ │ -1220 subElements.clear(); │ │ │ │ │ -1221 faceIds.clear(); │ │ │ │ │ -1222 │ │ │ │ │ -1223 if (elementCorners.size() == 4) { // tetrahedron │ │ │ │ │ -1224 subElements.resize(1); │ │ │ │ │ -1225 faceIds.resize(1); │ │ │ │ │ -1226 │ │ │ │ │ -1227 subElements[0].push_back(0); │ │ │ │ │ -1228 subElements[0].push_back(1); │ │ │ │ │ -1229 subElements[0].push_back(2); │ │ │ │ │ -1230 subElements[0].push_back(3); │ │ │ │ │ -1231 │ │ │ │ │ -1232 faceIds[0].push_back(0); │ │ │ │ │ -1233 faceIds[0].push_back(1); │ │ │ │ │ -1234 faceIds[0].push_back(2); │ │ │ │ │ -1235 faceIds[0].push_back(3); │ │ │ │ │ -1236 │ │ │ │ │ -1237 } else if (elementCorners.size() == 8) { // cube => 5 tetrahedra │ │ │ │ │ -1238 subElements.resize(5); │ │ │ │ │ -1239 faceIds.resize(5); │ │ │ │ │ -1240 │ │ │ │ │ -1241 subElements[0].push_back(0); │ │ │ │ │ -1242 subElements[0].push_back(2); │ │ │ │ │ -1243 subElements[0].push_back(3); │ │ │ │ │ -1244 subElements[0].push_back(6); │ │ │ │ │ -1245 │ │ │ │ │ -1246 subElements[1].push_back(0); │ │ │ │ │ -1247 subElements[1].push_back(1); │ │ │ │ │ -1248 subElements[1].push_back(3); │ │ │ │ │ -1249 subElements[1].push_back(5); │ │ │ │ │ -1250 │ │ │ │ │ -1251 subElements[2].push_back(0); │ │ │ │ │ -1252 subElements[2].push_back(3); │ │ │ │ │ -1253 subElements[2].push_back(5); │ │ │ │ │ -1254 subElements[2].push_back(6); │ │ │ │ │ -1255 │ │ │ │ │ -1256 subElements[3].push_back(0); │ │ │ │ │ -1257 subElements[3].push_back(4); │ │ │ │ │ -1258 subElements[3].push_back(5); │ │ │ │ │ -1259 subElements[3].push_back(6); │ │ │ │ │ -1260 │ │ │ │ │ -1261 subElements[4].push_back(3); │ │ │ │ │ -1262 subElements[4].push_back(5); │ │ │ │ │ -1263 subElements[4].push_back(6); │ │ │ │ │ -1264 subElements[4].push_back(7); │ │ │ │ │ -1265 │ │ │ │ │ -1266 faceIds[0].push_back(4); │ │ │ │ │ -1267 faceIds[0].push_back(0); │ │ │ │ │ -1268 faceIds[0].push_back(-1); │ │ │ │ │ -1269 faceIds[0].push_back(3); │ │ │ │ │ -1270 │ │ │ │ │ -1271 faceIds[1].push_back(4); │ │ │ │ │ -1272 faceIds[1].push_back(2); │ │ │ │ │ -1273 faceIds[1].push_back(-1); │ │ │ │ │ -1274 faceIds[1].push_back(1); │ │ │ │ │ -1275 │ │ │ │ │ -1276 faceIds[2].push_back(-1); │ │ │ │ │ -1277 faceIds[2].push_back(-1); │ │ │ │ │ -1278 faceIds[2].push_back(-1); │ │ │ │ │ -1279 faceIds[2].push_back(-1); │ │ │ │ │ -1280 │ │ │ │ │ -1281 faceIds[3].push_back(2); │ │ │ │ │ -1282 faceIds[3].push_back(0); │ │ │ │ │ -1283 faceIds[3].push_back(-1); │ │ │ │ │ -1284 faceIds[3].push_back(5); │ │ │ │ │ -1285 │ │ │ │ │ -1286 faceIds[4].push_back(-1); │ │ │ │ │ -1287 faceIds[4].push_back(1); │ │ │ │ │ -1288 faceIds[4].push_back(3); │ │ │ │ │ -1289 faceIds[4].push_back(5); │ │ │ │ │ -1290 } │ │ │ │ │ -1291} │ │ │ │ │ -1292 │ │ │ │ │ -1293} /* namespace Dune::GridGlue */ │ │ │ │ │ -1294} /* namespace Dune */ │ │ │ │ │ +189} /* namespace Dune::GridGlue */ │ │ │ │ │ +190} /* namespace Dune */ │ │ │ │ │ +191 │ │ │ │ │ +192#include "simplexintersection.cc" │ │ │ │ │ +193#include "computeintersection.cc" │ │ │ │ │ +194 │ │ │ │ │ +195#endif │ │ │ │ │ +simplexintersection.cc │ │ │ │ │ +computeintersection.cc │ │ │ │ │ Dune │ │ │ │ │ Definition gridglue.hh:37 │ │ │ │ │ Dune::GridGlue::insertPoint │ │ │ │ │ int insertPoint(const V p, std::vector< V > &P) │ │ │ │ │ Definition computeintersection.hh:164 │ │ │ │ │ -Dune::GridGlue::simplexSubdivision │ │ │ │ │ -void 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) │ │ │ │ │ -Definition simplexintersection.cc:1145 │ │ │ │ │ Dune::GridGlue::ComputationMethod │ │ │ │ │ Definition computeintersection.hh:13 │ │ │ │ │ -Dune::GridGlue::SimplexMethod │ │ │ │ │ -Definition simplexintersection.cc:30 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::grid1Dimension │ │ │ │ │ -static const int grid1Dimension │ │ │ │ │ -Definition simplexintersection.cc:35 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::grid2Dimension │ │ │ │ │ -static const int grid2Dimension │ │ │ │ │ -Definition simplexintersection.cc:36 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:34 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::intersectionDimension │ │ │ │ │ -static const int intersectionDimension │ │ │ │ │ -Definition simplexintersection.cc:37 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:39 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:48 │ │ │ │ │ -Dune::GridGlue::SimplexMethod::grid2_subdivisions │ │ │ │ │ -static void grid2_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:56 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:104 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:78 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_0,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:73 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:181 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:129 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_1,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:134 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:206 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:211 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_2,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:262 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:291 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:286 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_0,_3,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +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) │ │ │ │ │ -Definition simplexintersection.cc:332 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:360 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:542 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_1,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:355 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:570 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:684 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_2,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:565 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:779 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:712 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_1,_3,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:707 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:802 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:875 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_2,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:807 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:903 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:983 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_2,_3,_T_>::Vector │ │ │ │ │ -FieldVector< T, dimWorld > Vector │ │ │ │ │ -Definition simplexintersection.cc:898 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::grid1_subdivisions │ │ │ │ │ -static void grid1_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ -std::vector< std::vector< unsigned int > > &subElements, std::vector< std:: │ │ │ │ │ -vector< int > > &faceIds) │ │ │ │ │ -Definition simplexintersection.cc:1127 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::computeIntersectionPoints │ │ │ │ │ -static bool computeIntersectionPoints(const std::vector< FieldVector< T, │ │ │ │ │ -dimWorld > > &X, const std::vector< FieldVector< T, dimWorld > > &Y, std:: │ │ │ │ │ -vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std:: │ │ │ │ │ -vector< FieldVector< T, dimWorld > > &P) │ │ │ │ │ -Definition simplexintersection.cc:1010 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::Vector │ │ │ │ │ +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 simplexintersection.cc:1005 │ │ │ │ │ -Dune::GridGlue::SimplexMethod<_dimWorld,_3,_3,_T_>::grid2_subdivisions │ │ │ │ │ -static void grid2_subdivisions(const std::vector< Vector > &elementCorners, │ │ │ │ │ +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) │ │ │ │ │ -Definition simplexintersection.cc:1135 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.hh File Reference │ │ │ │ +dune-grid-glue: computeintersection.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,56 +70,28 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces
│ │ │ │ -
contactmerge.hh File Reference
│ │ │ │ +
computeintersection.cc 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 <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"
│ │ │ │ -
│ │ │ │

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...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

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

Detailed Description

│ │ │ │ -

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

│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,41 +1,17 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * 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 │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "contactmerge.cc" │ │ │ │ │ +Namespaces │ │ │ │ │ +computeintersection.cc File Reference │ │ │ │ │ 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... │ │ │ │ │ -  │ │ │ │ │ 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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00089_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: contactmerge.hh Source File │ │ │ │ +dune-grid-glue: computeintersection.cc Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,235 +74,356 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
contactmerge.hh
│ │ │ │ +
computeintersection.cc
│ │ │ │
│ │ │ │
│ │ │ │ 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
│ │ │ │ +
6namespace Dune {
│ │ │ │ +
7namespace GridGlue {
│ │ │ │ +
8
│ │ │ │ +
9//****************************************************************************************
│ │ │ │ +
10// PUBLIC
│ │ │ │ +
11//****************************************************************************************
│ │ │ │
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>
│ │ │ │ +
13template<class CM>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
15 const std::vector<V>& Y,
│ │ │ │ +
16 std::vector<std::vector<int> >& SX,
│ │ │ │ +
17 std::vector<std::vector<int> >& SY,
│ │ │ │ +
18 std::vector<V>& P) {
│ │ │ │ +
19
│ │ │ │ +
20 std::vector<std::vector<unsigned int> > subElementsX, subElementsY;
│ │ │ │ +
21 std::vector<std::vector<int> > faceIdsX, faceIdsY;
│ │ │ │ +
22 std::vector<V> subElementX(CM::grid1Dimension+1), subElementY(CM::grid2Dimension+1), sP;
│ │ │ │ +
23 std::vector<std::vector<int> > sSX, sSY;
│ │ │ │ +
24
│ │ │ │ +
25 CM::grid1_subdivisions(X,subElementsX,faceIdsX);
│ │ │ │ +
26 CM::grid2_subdivisions(Y,subElementsY,faceIdsY);
│ │ │ │
27
│ │ │ │ -
28#include <dune/grid/common/grid.hh>
│ │ │ │ +
28 bool intersectionFound = false;
│ │ │ │
29
│ │ │ │ - │ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
33namespace Dune {
│ │ │ │ -
34namespace GridGlue {
│ │ │ │ -
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;
│ │ │ │ -
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 }
│ │ │ │ -
│ │ │ │ -
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);
│ │ │ │ +
30 for (unsigned int i = 0; i < subElementsX.size(); ++i) { // iterate over all X subelements
│ │ │ │ +
31 for (unsigned int ki = 0; ki < subElementsX[i].size(); ++ki) // define the X subelement
│ │ │ │ +
32 subElementX[ki] = X[subElementsX[i][ki]];
│ │ │ │ +
33 for (unsigned int j = 0; j < subElementsY.size(); ++j) { // iterate over all Y subelemetns
│ │ │ │ +
34 for (unsigned int kj = 0; kj < subElementsY[j].size(); ++kj) // define the Y subleement
│ │ │ │ +
35 subElementY[kj] = Y[subElementsY[j][kj]];
│ │ │ │ +
36
│ │ │ │ +
37 sP.clear();
│ │ │ │ +
38
│ │ │ │ +
39 // compute the intersection
│ │ │ │ +
40 bool b = CM::computeIntersectionPoints(subElementX,subElementY,sSX,sSY,sP);
│ │ │ │ +
41 intersectionFound = intersectionFound || b;
│ │ │ │ +
42
│ │ │ │ +
43 // only insert points on outer faces
│ │ │ │ +
44 for (unsigned int ki = 0; ki < sSX.size(); ++ki) { // iterate over all faces
│ │ │ │ +
45 if (faceIdsX[i][ki] >= 0) {
│ │ │ │ +
46 for (unsigned int kii = 0; kii < sSX[ki].size(); ++kii) {
│ │ │ │ +
47 int k = insertPoint(sP[sSX[ki][kii]],P); // determine index in P
│ │ │ │ +
48 SX[faceIdsX[i][ki]].push_back(k);
│ │ │ │ +
49 }
│ │ │ │ +
50 }
│ │ │ │ +
51 }
│ │ │ │ +
52 for (unsigned int kj = 0; kj < sSY.size(); ++kj) { // iterate over all faces
│ │ │ │ +
53 if (faceIdsY[j][kj] >= 0) {
│ │ │ │ +
54 for (unsigned int kjj = 0; kjj < sSY[kj].size(); ++kjj) {
│ │ │ │ +
55 int k = insertPoint(sP[sSY[kj][kjj]],P); // determine index in P
│ │ │ │ +
56 SY[faceIdsY[j][kj]].push_back(k);
│ │ │ │ +
57 }
│ │ │ │ +
58 }
│ │ │ │ +
59 }
│ │ │ │ +
60 }
│ │ │ │ +
61 }
│ │ │ │ +
62
│ │ │ │ +
63 return intersectionFound;
│ │ │ │ +
64}
│ │ │ │ +
│ │ │ │ +
65
│ │ │ │ +
66//****************************************************************************************
│ │ │ │ +
67// PRIVATE
│ │ │ │ +
68//****************************************************************************************
│ │ │ │ +
69
│ │ │ │ +
70template<class CM>
│ │ │ │ +
71void IntersectionComputation<CM>::orderPoints_(std::integral_constant<int,3>,
│ │ │ │ +
72 std::integral_constant<int,3>,
│ │ │ │ +
73 const V& centroid,
│ │ │ │ +
74 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
75 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
76 const std::vector<V>& P,
│ │ │ │ +
77 std::vector<std::vector<int> >& H)
│ │ │ │ +
78{
│ │ │ │ +
79 int n_facesX = SX.size();
│ │ │ │ +
80 int n_facesY = SY.size();
│ │ │ │ +
81 int m;
│ │ │ │ +
82
│ │ │ │ +
83 std::vector<int> no,id,temp ;
│ │ │ │ +
84 std::vector<V> p ;
│ │ │ │ +
85 std::vector<std::vector<int> > tempH;
│ │ │ │ +
86
│ │ │ │ +
87 std::vector<int> faceOrderingX(n_facesX);
│ │ │ │ +
88 std::vector<int> faceOrderingY(n_facesY);
│ │ │ │ +
89
│ │ │ │ +
90 if (n_facesX==3) {
│ │ │ │ +
91 faceOrderingX[0] = 0; faceOrderingX[1] = 2; faceOrderingX[2] = 1;
│ │ │ │ +
92 } else {
│ │ │ │ +
93 faceOrderingX[0] = 0; faceOrderingX[1] = 3; faceOrderingX[2] = 2; faceOrderingX[3] = 1;
│ │ │ │ +
94 }
│ │ │ │ +
95 if (n_facesY==3) {
│ │ │ │ +
96 faceOrderingY[0] = 0; faceOrderingY[1] = 2; faceOrderingY[2] = 1;
│ │ │ │ +
97 } else {
│ │ │ │ +
98 faceOrderingY[0] = 0; faceOrderingY[1] = 3; faceOrderingY[2] = 2; faceOrderingY[3] = 1;
│ │ │ │ +
99 }
│ │ │ │ +
100
│ │ │ │ +
101 if (P.size() > 3) {
│ │ │ │ +
102 for (int i = 0; i < n_facesX; ++i) { // loop on faces of X
│ │ │ │ +
103 if (SX[i].size() > 0) {
│ │ │ │ +
104 no = SX[faceOrderingX[i]];
│ │ │ │ +
105 removeDuplicates(no);
│ │ │ │ +
106 m = no.size() ;
│ │ │ │ +
107 if ((m>=3) && newFace3D(no,tempH)) // don't compute degenerate polygons and check if face is new
│ │ │ │ +
108 {
│ │ │ │ +
109 for ( int l=0; l<m; ++l)
│ │ │ │ +
110 p.push_back(P[no[l]]);
│ │ │ │ +
111 orderPointsCC(std::integral_constant<int,3>(), centroid,id,p); // order points counter-clock-wise
│ │ │ │ +
112 for ( int l=0; l<m; ++l)
│ │ │ │ +
113 temp.push_back(no[id[l]]) ;
│ │ │ │ +
114 tempH.push_back(temp) ;
│ │ │ │ +
115 temp.clear();
│ │ │ │ +
116 p.clear();
│ │ │ │ +
117 id.clear(); // clean
│ │ │ │ +
118 }
│ │ │ │ +
119 no.clear() ; // clean
│ │ │ │ +
120 }
│ │ │ │ +
121 }
│ │ │ │ +
122 for (int i = 0; i < n_facesY; ++i) { // loop on faces of Y
│ │ │ │ +
123 if (SY[i].size() > 0) {
│ │ │ │ +
124 no = SY[faceOrderingY[i]];
│ │ │ │ +
125 removeDuplicates(no);
│ │ │ │ +
126 m = no.size() ;
│ │ │ │ +
127 if ((m>=3) && newFace3D(no,tempH)) // don't compute degenerate polygons and check if face is new
│ │ │ │ +
128 {
│ │ │ │ +
129 for ( int l=0; l<m; ++l)
│ │ │ │ +
130 p.push_back(P[no[l]]) ;
│ │ │ │ +
131 orderPointsCC(std::integral_constant<int,3>(),centroid,id,p); // order points counter-clock-wise
│ │ │ │ +
132 for ( int l=0; l<m; ++l)
│ │ │ │ +
133 temp.push_back(no[id[l]]) ;
│ │ │ │ +
134 tempH.push_back(temp) ;
│ │ │ │ +
135 temp.clear();
│ │ │ │ +
136 p.clear();
│ │ │ │ +
137 id.clear(); // clean
│ │ │ │ +
138 }
│ │ │ │ +
139 no.clear() ; // clean
│ │ │ │ +
140 }
│ │ │ │ +
141 }
│ │ │ │ +
142 }
│ │ │ │ +
143
│ │ │ │ +
144 for (int i = 0; i < tempH.size(); ++i) {
│ │ │ │ +
145 int hs = tempH[i].size();
│ │ │ │ +
146 if (hs >= 3) {
│ │ │ │ +
147 for (int j = 1; j <= hs-2;++j) {
│ │ │ │ +
148 temp.clear();
│ │ │ │ +
149 temp.push_back(tempH[i][0]);
│ │ │ │ +
150 for (int k = 0; k < 2; ++k)
│ │ │ │ +
151 temp.push_back(tempH[i][j+k]);
│ │ │ │ +
152 H.push_back(temp);
│ │ │ │ +
153 }
│ │ │ │ +
154 }
│ │ │ │ +
155 }
│ │ │ │ +
156}
│ │ │ │ +
157
│ │ │ │ +
158template<class CM>
│ │ │ │ +
159void IntersectionComputation<CM>::orderPoints_(std::integral_constant<int,2>,
│ │ │ │ +
160 std::integral_constant<int,2>,
│ │ │ │ +
161 const V& centroid,
│ │ │ │ +
162 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
163 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
164 const std::vector<V>& P,
│ │ │ │ +
165 std::vector<std::vector<int> >& H)
│ │ │ │ +
166{
│ │ │ │ +
167 H.clear();
│ │ │ │ +
168 std::vector<int> id, temp(2);
│ │ │ │
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);
│ │ │ │ +
170 orderPointsCC(std::integral_constant<int,2>(),centroid,id,P);
│ │ │ │ +
171
│ │ │ │ +
172 for (std::size_t i = 0; i < id.size();++i) {
│ │ │ │ +
173 temp[0] = id[i];
│ │ │ │ +
174 temp[1] = id[(i+1)%(id.size())];
│ │ │ │ +
175 H.push_back(temp);
│ │ │ │ +
176 }
│ │ │ │ +
177}
│ │ │ │ +
178
│ │ │ │ +
179template<class CM>
│ │ │ │ +
180void IntersectionComputation<CM>::orderPoints_(std::integral_constant<int,2>,
│ │ │ │ +
181 std::integral_constant<int,3>,
│ │ │ │ +
182 const V& centroid,
│ │ │ │ +
183 const std::vector<std::vector<int> >& SX,
│ │ │ │ +
184 const std::vector<std::vector<int> >& SY,
│ │ │ │ +
185 const std::vector<V>& P,
│ │ │ │ +
186 std::vector<std::vector<int> >& H)
│ │ │ │ +
187{
│ │ │ │ +
188 H.clear();
│ │ │ │ +
189 std::vector<int> id, temp(2);
│ │ │ │ +
190
│ │ │ │ +
191 orderPointsCC(std::integral_constant<int,3>(),centroid,id,P);
│ │ │ │ +
192
│ │ │ │ +
193 for (int i = 0; i < id.size();++i) {
│ │ │ │ +
194 temp[0] = id[i];
│ │ │ │ +
195 temp[1] = id[(i+1)%(id.size())];
│ │ │ │ +
196 H.push_back(temp);
│ │ │ │ +
197 }
│ │ │ │ +
198}
│ │ │ │
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"
│ │ │ │ +
200template<class CM>
│ │ │ │ +
201void IntersectionComputation<CM>::removeDuplicates(std::vector<int> & p)
│ │ │ │ +
202{
│ │ │ │ +
203 sort(p.begin(),p.end());
│ │ │ │ +
204 std::vector<int>::iterator it = std::unique(p.begin(),p.end());
│ │ │ │ +
205 p.erase(it,p.end());
│ │ │ │ +
206}
│ │ │ │ +
207
│ │ │ │ +
208template<class CM>
│ │ │ │ +
209bool IntersectionComputation<CM>::newFace3D(const std::vector<int>& id,
│ │ │ │ +
210 const std::vector<std::vector<int> >& H)
│ │ │ │ +
211{
│ │ │ │ +
212 // get size_type for all the vectors we are using
│ │ │ │ +
213 typedef typename std::vector<Empty>::size_type size_type;
│ │ │ │ +
214
│ │ │ │ +
215 int n = H.size() ;
│ │ │ │ +
216 int m = id.size() ;
│ │ │ │ +
217 std::vector<int> A ;
│ │ │ │ +
218 std::vector<int> B = id ;
│ │ │ │ +
219 sort(B.begin(),B.end()) ;
│ │ │ │ +
220 int i = 0 ;
│ │ │ │ +
221 bool b = true ;
│ │ │ │ +
222 double tp ;
│ │ │ │ +
223
│ │ │ │ +
224 while ( b && (i<n) )
│ │ │ │ +
225 {
│ │ │ │ +
226 if ((H[i].size())>=m)
│ │ │ │ +
227 {
│ │ │ │ +
228 A=H[i] ;
│ │ │ │ +
229 sort(A.begin(),A.end());
│ │ │ │ +
230 tp = 0 ;
│ │ │ │ +
231 for ( size_type j=0 ; j < m; j++)
│ │ │ │ +
232 tp += std::fabs(A[j]-B[j]) ;
│ │ │ │ +
233 b = (tp>0) ;
│ │ │ │ +
234 }
│ │ │ │ +
235
│ │ │ │ +
236 i += 1 ;
│ │ │ │ +
237 }
│ │ │ │ +
238
│ │ │ │ +
239 return b ;
│ │ │ │ +
240}
│ │ │ │ +
241
│ │ │ │
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.
│ │ │ │ - │ │ │ │ +
243template<class CM>
│ │ │ │ +
244void IntersectionComputation<CM>::orderPointsCC(std::integral_constant<int,3>,
│ │ │ │ +
245 const V& centroid,
│ │ │ │ +
246 std::vector<int>& id,
│ │ │ │ +
247 const std::vector<V>& P)
│ │ │ │ +
248{
│ │ │ │ +
249 typedef typename std::vector<Empty>::size_type size_type;
│ │ │ │ +
250
│ │ │ │ +
251 id.clear();
│ │ │ │ +
252
│ │ │ │ +
253 // get size_type for all the vectors we are using
│ │ │ │ +
254 V c,d1,d2,dr,dn,cross,d ;
│ │ │ │ +
255 std::vector<typename V::value_type> ai ;
│ │ │ │ +
256
│ │ │ │ +
257 d1 = P[1] - P[0] ; // two reference vectors
│ │ │ │ +
258 d2 = P[2] - P[0] ;
│ │ │ │ +
259
│ │ │ │ +
260 cross[0] = d1[1]*d2[2] - d1[2]*d2[1] ; // cross product
│ │ │ │ +
261 cross[1] = d1[2]*d2[0] - d1[0]*d2[2] ;
│ │ │ │ +
262 cross[2] = d1[0]*d2[1] - d1[1]*d2[0] ;
│ │ │ │ +
263
│ │ │ │ +
264 if (((centroid - P[0])*cross)<0) // good orientation ?
│ │ │ │ +
265 {
│ │ │ │ +
266 dr = d1 ;
│ │ │ │ +
267 dr /= dr.two_norm() ; // 'x-axis' unit vector
│ │ │ │ +
268 dn = dr ;
│ │ │ │ +
269 dn *= -(d2*dr) ;
│ │ │ │ +
270 dn += d2 ;
│ │ │ │ +
271 dn /= dn.two_norm() ; // 'y-axis' unit vector
│ │ │ │ +
272 }
│ │ │ │ +
273 else
│ │ │ │ +
274 {
│ │ │ │ +
275 dr = d2 ;
│ │ │ │ +
276 dr /= dr.two_norm() ; // 'y-axis' unit vector
│ │ │ │ +
277 dn = dr ;
│ │ │ │ +
278 dn *= -(d1*dr) ;
│ │ │ │ +
279 dn += d1 ;
│ │ │ │ +
280 dn /= dn.two_norm() ; // 'x-axis' unit vector
│ │ │ │ +
281 }
│ │ │ │ +
282
│ │ │ │ +
283 // definition of angles, using projection on the local reference, ie by scalarly multipliying by dr and dn resp.
│ │ │ │ +
284 for ( size_type j=1 ; j < P.size() ; j++)
│ │ │ │ +
285 {
│ │ │ │ +
286 ai.push_back(atan2((P[j]-P[0])*dn,(P[j]-P[0])*dr)) ;
│ │ │ │ +
287 id.push_back(j) ;
│ │ │ │ +
288 }
│ │ │ │ +
289
│ │ │ │ +
290 // sort according to increasing angles
│ │ │ │ +
291 for ( size_type j=1; j < ai.size(); j++) {
│ │ │ │ +
292 for ( size_type i=0; i < j; i++) {
│ │ │ │ +
293 if (ai[j]<ai[i]) {
│ │ │ │ +
294 std::swap<typename V::value_type>(ai[i],ai[j]) ;
│ │ │ │ +
295 std::swap<int>(id[i],id[j]) ;
│ │ │ │ +
296 }
│ │ │ │ +
297 }
│ │ │ │ +
298 }
│ │ │ │ +
299
│ │ │ │ +
300 id.insert(id.begin(),0);
│ │ │ │ +
301}
│ │ │ │ +
302
│ │ │ │ +
303template<class CM>
│ │ │ │ +
304void IntersectionComputation<CM>::orderPointsCC(std::integral_constant<int,2>,
│ │ │ │ +
305 const V& centroid,
│ │ │ │ +
306 std::vector<int>& id,
│ │ │ │ +
307 const std::vector<V>& P)
│ │ │ │ +
308{
│ │ │ │ +
309 typedef typename std::vector<Empty>::size_type size_type;
│ │ │ │ +
310
│ │ │ │ +
311 // get size_type for all the vectors we are using
│ │ │ │ +
312 typedef typename std::vector<Empty>::size_type size_type;
│ │ │ │ +
313
│ │ │ │ +
314 std::vector<typename V::value_type> ai(P.size());
│ │ │ │ +
315 id.resize(P.size());
│ │ │ │ +
316
│ │ │ │ +
317 // definition of angles
│ │ │ │ +
318 for ( size_type i=0; i < P.size(); i++) {
│ │ │ │ +
319 ai[i] = atan2(P[i][1]-centroid[1],P[i][0]-centroid[0]);
│ │ │ │ +
320 id[i] = i;
│ │ │ │ +
321 }
│ │ │ │ +
322
│ │ │ │ +
323 // sort according to increasing angles
│ │ │ │ +
324 for ( size_type j=1; j < ai.size(); j++) {
│ │ │ │ +
325 for ( size_type i=0; i < j; i++) if (ai[j]<ai[i]) {
│ │ │ │ +
326 std::swap<typename V::value_type>(ai[i],ai[j]);
│ │ │ │ +
327 std::swap<int>(id[i],id[j]);
│ │ │ │ +
328 }
│ │ │ │ +
329 }
│ │ │ │ +
330}
│ │ │ │ +
331
│ │ │ │ +
332} /* namespace Dune::GridGlue */
│ │ │ │ +
333} /* namespace Dune */
│ │ │ │
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
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
Definition standardmerge.hh:392
│ │ │ │ -
bool valid
Definition standardmerge.hh:86
│ │ │ │ +
int insertPoint(const V p, std::vector< V > &P)
Definition computeintersection.hh:164
│ │ │ │ +
Intersection computation method for two elements of arbitrary dimension.
Definition computeintersection.hh:39
│ │ │ │ +
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 {} │ │ │ │ │ @@ -1,304 +1,382 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -contactmerge.hh │ │ │ │ │ +computeintersection.cc │ │ │ │ │ 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 │ │ │ │ │ +6namespace Dune { │ │ │ │ │ +7namespace GridGlue { │ │ │ │ │ +8 │ │ │ │ │ +9// │ │ │ │ │ +**************************************************************************************** │ │ │ │ │ +10// PUBLIC │ │ │ │ │ +11// │ │ │ │ │ +**************************************************************************************** │ │ │ │ │ 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 │ │ │ │ │ +13template │ │ │ │ │ +14bool IntersectionComputation::computeIntersection(const std::vector& │ │ │ │ │ +X, │ │ │ │ │ +15 const std::vector& Y, │ │ │ │ │ +16 std::vector >& SX, │ │ │ │ │ +17 std::vector >& SY, │ │ │ │ │ +18 std::vector& P) { │ │ │ │ │ +19 │ │ │ │ │ +20 std::vector > subElementsX, subElementsY; │ │ │ │ │ +21 std::vector > faceIdsX, faceIdsY; │ │ │ │ │ +22 std::vector subElementX(CM::grid1Dimension+1), subElementY(CM:: │ │ │ │ │ +grid2Dimension+1), sP; │ │ │ │ │ +23 std::vector > sSX, sSY; │ │ │ │ │ +24 │ │ │ │ │ +25 CM::grid1_subdivisions(X,subElementsX,faceIdsX); │ │ │ │ │ +26 CM::grid2_subdivisions(Y,subElementsY,faceIdsY); │ │ │ │ │ 27 │ │ │ │ │ -28#include │ │ │ │ │ +28 bool intersectionFound = false; │ │ │ │ │ 29 │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32 │ │ │ │ │ -33namespace Dune { │ │ │ │ │ -34namespace GridGlue { │ │ │ │ │ -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; │ │ │ │ │ -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_; │ │ │ │ │ +30 for (unsigned int i = 0; i < subElementsX.size(); ++i) { // iterate over all │ │ │ │ │ +X subelements │ │ │ │ │ +31 for (unsigned int ki = 0; ki < subElementsX[i].size(); ++ki) // define the X │ │ │ │ │ +subelement │ │ │ │ │ +32 subElementX[ki] = X[subElementsX[i][ki]]; │ │ │ │ │ +33 for (unsigned int j = 0; j < subElementsY.size(); ++j) { // iterate over all │ │ │ │ │ +Y subelemetns │ │ │ │ │ +34 for (unsigned int kj = 0; kj < subElementsY[j].size(); ++kj) // define the Y │ │ │ │ │ +subleement │ │ │ │ │ +35 subElementY[kj] = Y[subElementsY[j][kj]]; │ │ │ │ │ +36 │ │ │ │ │ +37 sP.clear(); │ │ │ │ │ +38 │ │ │ │ │ +39 // compute the intersection │ │ │ │ │ +40 bool b = CM::computeIntersectionPoints(subElementX,subElementY,sSX,sSY,sP); │ │ │ │ │ +41 intersectionFound = intersectionFound || b; │ │ │ │ │ +42 │ │ │ │ │ +43 // only insert points on outer faces │ │ │ │ │ +44 for (unsigned int ki = 0; ki < sSX.size(); ++ki) { // iterate over all faces │ │ │ │ │ +45 if (faceIdsX[i][ki] >= 0) { │ │ │ │ │ +46 for (unsigned int kii = 0; kii < sSX[ki].size(); ++kii) { │ │ │ │ │ +47 int k = insertPoint(sP[sSX[ki][kii]],P); // determine index in P │ │ │ │ │ +48 SX[faceIdsX[i][ki]].push_back(k); │ │ │ │ │ +49 } │ │ │ │ │ +50 } │ │ │ │ │ +51 } │ │ │ │ │ +52 for (unsigned int kj = 0; kj < sSY.size(); ++kj) { // iterate over all faces │ │ │ │ │ +53 if (faceIdsY[j][kj] >= 0) { │ │ │ │ │ +54 for (unsigned int kjj = 0; kjj < sSY[kj].size(); ++kjj) { │ │ │ │ │ +55 int k = insertPoint(sP[sSY[kj][kjj]],P); // determine index in P │ │ │ │ │ +56 SY[faceIdsY[j][kj]].push_back(k); │ │ │ │ │ +57 } │ │ │ │ │ +58 } │ │ │ │ │ +59 } │ │ │ │ │ +60 } │ │ │ │ │ +61 } │ │ │ │ │ +62 │ │ │ │ │ +63 return intersectionFound; │ │ │ │ │ +64} │ │ │ │ │ +65 │ │ │ │ │ +66// │ │ │ │ │ +**************************************************************************************** │ │ │ │ │ +67// PRIVATE │ │ │ │ │ +68// │ │ │ │ │ +**************************************************************************************** │ │ │ │ │ +69 │ │ │ │ │ +70template │ │ │ │ │ +71void IntersectionComputation::orderPoints_(std::integral_constant, │ │ │ │ │ +72 std::integral_constant, │ │ │ │ │ +73 const V& centroid, │ │ │ │ │ +74 const std::vector >& SX, │ │ │ │ │ +75 const std::vector >& SY, │ │ │ │ │ +76 const std::vector& P, │ │ │ │ │ +77 std::vector >& H) │ │ │ │ │ +78{ │ │ │ │ │ +79 int n_facesX = SX.size(); │ │ │ │ │ +80 int n_facesY = SY.size(); │ │ │ │ │ +81 int m; │ │ │ │ │ +82 │ │ │ │ │ +83 std::vector no,id,temp ; │ │ │ │ │ +84 std::vector p ; │ │ │ │ │ +85 std::vector > tempH; │ │ │ │ │ +86 │ │ │ │ │ +87 std::vector faceOrderingX(n_facesX); │ │ │ │ │ +88 std::vector faceOrderingY(n_facesY); │ │ │ │ │ +89 │ │ │ │ │ +90 if (n_facesX==3) { │ │ │ │ │ +91 faceOrderingX[0] = 0; faceOrderingX[1] = 2; faceOrderingX[2] = 1; │ │ │ │ │ +92 } else { │ │ │ │ │ +93 faceOrderingX[0] = 0; faceOrderingX[1] = 3; faceOrderingX[2] = 2; │ │ │ │ │ +faceOrderingX[3] = 1; │ │ │ │ │ +94 } │ │ │ │ │ +95 if (n_facesY==3) { │ │ │ │ │ +96 faceOrderingY[0] = 0; faceOrderingY[1] = 2; faceOrderingY[2] = 1; │ │ │ │ │ +97 } else { │ │ │ │ │ +98 faceOrderingY[0] = 0; faceOrderingY[1] = 3; faceOrderingY[2] = 2; │ │ │ │ │ +faceOrderingY[3] = 1; │ │ │ │ │ +99 } │ │ │ │ │ +100 │ │ │ │ │ +101 if (P.size() > 3) { │ │ │ │ │ +102 for (int i = 0; i < n_facesX; ++i) { // loop on faces of X │ │ │ │ │ +103 if (SX[i].size() > 0) { │ │ │ │ │ +104 no = SX[faceOrderingX[i]]; │ │ │ │ │ +105 removeDuplicates(no); │ │ │ │ │ +106 m = no.size() ; │ │ │ │ │ +107 if ((m>=3) && newFace3D(no,tempH)) // don't compute degenerate polygons and │ │ │ │ │ +check if face is new │ │ │ │ │ +108 { │ │ │ │ │ +109 for ( int l=0; l(), centroid,id,p); // order │ │ │ │ │ +points counter-clock-wise │ │ │ │ │ +112 for ( int l=0; l:: │ │ │ │ │ -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); │ │ │ │ │ +119 no.clear() ; // clean │ │ │ │ │ +120 } │ │ │ │ │ +121 } │ │ │ │ │ +122 for (int i = 0; i < n_facesY; ++i) { // loop on faces of Y │ │ │ │ │ +123 if (SY[i].size() > 0) { │ │ │ │ │ +124 no = SY[faceOrderingY[i]]; │ │ │ │ │ +125 removeDuplicates(no); │ │ │ │ │ +126 m = no.size() ; │ │ │ │ │ +127 if ((m>=3) && newFace3D(no,tempH)) // don't compute degenerate polygons and │ │ │ │ │ +check if face is new │ │ │ │ │ +128 { │ │ │ │ │ +129 for ( int l=0; l(),centroid,id,p); // order │ │ │ │ │ +points counter-clock-wise │ │ │ │ │ +132 for ( int l=0; l= 3) { │ │ │ │ │ +147 for (int j = 1; j <= hs-2;++j) { │ │ │ │ │ +148 temp.clear(); │ │ │ │ │ +149 temp.push_back(tempH[i][0]); │ │ │ │ │ +150 for (int k = 0; k < 2; ++k) │ │ │ │ │ +151 temp.push_back(tempH[i][j+k]); │ │ │ │ │ +152 H.push_back(temp); │ │ │ │ │ +153 } │ │ │ │ │ +154 } │ │ │ │ │ +155 } │ │ │ │ │ +156} │ │ │ │ │ +157 │ │ │ │ │ +158template │ │ │ │ │ +159void IntersectionComputation::orderPoints_(std::integral_ │ │ │ │ │ +constant, │ │ │ │ │ +160 std::integral_constant, │ │ │ │ │ +161 const V& centroid, │ │ │ │ │ +162 const std::vector >& SX, │ │ │ │ │ +163 const std::vector >& SY, │ │ │ │ │ +164 const std::vector& P, │ │ │ │ │ +165 std::vector >& H) │ │ │ │ │ +166{ │ │ │ │ │ +167 H.clear(); │ │ │ │ │ +168 std::vector id, temp(2); │ │ │ │ │ 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); │ │ │ │ │ +170 orderPointsCC(std::integral_constant(),centroid,id,P); │ │ │ │ │ +171 │ │ │ │ │ +172 for (std::size_t i = 0; i < id.size();++i) { │ │ │ │ │ +173 temp[0] = id[i]; │ │ │ │ │ +174 temp[1] = id[(i+1)%(id.size())]; │ │ │ │ │ +175 H.push_back(temp); │ │ │ │ │ +176 } │ │ │ │ │ +177} │ │ │ │ │ +178 │ │ │ │ │ +179template │ │ │ │ │ +180void IntersectionComputation::orderPoints_(std::integral_ │ │ │ │ │ +constant, │ │ │ │ │ +181 std::integral_constant, │ │ │ │ │ +182 const V& centroid, │ │ │ │ │ +183 const std::vector >& SX, │ │ │ │ │ +184 const std::vector >& SY, │ │ │ │ │ +185 const std::vector& P, │ │ │ │ │ +186 std::vector >& H) │ │ │ │ │ +187{ │ │ │ │ │ +188 H.clear(); │ │ │ │ │ +189 std::vector id, temp(2); │ │ │ │ │ +190 │ │ │ │ │ +191 orderPointsCC(std::integral_constant(),centroid,id,P); │ │ │ │ │ +192 │ │ │ │ │ +193 for (int i = 0; i < id.size();++i) { │ │ │ │ │ +194 temp[0] = id[i]; │ │ │ │ │ +195 temp[1] = id[(i+1)%(id.size())]; │ │ │ │ │ +196 H.push_back(temp); │ │ │ │ │ +197 } │ │ │ │ │ +198} │ │ │ │ │ 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" │ │ │ │ │ +200template │ │ │ │ │ +201void IntersectionComputation::removeDuplicates(std::vector & p) │ │ │ │ │ +202{ │ │ │ │ │ +203 sort(p.begin(),p.end()); │ │ │ │ │ +204 std::vector::iterator it = std::unique(p.begin(),p.end()); │ │ │ │ │ +205 p.erase(it,p.end()); │ │ │ │ │ +206} │ │ │ │ │ +207 │ │ │ │ │ +208template │ │ │ │ │ +209bool IntersectionComputation::newFace3D(const std::vector& id, │ │ │ │ │ +210 const std::vector >& H) │ │ │ │ │ +211{ │ │ │ │ │ +212 // get size_type for all the vectors we are using │ │ │ │ │ +213 typedef typename std::vector::size_type size_type; │ │ │ │ │ +214 │ │ │ │ │ +215 int n = H.size() ; │ │ │ │ │ +216 int m = id.size() ; │ │ │ │ │ +217 std::vector A ; │ │ │ │ │ +218 std::vector B = id ; │ │ │ │ │ +219 sort(B.begin(),B.end()) ; │ │ │ │ │ +220 int i = 0 ; │ │ │ │ │ +221 bool b = true ; │ │ │ │ │ +222 double tp ; │ │ │ │ │ +223 │ │ │ │ │ +224 while ( b && (i=m) │ │ │ │ │ +227 { │ │ │ │ │ +228 A=H[i] ; │ │ │ │ │ +229 sort(A.begin(),A.end()); │ │ │ │ │ +230 tp = 0 ; │ │ │ │ │ +231 for ( size_type j=0 ; j < m; j++) │ │ │ │ │ +232 tp += std::fabs(A[j]-B[j]) ; │ │ │ │ │ +233 b = (tp>0) ; │ │ │ │ │ +234 } │ │ │ │ │ +235 │ │ │ │ │ +236 i += 1 ; │ │ │ │ │ +237 } │ │ │ │ │ +238 │ │ │ │ │ +239 return b ; │ │ │ │ │ +240} │ │ │ │ │ +241 │ │ │ │ │ 242 │ │ │ │ │ -243#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH │ │ │ │ │ -gridglue.hh │ │ │ │ │ -Central component of the module implementing the coupling of two grids. │ │ │ │ │ -standardmerge.hh │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ -contactmerge.cc │ │ │ │ │ +243template │ │ │ │ │ +244void IntersectionComputation::orderPointsCC(std::integral_ │ │ │ │ │ +constant, │ │ │ │ │ +245 const V& centroid, │ │ │ │ │ +246 std::vector& id, │ │ │ │ │ +247 const std::vector& P) │ │ │ │ │ +248{ │ │ │ │ │ +249 typedef typename std::vector::size_type size_type; │ │ │ │ │ +250 │ │ │ │ │ +251 id.clear(); │ │ │ │ │ +252 │ │ │ │ │ +253 // get size_type for all the vectors we are using │ │ │ │ │ +254 V c,d1,d2,dr,dn,cross,d ; │ │ │ │ │ +255 std::vector ai ; │ │ │ │ │ +256 │ │ │ │ │ +257 d1 = P[1] - P[0] ; // two reference vectors │ │ │ │ │ +258 d2 = P[2] - P[0] ; │ │ │ │ │ +259 │ │ │ │ │ +260 cross[0] = d1[1]*d2[2] - d1[2]*d2[1] ; // cross product │ │ │ │ │ +261 cross[1] = d1[2]*d2[0] - d1[0]*d2[2] ; │ │ │ │ │ +262 cross[2] = d1[0]*d2[1] - d1[1]*d2[0] ; │ │ │ │ │ +263 │ │ │ │ │ +264 if (((centroid - P[0])*cross)<0) // good orientation ? │ │ │ │ │ +265 { │ │ │ │ │ +266 dr = d1 ; │ │ │ │ │ +267 dr /= dr.two_norm() ; // 'x-axis' unit vector │ │ │ │ │ +268 dn = dr ; │ │ │ │ │ +269 dn *= -(d2*dr) ; │ │ │ │ │ +270 dn += d2 ; │ │ │ │ │ +271 dn /= dn.two_norm() ; // 'y-axis' unit vector │ │ │ │ │ +272 } │ │ │ │ │ +273 else │ │ │ │ │ +274 { │ │ │ │ │ +275 dr = d2 ; │ │ │ │ │ +276 dr /= dr.two_norm() ; // 'y-axis' unit vector │ │ │ │ │ +277 dn = dr ; │ │ │ │ │ +278 dn *= -(d1*dr) ; │ │ │ │ │ +279 dn += d1 ; │ │ │ │ │ +280 dn /= dn.two_norm() ; // 'x-axis' unit vector │ │ │ │ │ +281 } │ │ │ │ │ +282 │ │ │ │ │ +283 // definition of angles, using projection on the local reference, ie by │ │ │ │ │ +scalarly multipliying by dr and dn resp. │ │ │ │ │ +284 for ( size_type j=1 ; j < P.size() ; j++) │ │ │ │ │ +285 { │ │ │ │ │ +286 ai.push_back(atan2((P[j]-P[0])*dn,(P[j]-P[0])*dr)) ; │ │ │ │ │ +287 id.push_back(j) ; │ │ │ │ │ +288 } │ │ │ │ │ +289 │ │ │ │ │ +290 // sort according to increasing angles │ │ │ │ │ +291 for ( size_type j=1; j < ai.size(); j++) { │ │ │ │ │ +292 for ( size_type i=0; i < j; i++) { │ │ │ │ │ +293 if (ai[j](ai[i],ai[j]) ; │ │ │ │ │ +295 std::swap(id[i],id[j]) ; │ │ │ │ │ +296 } │ │ │ │ │ +297 } │ │ │ │ │ +298 } │ │ │ │ │ +299 │ │ │ │ │ +300 id.insert(id.begin(),0); │ │ │ │ │ +301} │ │ │ │ │ +302 │ │ │ │ │ +303template │ │ │ │ │ +304void IntersectionComputation::orderPointsCC(std::integral_ │ │ │ │ │ +constant, │ │ │ │ │ +305 const V& centroid, │ │ │ │ │ +306 std::vector& id, │ │ │ │ │ +307 const std::vector& P) │ │ │ │ │ +308{ │ │ │ │ │ +309 typedef typename std::vector::size_type size_type; │ │ │ │ │ +310 │ │ │ │ │ +311 // get size_type for all the vectors we are using │ │ │ │ │ +312 typedef typename std::vector::size_type size_type; │ │ │ │ │ +313 │ │ │ │ │ +314 std::vector ai(P.size()); │ │ │ │ │ +315 id.resize(P.size()); │ │ │ │ │ +316 │ │ │ │ │ +317 // definition of angles │ │ │ │ │ +318 for ( size_type i=0; i < P.size(); i++) { │ │ │ │ │ +319 ai[i] = atan2(P[i][1]-centroid[1],P[i][0]-centroid[0]); │ │ │ │ │ +320 id[i] = i; │ │ │ │ │ +321 } │ │ │ │ │ +322 │ │ │ │ │ +323 // sort according to increasing angles │ │ │ │ │ +324 for ( size_type j=1; j < ai.size(); j++) { │ │ │ │ │ +325 for ( size_type i=0; i < j; i++) if (ai[j](ai[i],ai[j]); │ │ │ │ │ +327 std::swap(id[i],id[j]); │ │ │ │ │ +328 } │ │ │ │ │ +329 } │ │ │ │ │ +330} │ │ │ │ │ +331 │ │ │ │ │ +332} /* namespace Dune::GridGlue */ │ │ │ │ │ +333} /* namespace Dune */ │ │ │ │ │ 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 │ │ │ │ │ -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 │ │ │ │ │ -Definition standardmerge.hh:392 │ │ │ │ │ -Dune::GridGlue::StandardMerge::valid │ │ │ │ │ -bool valid │ │ │ │ │ -Definition standardmerge.hh:86 │ │ │ │ │ +Dune::GridGlue::insertPoint │ │ │ │ │ +int insertPoint(const V p, std::vector< V > &P) │ │ │ │ │ +Definition computeintersection.hh:164 │ │ │ │ │ +Dune::GridGlue::IntersectionComputation │ │ │ │ │ +Intersection computation method for two elements of arbitrary dimension. │ │ │ │ │ +Definition computeintersection.hh:39 │ │ │ │ │ +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.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00092.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: standardmerge.cc File Reference │ │ │ │ +dune-grid-glue: contactmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,110 +70,56 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
standardmerge.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
contactmerge.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include "config.h"
│ │ │ │ -#include "standardmerge.hh"
│ │ │ │ -
│ │ │ │ + │ │ │ │ +

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/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::ContactMerge< dimworld, T >
 Merge two codimension-1 surfaces that may be a positive distance apart. 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

│ │ │ │ +

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

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,52 +1,41 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -standardmerge.cc File Reference │ │ │ │ │ -#include "config.h" │ │ │ │ │ -#include "standardmerge.hh" │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +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 "contactmerge.cc" │ │ │ │ │ +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... │ │ │ │ │ +  │ │ │ │ │ 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 ***** │ │ │ │ │ +Merge two grid boundary surfaces that may be a positive distance apart. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: overlappingmerge.hh File Reference │ │ │ │ +dune-grid-glue: standardmerge.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,46 +71,139 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
overlappingmerge.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Functions
│ │ │ │ +
standardmerge.hh 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/fmatrix.hh>
│ │ │ │ #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/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 <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::OverlappingMerge< dim1, dim2, dimworld, T >
 Computing overlapping grid intersections for grids of different dimensions. More...
class  Dune::GridGlue::StandardMerge< T, grid1Dim, grid2Dim, dimworld >
 Common base class for many merger implementations: produce pairs of entities that may intersect. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

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

│ │ │ │ +Macros

#define DECL   extern
 
#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

│ │ │ │ + │ │ │ │ +

◆ DECL

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DECL   extern
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ 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> >& grid1Coords, \
│ │ │ │ +
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<unsigned int>& grid2_elements, \
│ │ │ │ +
const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │ +
)
│ │ │ │ +
#define DECL
Definition standardmerge.hh:827
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,34 +1,79 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -overlappingmerge.hh File Reference │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +standardmerge.hh File Reference │ │ │ │ │ +Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ +that may intersect. More... │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include "overlappingmerge.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::StandardMerge<_T,_grid1Dim,_grid2Dim,_dimworld_> │ │ │ │ │ +  Common base class for many merger implementations: produce pairs of │ │ │ │ │ + entities that may intersect. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ +Macros │ │ │ │ │ +#define  DECL   extern │ │ │ │ │ +  │ │ │ │ │ +#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 ***** │ │ │ │ │ +***** ◆ DECL ***** │ │ │ │ │ +#define DECL   extern │ │ │ │ │ +***** ◆ STANDARD_MERGE_INSTANTIATE ***** │ │ │ │ │ +#define STANDARD_MERGE_INSTANTIATE (   T, │ │ │ │ │ +   A, │ │ │ │ │ +   B, │ │ │ │ │ +   C  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +DECL template \ │ │ │ │ │ +void StandardMerge::build(const std::vector >& │ │ │ │ │ +grid1Coords, \ │ │ │ │ │ +const std::vector& grid1_elements, \ │ │ │ │ │ +const std::vector& grid1_element_types, \ │ │ │ │ │ +const std::vector >& grid2Coords, \ │ │ │ │ │ +const std::vector& grid2_elements, \ │ │ │ │ │ +const std::vector& grid2_element_types \ │ │ │ │ │ +) │ │ │ │ │ +DECL │ │ │ │ │ +#define DECL │ │ │ │ │ +Definition standardmerge.hh:827 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00095_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: overlappingmerge.hh Source File │ │ │ │ +dune-grid-glue: standardmerge.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,102 +74,857 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
overlappingmerge.hh
│ │ │ │ +
standardmerge.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>
│ │ │ │ +
10#ifndef DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
│ │ │ │ +
11#define DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
│ │ │ │
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
│ │ │ │ - │ │ │ │ - │ │ │ │ +
13
│ │ │ │ +
14#include <iostream>
│ │ │ │ +
15#include <iomanip>
│ │ │ │ +
16#include <vector>
│ │ │ │ +
17#include <stack>
│ │ │ │ +
18#include <set>
│ │ │ │ +
19#include <utility>
│ │ │ │ +
20#include <map>
│ │ │ │ +
21#include <memory>
│ │ │ │ +
22#include <algorithm>
│ │ │ │
23
│ │ │ │ -
24namespace Dune {
│ │ │ │ -
25namespace GridGlue {
│ │ │ │ -
26
│ │ │ │ -
34template<int dim1, int dim2, int dimworld, typename T = double>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
36 : public StandardMerge<T,dim1,dim2,dimworld>
│ │ │ │ -
37{
│ │ │ │ +
24#include <dune/common/fvector.hh>
│ │ │ │ +
25#include <dune/common/bitsetvector.hh>
│ │ │ │ +
26#include <dune/common/stdstreams.hh>
│ │ │ │ +
27#include <dune/common/timer.hh>
│ │ │ │ +
28
│ │ │ │ +
29#include <dune/geometry/referenceelements.hh>
│ │ │ │ +
30#include <dune/grid/common/grid.hh>
│ │ │ │ +
31
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
35
│ │ │ │ +
36namespace Dune {
│ │ │ │ +
37namespace GridGlue {
│ │ │ │
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);
│ │ │ │ +
55template<class T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
57 : public Merger<T,grid1Dim,grid2Dim,dimworld>
│ │ │ │ +
58{
│ │ │ │ + │ │ │ │ +
60
│ │ │ │ +
61public:
│ │ │ │ +
62
│ │ │ │ +
63 /* 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 */
│ │ │ │ +
64
│ │ │ │ +
66 typedef T ctype;
│ │ │ │ +
67
│ │ │ │ + │ │ │ │ +
70
│ │ │ │ + │ │ │ │ +
73
│ │ │ │ + │ │ │ │ +
76
│ │ │ │ + │ │ │ │
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.
│ │ │ │ - │ │ │ │ +
79protected:
│ │ │ │ +
80
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
85
│ │ │ │ +
86 bool valid = false;
│ │ │ │ +
87
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
91 {}
│ │ │ │ +
│ │ │ │ +
92
│ │ │ │ +
93 virtual ~StandardMerge() = default;
│ │ │ │ +
94
│ │ │ │ +
99 virtual void computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
100 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
101 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ +
102 unsigned int grid1Index,
│ │ │ │ +
103 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
104 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
105 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ +
106 unsigned int grid2Index,
│ │ │ │ +
107 std::vector<SimplicialIntersection>& intersections) = 0;
│ │ │ │ +
108
│ │ │ │ +
│ │ │ │ +
112 bool computeIntersection(unsigned int candidate0, unsigned int candidate1,
│ │ │ │ +
113 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
114 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
115 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ +
116 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
117 const std::vector<Dune::GeometryType>& grid2_element_types,
│ │ │ │ +
118 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ +
119 bool insert = true);
│ │ │ │ +
120
│ │ │ │ +
121 /* M E M B E R V A R I A B L E S */
│ │ │ │ +
122
│ │ │ │ +
123 std::shared_ptr<IntersectionListProvider> intersectionListProvider_;
│ │ │ │ +
124 std::shared_ptr<IntersectionList> intersectionList_;
│ │ │ │ +
125
│ │ │ │ +
127 std::vector<std::vector<unsigned int> > grid1ElementCorners_;
│ │ │ │ +
128 std::vector<std::vector<unsigned int> > grid2ElementCorners_;
│ │ │ │ +
129
│ │ │ │ +
130 std::vector<std::vector<int> > elementNeighbors1_;
│ │ │ │ +
131 std::vector<std::vector<int> > elementNeighbors2_;
│ │ │ │ +
132
│ │ │ │ +
133public:
│ │ │ │ +
134
│ │ │ │ +
135 /* C O N C E P T I M P L E M E N T I N G I N T E R F A C E */
│ │ │ │ +
136
│ │ │ │ +
│ │ │ │ +
140 void build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ +
141 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
142 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
143 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ +
144 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
145 const std::vector<Dune::GeometryType>& grid2_element_types) override;
│ │ │ │ +
146
│ │ │ │ +
147
│ │ │ │ +
148 /* P R O B I N G T H E M E R G E D G R I D */
│ │ │ │ +
149
│ │ │ │ +
│ │ │ │ +
150 void clear() override
│ │ │ │ +
151 {
│ │ │ │ +
152 // Delete old internal data, from a possible previous run
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
156
│ │ │ │ +
157 valid = false;
│ │ │ │ +
158 }
│ │ │ │ +
│ │ │ │ +
159
│ │ │ │ +
│ │ │ │ +
160 std::shared_ptr<IntersectionList> intersectionList() const final
│ │ │ │ +
161 {
│ │ │ │ +
162 assert(valid);
│ │ │ │ +
163 return intersectionList_;
│ │ │ │ +
164 }
│ │ │ │ +
│ │ │ │ +
165
│ │ │ │ +
│ │ │ │ +
166 void enableFallback(bool fallback)
│ │ │ │ +
167 {
│ │ │ │ +
168 m_enableFallback = fallback;
│ │ │ │ +
169 }
│ │ │ │ +
│ │ │ │ +
170
│ │ │ │ +
│ │ │ │ +
171 void enableBruteForce(bool bruteForce)
│ │ │ │ +
172 {
│ │ │ │ +
173 m_enableBruteForce = bruteForce;
│ │ │ │ +
174 }
│ │ │ │ +
│ │ │ │ +
175
│ │ │ │ +
176private:
│ │ │ │ +
180 bool m_enableFallback = false;
│ │ │ │ +
181
│ │ │ │ +
185 bool m_enableBruteForce = false;
│ │ │ │ +
186
│ │ │ │ +
187 auto& intersections()
│ │ │ │ +
188 { return intersectionListProvider_->intersections(); }
│ │ │ │ +
189
│ │ │ │ +
191 template<typename V>
│ │ │ │ +
192 static void purge(V & v)
│ │ │ │ +
193 {
│ │ │ │ +
194 v.clear();
│ │ │ │ +
195 V v2(v);
│ │ │ │ +
196 v.swap(v2);
│ │ │ │ +
197 }
│ │ │ │ +
198
│ │ │ │ +
203 void generateSeed(std::vector<int>& seeds,
│ │ │ │ +
204 Dune::BitSetVector<1>& isHandled2,
│ │ │ │ +
205 std::stack<unsigned>& candidates2,
│ │ │ │ +
206 const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords,
│ │ │ │ +
207 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
208 const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords,
│ │ │ │ +
209 const std::vector<Dune::GeometryType>& grid2_element_types);
│ │ │ │ +
210
│ │ │ │ +
214 int insertIntersections(unsigned int candidate1, unsigned int candidate2,std::vector<SimplicialIntersection>& intersections);
│ │ │ │ +
215
│ │ │ │ +
219 int bruteForceSearch(int candidate1,
│ │ │ │ +
220 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
221 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
222 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
223 const std::vector<Dune::GeometryType>& grid2_element_types);
│ │ │ │ +
224
│ │ │ │ +
228 std::pair<bool, unsigned int>
│ │ │ │ +
229 intersectionIndex(unsigned int grid1Index, unsigned int grid2Index,
│ │ │ │ +
230 SimplicialIntersection& intersection);
│ │ │ │ +
231
│ │ │ │ +
235 template <int gridDim>
│ │ │ │ +
236 void computeNeighborsPerElement(const std::vector<Dune::GeometryType>& gridElementTypes,
│ │ │ │ +
237 const std::vector<std::vector<unsigned int> >& gridElementCorners,
│ │ │ │ +
238 std::vector<std::vector<int> >& elementNeighbors);
│ │ │ │ +
239
│ │ │ │ +
240 void buildAdvancingFront(
│ │ │ │ +
241 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ +
242 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
243 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
244 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ +
245 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
246 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ +
247 );
│ │ │ │ +
248
│ │ │ │ +
249 void buildBruteForce(
│ │ │ │ +
250 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
│ │ │ │ +
251 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
252 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
253 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
│ │ │ │ +
254 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
255 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ +
256 );
│ │ │ │ +
257};
│ │ │ │ +
258
│ │ │ │ +
259
│ │ │ │ +
260/* IMPLEMENTATION */
│ │ │ │ +
261
│ │ │ │ +
262template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
│ │ │ │ +
263bool StandardMerge<T,grid1Dim,grid2Dim,dimworld>::computeIntersection(unsigned int candidate0, unsigned int candidate1,
│ │ │ │ +
264 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
265 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
266 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
│ │ │ │ +
267 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
268 const std::vector<Dune::GeometryType>& grid2_element_types,
│ │ │ │ +
269 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
│ │ │ │ +
270 bool insert)
│ │ │ │ +
271{
│ │ │ │ +
272 // Select vertices of the grid1 element
│ │ │ │ +
273 int grid1NumVertices = grid1ElementCorners_[candidate0].size();
│ │ │ │ +
274 std::vector<Dune::FieldVector<T,dimworld> > grid1ElementCorners(grid1NumVertices);
│ │ │ │ +
275 for (int i=0; i<grid1NumVertices; i++)
│ │ │ │ +
276 grid1ElementCorners[i] = grid1Coords[grid1ElementCorners_[candidate0][i]];
│ │ │ │ +
277
│ │ │ │ +
278 // Select vertices of the grid2 element
│ │ │ │ +
279 int grid2NumVertices = grid2ElementCorners_[candidate1].size();
│ │ │ │ +
280 std::vector<Dune::FieldVector<T,dimworld> > grid2ElementCorners(grid2NumVertices);
│ │ │ │ +
281 for (int i=0; i<grid2NumVertices; i++)
│ │ │ │ +
282 grid2ElementCorners[i] = grid2Coords[grid2ElementCorners_[candidate1][i]];
│ │ │ │ +
283
│ │ │ │ +
284 // ///////////////////////////////////////////////////////
│ │ │ │ +
285 // Compute the intersection between the two elements
│ │ │ │ +
286 // ///////////////////////////////////////////////////////
│ │ │ │ +
287
│ │ │ │ +
288 std::vector<SimplicialIntersection> intersections(0);
│ │ │ │ +
289
│ │ │ │ +
290 // compute the intersections
│ │ │ │ +
291 computeIntersections(grid1_element_types[candidate0], grid1ElementCorners,
│ │ │ │ +
292 neighborIntersects1, candidate0,
│ │ │ │ +
293 grid2_element_types[candidate1], grid2ElementCorners,
│ │ │ │ +
294 neighborIntersects2, candidate1,
│ │ │ │ + │ │ │ │ +
296
│ │ │ │ +
297 // insert intersections if needed
│ │ │ │ +
298 if(insert && !intersections.empty())
│ │ │ │ +
299 insertIntersections(candidate0,candidate1,intersections);
│ │ │ │ +
300
│ │ │ │ +
301 // Have we found an intersection?
│ │ │ │ +
302 return !intersections.empty() || neighborIntersects1.any() || neighborIntersects2.any();
│ │ │ │ +
303
│ │ │ │ +
304}
│ │ │ │ +
│ │ │ │ +
305
│ │ │ │ +
306template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ + │ │ │ │ +
308 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
309 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
310 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
311 const std::vector<Dune::GeometryType>& grid2_element_types)
│ │ │ │ +
312{
│ │ │ │ +
313 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ +
314 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ +
315 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
│ │ │ │ +
316
│ │ │ │ +
317 bool intersectionFound = computeIntersection(i, candidate1,
│ │ │ │ +
318 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ +
319 grid2Coords, grid2_element_types, neighborIntersects2,
│ │ │ │ +
320 false);
│ │ │ │ +
321
│ │ │ │ +
322 // if there is an intersection, i is our new seed candidate on the grid1 side
│ │ │ │ +
323 if (intersectionFound)
│ │ │ │ +
324 return i;
│ │ │ │ +
325
│ │ │ │ +
326 }
│ │ │ │ +
327
│ │ │ │ +
328 return -1;
│ │ │ │ +
329}
│ │ │ │ +
330
│ │ │ │ +
331
│ │ │ │ +
332template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
333template<int gridDim>
│ │ │ │ +
334void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::
│ │ │ │ +
335computeNeighborsPerElement(const std::vector<Dune::GeometryType>& gridElementTypes,
│ │ │ │ +
336 const std::vector<std::vector<unsigned int> >& gridElementCorners,
│ │ │ │ +
337 std::vector<std::vector<int> >& elementNeighbors)
│ │ │ │ +
338{
│ │ │ │ +
339 typedef std::vector<unsigned int> FaceType;
│ │ │ │ +
340 typedef std::map<FaceType, std::pair<unsigned int, unsigned int> > FaceSetType;
│ │ │ │ +
341
│ │ │ │ +
343 // First: grid 1
│ │ │ │ +
345 FaceSetType faces;
│ │ │ │ +
346 elementNeighbors.resize(gridElementTypes.size());
│ │ │ │ +
347
│ │ │ │ +
348 for (size_t i=0; i<gridElementTypes.size(); i++)
│ │ │ │ +
349 elementNeighbors[i].resize(Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]).size(1), -1);
│ │ │ │ +
350
│ │ │ │ +
351 for (size_t i=0; i<gridElementTypes.size(); i++) { //iterate over all elements
│ │ │ │ +
352 const auto& refElement = Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]);
│ │ │ │ +
353
│ │ │ │ +
354 for (size_t j=0; j<(size_t)refElement.size(1); j++) { // iterate over all faces of the element
│ │ │ │ +
355
│ │ │ │ +
356 FaceType face;
│ │ │ │ +
357 // extract element face
│ │ │ │ +
358 for (size_t k=0; k<(size_t)refElement.size(j,1,gridDim); k++)
│ │ │ │ +
359 face.push_back(gridElementCorners[i][refElement.subEntity(j,1,k,gridDim)]);
│ │ │ │ +
360
│ │ │ │ +
361 // sort the face vertices to get rid of twists and other permutations
│ │ │ │ +
362 std::sort(face.begin(), face.end());
│ │ │ │ +
363
│ │ │ │ +
364 typename FaceSetType::iterator faceHandle = faces.find(face);
│ │ │ │ +
365
│ │ │ │ +
366 if (faceHandle == faces.end()) {
│ │ │ │ +
367
│ │ │ │ +
368 // face has not been visited before
│ │ │ │ +
369 faces.insert(std::make_pair(face, std::make_pair(i,j)));
│ │ │ │ +
370
│ │ │ │ +
371 } else {
│ │ │ │ +
372
│ │ │ │ +
373 // face has been visited before: store the mutual neighbor information
│ │ │ │ +
374 elementNeighbors[i][j] = faceHandle->second.first;
│ │ │ │ +
375 elementNeighbors[faceHandle->second.first][faceHandle->second.second] = i;
│ │ │ │ +
376
│ │ │ │ +
377 faces.erase(faceHandle);
│ │ │ │ +
378
│ │ │ │ +
379 }
│ │ │ │ +
380
│ │ │ │ +
381 }
│ │ │ │ +
382
│ │ │ │ +
383 }
│ │ │ │ +
384}
│ │ │ │ +
385
│ │ │ │ +
386// /////////////////////////////////////////////////////////////////////
│ │ │ │ +
387// Compute the intersection of all pairs of elements
│ │ │ │ +
388// Linear algorithm by Gander and Japhet, Proc. of DD18
│ │ │ │ +
389// /////////////////////////////////////////////////////////////////////
│ │ │ │ +
390
│ │ │ │ +
391template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
│ │ │ │ +
392void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
393 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
394 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
395 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
396 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
397 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ +
398 )
│ │ │ │ +
399{
│ │ │ │ +
400
│ │ │ │ +
401 std::cout << "StandardMerge building merged grid..." << std::endl;
│ │ │ │ +
402 Dune::Timer watch;
│ │ │ │ +
403
│ │ │ │ +
404 clear();
│ │ │ │ +
405 // clear global intersection list
│ │ │ │ +
406 intersectionListProvider_->clear();
│ │ │ │ +
407 this->counter = 0;
│ │ │ │ +
408
│ │ │ │ +
409 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
410 // Copy element corners into a data structure with block-structure.
│ │ │ │ +
411 // This is not as efficient but a lot easier to use.
│ │ │ │ +
412 // We may think about efficiency later.
│ │ │ │ +
413 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
414
│ │ │ │ +
415 // first the grid1 side
│ │ │ │ +
416 grid1ElementCorners_.resize(grid1_element_types.size());
│ │ │ │ +
417
│ │ │ │ +
418 unsigned int grid1CornerCounter = 0;
│ │ │ │ +
419
│ │ │ │ +
420 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
│ │ │ │ +
421
│ │ │ │ +
422 // Select vertices of the grid1 element
│ │ │ │ +
423 int numVertices = Dune::ReferenceElements<T,grid1Dim>::general(grid1_element_types[i]).size(grid1Dim);
│ │ │ │ +
424 grid1ElementCorners_[i].resize(numVertices);
│ │ │ │ +
425 for (int j=0; j<numVertices; j++)
│ │ │ │ +
426 grid1ElementCorners_[i][j] = grid1_elements[grid1CornerCounter++];
│ │ │ │ +
427
│ │ │ │ +
428 }
│ │ │ │ +
429
│ │ │ │ +
430 // then the grid2 side
│ │ │ │ +
431 grid2ElementCorners_.resize(grid2_element_types.size());
│ │ │ │ +
432
│ │ │ │ +
433 unsigned int grid2CornerCounter = 0;
│ │ │ │ +
434
│ │ │ │ +
435 for (std::size_t i=0; i<grid2_element_types.size(); i++) {
│ │ │ │ +
436
│ │ │ │ +
437 // Select vertices of the grid2 element
│ │ │ │ +
438 int numVertices = Dune::ReferenceElements<T,grid2Dim>::general(grid2_element_types[i]).size(grid2Dim);
│ │ │ │ +
439 grid2ElementCorners_[i].resize(numVertices);
│ │ │ │ +
440 for (int j=0; j<numVertices; j++)
│ │ │ │ +
441 grid2ElementCorners_[i][j] = grid2_elements[grid2CornerCounter++];
│ │ │ │ +
442
│ │ │ │ +
443 }
│ │ │ │ +
444
│ │ │ │ +
446 // Compute the face neighbors for each element
│ │ │ │ +
448
│ │ │ │ +
449 computeNeighborsPerElement<grid1Dim>(grid1_element_types, grid1ElementCorners_, elementNeighbors1_);
│ │ │ │ +
450 computeNeighborsPerElement<grid2Dim>(grid2_element_types, grid2ElementCorners_, elementNeighbors2_);
│ │ │ │ +
451
│ │ │ │ +
452 std::cout << "setup took " << watch.elapsed() << " seconds." << std::endl;
│ │ │ │ +
453
│ │ │ │ +
454 if (m_enableBruteForce)
│ │ │ │ +
455 buildBruteForce(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
│ │ │ │ +
456 else
│ │ │ │ +
457 buildAdvancingFront(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
│ │ │ │ +
458
│ │ │ │ +
459 valid = true;
│ │ │ │ +
460 std::cout << "intersection construction took " << watch.elapsed() << " seconds." << std::endl;
│ │ │ │ +
461}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
462
│ │ │ │ +
463template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ + │ │ │ │ +
465 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
466 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
467 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
468 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
469 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
470 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ +
471 )
│ │ │ │ +
472{
│ │ │ │ +
474 // Data structures for the advancing-front algorithm
│ │ │ │ +
476
│ │ │ │ +
477 std::stack<unsigned int> candidates1;
│ │ │ │ +
478 std::stack<unsigned int> candidates2;
│ │ │ │ +
479
│ │ │ │ +
480 std::vector<int> seeds(grid2_element_types.size(), -1);
│ │ │ │ +
481
│ │ │ │ +
482 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
483 // Do a brute-force search to find one pair of intersecting elements
│ │ │ │ +
484 // to start the advancing-front type algorithm with.
│ │ │ │ +
485 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
486
│ │ │ │ +
487 // Set flag if element has been handled
│ │ │ │ +
488 Dune::BitSetVector<1> isHandled2(grid2_element_types.size());
│ │ │ │ +
489
│ │ │ │ +
490 // Set flag if the element has been entered in the queue
│ │ │ │ +
491 Dune::BitSetVector<1> isCandidate2(grid2_element_types.size());
│ │ │ │ +
492
│ │ │ │ +
493 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
│ │ │ │ +
494
│ │ │ │ +
495 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
496 // Main loop
│ │ │ │ +
497 // /////////////////////////////////////////////////////////////////////
│ │ │ │ +
498
│ │ │ │ +
499 std::set<unsigned int> isHandled1;
│ │ │ │ +
500
│ │ │ │ +
501 std::set<unsigned int> isCandidate1;
│ │ │ │ +
502
│ │ │ │ +
503 while (!candidates2.empty()) {
│ │ │ │ +
504
│ │ │ │ +
505 // Get the next element on the grid2 side
│ │ │ │ +
506 unsigned int currentCandidate2 = candidates2.top();
│ │ │ │ +
507 int seed = seeds[currentCandidate2];
│ │ │ │ +
508 assert(seed >= 0);
│ │ │ │ +
509
│ │ │ │ +
510 candidates2.pop();
│ │ │ │ +
511 isHandled2[currentCandidate2] = true;
│ │ │ │ +
512
│ │ │ │ +
513 // Start advancing front algorithm on the grid1 side from the 'seed' element that
│ │ │ │ +
514 // we stored along with the current grid2 element
│ │ │ │ +
515 candidates1.push(seed);
│ │ │ │ +
516
│ │ │ │ +
517 isHandled1.clear();
│ │ │ │ +
518 isCandidate1.clear();
│ │ │ │ +
519
│ │ │ │ +
520 while (!candidates1.empty()) {
│ │ │ │ +
521
│ │ │ │ +
522 unsigned int currentCandidate1 = candidates1.top();
│ │ │ │ +
523 candidates1.pop();
│ │ │ │ +
524 isHandled1.insert(currentCandidate1);
│ │ │ │ +
525
│ │ │ │ +
526 // Test whether there is an intersection between currentCandidate0 and currentCandidate1
│ │ │ │ +
527 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ +
528 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ +
529 bool intersectionFound = computeIntersection(currentCandidate1, currentCandidate2,
│ │ │ │ +
530 grid1Coords,grid1_element_types, neighborIntersects1,
│ │ │ │ +
531 grid2Coords,grid2_element_types, neighborIntersects2);
│ │ │ │ +
532
│ │ │ │ +
533 for (size_t i=0; i<neighborIntersects2.size(); i++)
│ │ │ │ +
534 if (neighborIntersects2[i] && elementNeighbors2_[currentCandidate2][i] != -1)
│ │ │ │ +
535 seeds[elementNeighbors2_[currentCandidate2][i]] = currentCandidate1;
│ │ │ │ +
536
│ │ │ │ +
537 // add neighbors of candidate0 to the list of elements to be checked
│ │ │ │ +
538 if (intersectionFound) {
│ │ │ │ +
539
│ │ │ │ +
540 for (size_t i=0; i<elementNeighbors1_[currentCandidate1].size(); i++) {
│ │ │ │ +
541
│ │ │ │ +
542 int neighbor = elementNeighbors1_[currentCandidate1][i];
│ │ │ │ +
543
│ │ │ │ +
544 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ +
545 continue;
│ │ │ │ +
546
│ │ │ │ +
547 if (isHandled1.find(neighbor) == isHandled1.end()
│ │ │ │ +
548 && isCandidate1.find(neighbor) == isCandidate1.end()) {
│ │ │ │ +
549 candidates1.push(neighbor);
│ │ │ │ +
550 isCandidate1.insert(neighbor);
│ │ │ │ +
551 }
│ │ │ │ +
552
│ │ │ │ +
553 }
│ │ │ │ +
554
│ │ │ │ +
555 }
│ │ │ │ +
556
│ │ │ │ +
557 }
│ │ │ │ +
558
│ │ │ │ +
559 // We have now found all intersections of elements in the grid1 side with currentCandidate2
│ │ │ │ +
560 // Now we add all neighbors of currentCandidate2 that have not been treated yet as new
│ │ │ │ +
561 // candidates.
│ │ │ │ +
562
│ │ │ │ +
563 // Do we have an unhandled neighbor with a seed?
│ │ │ │ +
564 bool seedFound = !candidates2.empty();
│ │ │ │ +
565 for (size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
│ │ │ │ +
566
│ │ │ │ +
567 int neighbor = elementNeighbors2_[currentCandidate2][i];
│ │ │ │ +
568
│ │ │ │ +
569 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ +
570 continue;
│ │ │ │ +
571
│ │ │ │ +
572 // Add all unhandled intersecting neighbors to the queue
│ │ │ │ +
573 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0] && seeds[neighbor]>-1) {
│ │ │ │ +
574
│ │ │ │ +
575 isCandidate2[neighbor][0] = true;
│ │ │ │ +
576 candidates2.push(neighbor);
│ │ │ │ +
577 seedFound = true;
│ │ │ │ +
578 }
│ │ │ │ +
579 }
│ │ │ │ +
580
│ │ │ │ +
581 if (seedFound || !m_enableFallback)
│ │ │ │ +
582 continue;
│ │ │ │ +
583
│ │ │ │ +
584 // There is no neighbor with a seed, so we need to be a bit more aggressive...
│ │ │ │ +
585 // get all neighbors of currentCandidate2, but not currentCandidate2 itself
│ │ │ │ +
586 for (size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
│ │ │ │ +
587
│ │ │ │ +
588 int neighbor = elementNeighbors2_[currentCandidate2][i];
│ │ │ │ +
589
│ │ │ │ +
590 if (neighbor == -1) // do nothing at the grid boundary
│ │ │ │ +
591 continue;
│ │ │ │ +
592
│ │ │ │ +
593 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0]) {
│ │ │ │ +
594
│ │ │ │ +
595 // Get a seed element for the new grid2 element
│ │ │ │ +
596 // Look for an element on the grid1 side that intersects the new grid2 element.
│ │ │ │ +
597 int seed = -1;
│ │ │ │ +
598
│ │ │ │ +
599 // Look among the ones that have been tested during the last iteration.
│ │ │ │ +
600 for (typename std::set<unsigned int>::iterator seedIt = isHandled1.begin();
│ │ │ │ +
601 seedIt != isHandled1.end(); ++seedIt) {
│ │ │ │ +
602
│ │ │ │ +
603 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ +
604 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ +
605 bool intersectionFound = computeIntersection(*seedIt, neighbor,
│ │ │ │ +
606 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ +
607 grid2Coords, grid2_element_types, neighborIntersects2,
│ │ │ │ +
608 false);
│ │ │ │ +
609
│ │ │ │ +
610 // if the intersection is nonempty, *seedIt is our new seed candidate on the grid1 side
│ │ │ │ +
611 if (intersectionFound) {
│ │ │ │ +
612 seed = *seedIt;
│ │ │ │ +
613 Dune::dwarn << "Algorithm entered first fallback method and found a new seed in the build algorithm." <<
│ │ │ │ +
614 "Probably, the neighborIntersects bitsets computed in computeIntersection specialization is wrong." << std::endl;
│ │ │ │ +
615 break;
│ │ │ │ +
616 }
│ │ │ │ +
617
│ │ │ │ +
618 }
│ │ │ │ +
619
│ │ │ │ +
620 if (seed < 0) {
│ │ │ │ +
621 // The fast method didn't find a grid1 element that intersects with
│ │ │ │ +
622 // the new grid2 candidate. We have to do a brute-force search.
│ │ │ │ +
623 seed = bruteForceSearch(neighbor,
│ │ │ │ +
624 grid1Coords,grid1_element_types,
│ │ │ │ +
625 grid2Coords,grid2_element_types);
│ │ │ │ +
626 Dune::dwarn << "Algorithm entered second fallback method. This probably should not happen." << std::endl;
│ │ │ │ +
627
│ │ │ │ +
628 }
│ │ │ │ +
629
│ │ │ │ +
630 // We have tried all we could: the candidate is 'handled' now
│ │ │ │ +
631 isCandidate2[neighbor] = true;
│ │ │ │ +
632
│ │ │ │ +
633 // still no seed? Then the new grid2 candidate isn't overlapped by anything
│ │ │ │ +
634 if (seed < 0)
│ │ │ │ +
635 continue;
│ │ │ │ +
636
│ │ │ │ +
637 // we have a seed now
│ │ │ │ +
638 candidates2.push(neighbor);
│ │ │ │ +
639 seeds[neighbor] = seed;
│ │ │ │ +
640 seedFound = true;
│ │ │ │ +
641
│ │ │ │ +
642 }
│ │ │ │ +
643
│ │ │ │ +
644 }
│ │ │ │ +
645
│ │ │ │ +
646 /* Do a brute-force search if there is still no seed:
│ │ │ │ +
647 * There might still be a disconnected region out there.
│ │ │ │ +
648 */
│ │ │ │ +
649 if (!seedFound && candidates2.empty()) {
│ │ │ │ +
650 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
│ │ │ │ +
651 }
│ │ │ │ +
652 }
│ │ │ │ +
653}
│ │ │ │ +
654
│ │ │ │ +
655template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
656void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::buildBruteForce(
│ │ │ │ +
657 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
│ │ │ │ +
658 const std::vector<unsigned int>& grid1_elements,
│ │ │ │ +
659 const std::vector<Dune::GeometryType>& grid1_element_types,
│ │ │ │ +
660 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
│ │ │ │ +
661 const std::vector<unsigned int>& grid2_elements,
│ │ │ │ +
662 const std::vector<Dune::GeometryType>& grid2_element_types
│ │ │ │ +
663 )
│ │ │ │ +
664{
│ │ │ │ +
665 std::bitset<(1<<grid1Dim)> neighborIntersects1;
│ │ │ │ +
666 std::bitset<(1<<grid2Dim)> neighborIntersects2;
│ │ │ │ +
667
│ │ │ │ +
668 for (unsigned i = 0; i < grid1_element_types.size(); ++i) {
│ │ │ │ +
669 for (unsigned j = 0; j < grid2_element_types.size(); ++j) {
│ │ │ │ +
670 (void) computeIntersection(i, j,
│ │ │ │ +
671 grid1Coords, grid1_element_types, neighborIntersects1,
│ │ │ │ +
672 grid2Coords, grid2_element_types, neighborIntersects2);
│ │ │ │ +
673 }
│ │ │ │ +
674 }
│ │ │ │ +
675}
│ │ │ │ +
676
│ │ │ │ +
677template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
678void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::generateSeed(std::vector<int>& seeds, Dune::BitSetVector<1>& isHandled2, std::stack<unsigned>& candidates2, const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords, const std::vector<Dune::GeometryType>& grid1_element_types, const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords, const std::vector<Dune::GeometryType>& grid2_element_types)
│ │ │ │ +
679{
│ │ │ │ +
680 for (std::size_t j=0; j<grid2_element_types.size(); j++) {
│ │ │ │ +
681
│ │ │ │ +
682 if (seeds[j] > 0 || isHandled2[j][0])
│ │ │ │ +
683 continue;
│ │ │ │ +
684
│ │ │ │ +
685 int seed = bruteForceSearch(j,grid1Coords,grid1_element_types,grid2Coords,grid2_element_types);
│ │ │ │ +
686
│ │ │ │ +
687 if (seed >= 0) {
│ │ │ │ +
688 candidates2.push(j); // the candidate and a seed for the candidate
│ │ │ │ +
689 seeds[j] = seed;
│ │ │ │ +
690 break;
│ │ │ │ +
691 } else // If the brute force search did not find any intersection we can skip this element
│ │ │ │ +
692 isHandled2[j] = true;
│ │ │ │ +
693 }
│ │ │ │ +
694}
│ │ │ │ +
695
│ │ │ │ +
696template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
697int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::insertIntersections(unsigned int candidate1, unsigned int candidate2,
│ │ │ │ +
698 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ +
699{
│ │ │ │ +
700 typedef typename std::vector<SimplicialIntersection>::size_type size_t;
│ │ │ │ +
701 int count = 0;
│ │ │ │ +
702
│ │ │ │ +
703 for (size_t i = 0; i < intersections.size(); ++i) {
│ │ │ │ +
704 // get the intersection index of the current intersection from intersections in this->intersections
│ │ │ │ +
705 bool found;
│ │ │ │ +
706 unsigned int index;
│ │ │ │ +
707 std::tie(found, index) = intersectionIndex(candidate1,candidate2,intersections[i]);
│ │ │ │ +
708
│ │ │ │ +
709 if (found && index >= this->intersections().size()) { //the intersection is not yet contained in this->intersections
│ │ │ │ +
710 this->intersections().push_back(intersections[i]); // insert
│ │ │ │ +
711
│ │ │ │ +
712 ++count;
│ │ │ │ +
713 } else if (found) {
│ │ │ │ +
714 auto& intersection = this->intersections()[index];
│ │ │ │ +
715
│ │ │ │ +
716 // insert each grid1 element and local representation of intersections[i] with parent candidate1
│ │ │ │ +
717 for (size_t j = 0; j < intersections[i].parents0.size(); ++j) {
│ │ │ │ +
718 intersection.parents0.push_back(candidate1);
│ │ │ │ +
719 intersection.corners0.push_back(intersections[i].corners0[j]);
│ │ │ │ +
720 }
│ │ │ │ +
721
│ │ │ │ +
722 // insert each grid2 element and local representation of intersections[i] with parent candidate2
│ │ │ │ +
723 for (size_t j = 0; j < intersections[i].parents1.size(); ++j) {
│ │ │ │ +
724 intersection.parents1.push_back(candidate2);
│ │ │ │ +
725 intersection.corners1.push_back(intersections[i].corners1[j]);
│ │ │ │ +
726 }
│ │ │ │ +
727
│ │ │ │ +
728 ++count;
│ │ │ │ +
729 } else {
│ │ │ │ +
730 Dune::dwarn << "Computed the same intersection twice!" << std::endl;
│ │ │ │ +
731 }
│ │ │ │ +
732 }
│ │ │ │ +
733 return count;
│ │ │ │ +
734}
│ │ │ │ +
735
│ │ │ │ +
736template<typename T, int grid1Dim, int grid2Dim, int dimworld>
│ │ │ │ +
737std::pair<bool, unsigned int>
│ │ │ │ +
738StandardMerge<T,grid1Dim,grid2Dim,dimworld>::intersectionIndex(unsigned int grid1Index, unsigned int grid2Index,
│ │ │ │ +
739 SimplicialIntersection& intersection) {
│ │ │ │ +
740
│ │ │ │ +
741
│ │ │ │ +
742 // return index in intersections_ if at least one local representation of a Simplicial Intersection (SI)
│ │ │ │ +
743 // of intersections_ is equal to the local representation of one element in intersections
│ │ │ │ +
744
│ │ │ │ +
745 std::size_t n_intersections = this->intersections().size();
│ │ │ │ +
746 if (grid1Dim == grid2Dim)
│ │ │ │ +
747 return {true, n_intersections};
│ │ │ │ +
748
│ │ │ │ +
749 T eps = 1e-10;
│ │ │ │ +
750
│ │ │ │ +
751 for (std::size_t i = 0; i < n_intersections; ++i) {
│ │ │ │ +
752
│ │ │ │ +
753 // compare the local representation of the subelements of the SI
│ │ │ │ +
754 for (std::size_t ei = 0; ei < this->intersections()[i].parents0.size(); ++ei) // merger subelement
│ │ │ │ +
755 {
│ │ │ │ +
756 if (this->intersections()[i].parents0[ei] == grid1Index)
│ │ │ │ +
757 {
│ │ │ │ +
758 for (std::size_t er = 0; er < intersection.parents0.size(); ++er) // list subelement
│ │ │ │ +
759 {
│ │ │ │ +
760 bool found_all = true;
│ │ │ │ +
761 // compare the local coordinate representations
│ │ │ │ +
762 for (std::size_t ci = 0; ci < this->intersections()[i].corners0[ei].size(); ++ci)
│ │ │ │ +
763 {
│ │ │ │ +
764 Dune::FieldVector<T,grid1Dim> ni = this->intersections()[i].corners0[ei][ci];
│ │ │ │ +
765 bool found_ni = false;
│ │ │ │ +
766 for (std::size_t cr = 0; cr < intersection.corners0[er].size(); ++cr)
│ │ │ │ +
767 {
│ │ │ │ +
768 Dune::FieldVector<T,grid1Dim> nr = intersection.corners0[er][cr];
│ │ │ │ +
769
│ │ │ │ +
770 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
│ │ │ │ +
771 if (found_ni)
│ │ │ │ +
772 break;
│ │ │ │ +
773 }
│ │ │ │ +
774 found_all = found_all && found_ni;
│ │ │ │ +
775
│ │ │ │ +
776 if (!found_ni)
│ │ │ │ +
777 break;
│ │ │ │ +
778 }
│ │ │ │ +
779
│ │ │ │ +
780 if (found_all && (this->intersections()[i].parents1[ei] != grid2Index))
│ │ │ │ +
781 return {true, i};
│ │ │ │ +
782 else if (found_all)
│ │ │ │ +
783 return {false, 0};
│ │ │ │ +
784 }
│ │ │ │ +
785 }
│ │ │ │ +
786 }
│ │ │ │ +
787
│ │ │ │ +
788 // compare the local representation of the subelements of the SI
│ │ │ │ +
789 for (std::size_t ei = 0; ei < this->intersections()[i].parents1.size(); ++ei) // merger subelement
│ │ │ │ +
790 {
│ │ │ │ +
791 if (this->intersections()[i].parents1[ei] == grid2Index)
│ │ │ │ +
792 {
│ │ │ │ +
793 for (std::size_t er = 0; er < intersection.parents1.size(); ++er) // list subelement
│ │ │ │ +
794 {
│ │ │ │ +
795 bool found_all = true;
│ │ │ │ +
796 // compare the local coordinate representations
│ │ │ │ +
797 for (std::size_t ci = 0; ci < this->intersections()[i].corners1[ei].size(); ++ci)
│ │ │ │ +
798 {
│ │ │ │ +
799 Dune::FieldVector<T,grid2Dim> ni = this->intersections()[i].corners1[ei][ci];
│ │ │ │ +
800 bool found_ni = false;
│ │ │ │ +
801 for (std::size_t cr = 0; cr < intersection.corners1[er].size(); ++cr)
│ │ │ │ +
802 {
│ │ │ │ +
803 Dune::FieldVector<T,grid2Dim> nr = intersection.corners1[er][cr];
│ │ │ │ +
804 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
│ │ │ │ +
805
│ │ │ │ +
806 if (found_ni)
│ │ │ │ +
807 break;
│ │ │ │ +
808 }
│ │ │ │ +
809 found_all = found_all && found_ni;
│ │ │ │ +
810
│ │ │ │ +
811 if (!found_ni)
│ │ │ │ +
812 break;
│ │ │ │ +
813 }
│ │ │ │ +
814
│ │ │ │ +
815 if (found_all && (this->intersections()[i].parents0[ei] != grid1Index))
│ │ │ │ +
816 return {true, i};
│ │ │ │ +
817 else if (found_all)
│ │ │ │ +
818 return {false, 0};
│ │ │ │ +
819 }
│ │ │ │ +
820 }
│ │ │ │ +
821 }
│ │ │ │ +
822 }
│ │ │ │ +
823
│ │ │ │ +
824 return {true, n_intersections};
│ │ │ │ +
825}
│ │ │ │ +
826
│ │ │ │ +
827#define DECL extern
│ │ │ │ +
│ │ │ │ +
828#define STANDARD_MERGE_INSTANTIATE(T,A,B,C) \
│ │ │ │ +
829 DECL template \
│ │ │ │ +
830 void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1Coords, \
│ │ │ │ +
831 const std::vector<unsigned int>& grid1_elements, \
│ │ │ │ +
832 const std::vector<Dune::GeometryType>& grid1_element_types, \
│ │ │ │ +
833 const std::vector<Dune::FieldVector<T,C> >& grid2Coords, \
│ │ │ │ +
834 const std::vector<unsigned int>& grid2_elements, \
│ │ │ │ +
835 const std::vector<Dune::GeometryType>& grid2_element_types \
│ │ │ │ +
836 )
│ │ │ │ +
│ │ │ │ +
837
│ │ │ │ +
838STANDARD_MERGE_INSTANTIATE(double,1,1,1);
│ │ │ │ +
839STANDARD_MERGE_INSTANTIATE(double,2,2,2);
│ │ │ │ +
840STANDARD_MERGE_INSTANTIATE(double,3,3,3);
│ │ │ │ +
841#undef STANDARD_MERGE_INSTANTIATE
│ │ │ │ +
842#undef DECL
│ │ │ │ +
843
│ │ │ │ +
844} /* namespace GridGlue */
│ │ │ │ +
845} /* namespace Dune */
│ │ │ │ +
846
│ │ │ │ +
847#endif // DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
#define STANDARD_MERGE_INSTANTIATE(T, A, B, C)
Definition standardmerge.cc:13
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
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
│ │ │ │ +
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
│ │ │ │ +
Definition intersectionlist.hh:207
│ │ │ │ + │ │ │ │ +
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition merger.hh:27
│ │ │ │ +
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition merger.hh:37
│ │ │ │ +
Dune::GridGlue::IntersectionList< Grid1Coords, Grid2Coords > IntersectionList
Definition merger.hh:39
│ │ │ │ +
Dune::FieldVector< T, grid1Dim > Grid1Coords
the local coordinate type for the grid1 coordinates
Definition merger.hh:31
│ │ │ │ +
Dune::FieldVector< T, grid2Dim > Grid2Coords
the local coordinate type for the grid2 coordinates
Definition merger.hh:34
│ │ │ │
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition standardmerge.hh:58
│ │ │ │ +
virtual void computeIntersections(const Dune::GeometryType &grid1ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std::bitset<(1<< grid1Dim)> &neighborIntersects1, unsigned int grid1Index, const Dune::GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< grid2Dim)> &neighborIntersects2, unsigned int grid2Index, std::vector< SimplicialIntersection > &intersections)=0
Compute the intersection between two overlapping elements.
│ │ │ │ +
std::shared_ptr< IntersectionList > intersectionList_
Definition standardmerge.hh:124
│ │ │ │ +
typename Base::Grid1Coords Grid1Coords
Type used for local coordinates on the grid1 side.
Definition standardmerge.hh:69
│ │ │ │ +
void enableFallback(bool fallback)
Definition standardmerge.hh:166
│ │ │ │ +
std::vector< std::vector< int > > elementNeighbors2_
Definition standardmerge.hh:131
│ │ │ │ +
std::vector< std::vector< int > > elementNeighbors1_
Definition standardmerge.hh:130
│ │ │ │ +
T ctype
the numeric type used in this interface
Definition standardmerge.hh:66
│ │ │ │ +
void clear() override
Definition standardmerge.hh:150
│ │ │ │ +
typename Base::IntersectionList IntersectionList
Definition standardmerge.hh:77
│ │ │ │ +
bool computeIntersection(unsigned int candidate0, unsigned int candidate1, const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std::vector< Dune::GeometryType > &grid1_element_types, std::bitset<(1<< grid1Dim)> &neighborIntersects1, const std::vector< Dune::FieldVector< T, dimworld > > &grid2Coords, const std::vector< Dune::GeometryType > &grid2_element_types, std::bitset<(1<< grid2Dim)> &neighborIntersects2, bool insert=true)
Compute the intersection between two overlapping elements.
Definition standardmerge.hh:263
│ │ │ │ +
void enableBruteForce(bool bruteForce)
Definition standardmerge.hh:171
│ │ │ │ +
std::shared_ptr< IntersectionListProvider > intersectionListProvider_
Definition standardmerge.hh:123
│ │ │ │ +
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 standardmerge.hh:392
│ │ │ │ +
std::vector< std::vector< unsigned int > > grid1ElementCorners_
Temporary internal data.
Definition standardmerge.hh:127
│ │ │ │ +
std::vector< std::vector< unsigned int > > grid2ElementCorners_
Definition standardmerge.hh:128
│ │ │ │ +
typename Base::Grid2Coords Grid2Coords
Type used for local coordinates on the grid2 side.
Definition standardmerge.hh:72
│ │ │ │ +
std::shared_ptr< IntersectionList > intersectionList() const final
Definition standardmerge.hh:160
│ │ │ │ +
virtual ~StandardMerge()=default
│ │ │ │ +
SimplicialIntersection RemoteSimplicialIntersection
Definition standardmerge.hh:84
│ │ │ │ +
bool valid
Definition standardmerge.hh:86
│ │ │ │ +
StandardMerge()
Definition standardmerge.hh:88
│ │ │ │
typename IntersectionListProvider::SimplicialIntersection SimplicialIntersection
Definition standardmerge.hh:83
│ │ │ │ +
typename Base::WorldCoords WorldCoords
the coordinate type used in this interface
Definition standardmerge.hh:75
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,127 +1,989 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -overlappingmerge.hh │ │ │ │ │ +standardmerge.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 │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ +10#ifndef DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH │ │ │ │ │ +11#define DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH │ │ │ │ │ 12 │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19#include │ │ │ │ │ -20 │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ +13 │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ 23 │ │ │ │ │ -24namespace Dune { │ │ │ │ │ -25namespace GridGlue { │ │ │ │ │ -26 │ │ │ │ │ -34template │ │ │ │ │ -35class OverlappingMerge │ │ │ │ │ -36 : public StandardMerge │ │ │ │ │ -37{ │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28 │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31 │ │ │ │ │ +32#include │ │ │ │ │ +33#include │ │ │ │ │ +34#include │ │ │ │ │ +35 │ │ │ │ │ +36namespace Dune { │ │ │ │ │ +37namespace GridGlue { │ │ │ │ │ 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); │ │ │ │ │ +55template │ │ │ │ │ +56class StandardMerge │ │ │ │ │ +57 : public Merger │ │ │ │ │ +58{ │ │ │ │ │ +59 using Base = Merger; │ │ │ │ │ +60 │ │ │ │ │ +61public: │ │ │ │ │ +62 │ │ │ │ │ +63 /* 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 */ │ │ │ │ │ +64 │ │ │ │ │ +66 typedef T ctype; │ │ │ │ │ +67 │ │ │ │ │ +69 using Grid1Coords = typename Base::Grid1Coords; │ │ │ │ │ +70 │ │ │ │ │ +72 using Grid2Coords = typename Base::Grid2Coords; │ │ │ │ │ +73 │ │ │ │ │ +75 using WorldCoords = typename Base::WorldCoords; │ │ │ │ │ +76 │ │ │ │ │ +77 using IntersectionList = typename Base::IntersectionList; │ │ │ │ │ 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 │ │ │ │ │ -overlappingmerge.cc │ │ │ │ │ -standardmerge.hh │ │ │ │ │ -Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ -that may intersect. │ │ │ │ │ +79protected: │ │ │ │ │ +80 │ │ │ │ │ +82 using IntersectionListProvider = │ │ │ │ │ +SimplicialIntersectionListProvider; │ │ │ │ │ +83 using SimplicialIntersection = typename IntersectionListProvider:: │ │ │ │ │ +SimplicialIntersection; │ │ │ │ │ +84 using RemoteSimplicialIntersection = SimplicialIntersection; │ │ │ │ │ +85 │ │ │ │ │ +86 bool valid = false; │ │ │ │ │ +87 │ │ │ │ │ +88 StandardMerge() │ │ │ │ │ +89 : intersectionListProvider_(std::make_shared()) │ │ │ │ │ +90 , intersectionList_(std::make_shared │ │ │ │ │ +(intersectionListProvider_)) │ │ │ │ │ +91 {} │ │ │ │ │ +92 │ │ │ │ │ +93 virtual ~StandardMerge() = default; │ │ │ │ │ +94 │ │ │ │ │ +99 virtual void computeIntersections(const Dune::GeometryType& │ │ │ │ │ +grid1ElementType, │ │ │ │ │ +100 const std::vector >& grid1ElementCorners, │ │ │ │ │ +101 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +102 unsigned int grid1Index, │ │ │ │ │ +103 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ +104 const std::vector >& grid2ElementCorners, │ │ │ │ │ +105 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +106 unsigned int grid2Index, │ │ │ │ │ +107 std::vector& intersections) = 0; │ │ │ │ │ +108 │ │ │ │ │ +112 bool computeIntersection(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ +113 const std::vector >& grid1Coords, │ │ │ │ │ +114 const std::vector& grid1_element_types, │ │ │ │ │ +115 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +116 const std::vector >& grid2Coords, │ │ │ │ │ +117 const std::vector& grid2_element_types, │ │ │ │ │ +118 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +119 bool insert = true); │ │ │ │ │ +120 │ │ │ │ │ +121 /* M E M B E R V A R I A B L E S */ │ │ │ │ │ +122 │ │ │ │ │ +123 std::shared_ptr intersectionListProvider_; │ │ │ │ │ +124 std::shared_ptr intersectionList_; │ │ │ │ │ +125 │ │ │ │ │ +127 std::vector > grid1ElementCorners_; │ │ │ │ │ +128 std::vector > grid2ElementCorners_; │ │ │ │ │ +129 │ │ │ │ │ +130 std::vector > elementNeighbors1_; │ │ │ │ │ +131 std::vector > elementNeighbors2_; │ │ │ │ │ +132 │ │ │ │ │ +133public: │ │ │ │ │ +134 │ │ │ │ │ +135 /* C O N C E P T I M P L E M E N T I N G I N T E R F A C E */ │ │ │ │ │ +136 │ │ │ │ │ +140 void build(const std::vector >& grid1_Coords, │ │ │ │ │ +141 const std::vector& grid1_elements, │ │ │ │ │ +142 const std::vector& grid1_element_types, │ │ │ │ │ +143 const std::vector >& grid2_coords, │ │ │ │ │ +144 const std::vector& grid2_elements, │ │ │ │ │ +145 const std::vector& grid2_element_types) override; │ │ │ │ │ +146 │ │ │ │ │ +147 │ │ │ │ │ +148 /* P R O B I N G T H E M E R G E D G R I D */ │ │ │ │ │ +149 │ │ │ │ │ +150 void clear() override │ │ │ │ │ +151 { │ │ │ │ │ +152 // Delete old internal data, from a possible previous run │ │ │ │ │ +153 intersectionListProvider_->clear(); │ │ │ │ │ +154 purge(grid1ElementCorners_); │ │ │ │ │ +155 purge(grid2ElementCorners_); │ │ │ │ │ +156 │ │ │ │ │ +157 valid = false; │ │ │ │ │ +158 } │ │ │ │ │ +159 │ │ │ │ │ +160 std::shared_ptr intersectionList() const final │ │ │ │ │ +161 { │ │ │ │ │ +162 assert(valid); │ │ │ │ │ +163 return intersectionList_; │ │ │ │ │ +164 } │ │ │ │ │ +165 │ │ │ │ │ +166 void enableFallback(bool fallback) │ │ │ │ │ +167 { │ │ │ │ │ +168 m_enableFallback = fallback; │ │ │ │ │ +169 } │ │ │ │ │ +170 │ │ │ │ │ +171 void enableBruteForce(bool bruteForce) │ │ │ │ │ +172 { │ │ │ │ │ +173 m_enableBruteForce = bruteForce; │ │ │ │ │ +174 } │ │ │ │ │ +175 │ │ │ │ │ +176private: │ │ │ │ │ +180 bool m_enableFallback = false; │ │ │ │ │ +181 │ │ │ │ │ +185 bool m_enableBruteForce = false; │ │ │ │ │ +186 │ │ │ │ │ +187 auto& intersections() │ │ │ │ │ +188 { return intersectionListProvider_->intersections(); } │ │ │ │ │ +189 │ │ │ │ │ +191 template │ │ │ │ │ +192 static void purge(V & v) │ │ │ │ │ +193 { │ │ │ │ │ +194 v.clear(); │ │ │ │ │ +195 V v2(v); │ │ │ │ │ +196 v.swap(v2); │ │ │ │ │ +197 } │ │ │ │ │ +198 │ │ │ │ │ +203 void generateSeed(std::vector& seeds, │ │ │ │ │ +204 Dune::BitSetVector<1>& isHandled2, │ │ │ │ │ +205 std::stack& candidates2, │ │ │ │ │ +206 const std::vector >& grid1Coords, │ │ │ │ │ +207 const std::vector& grid1_element_types, │ │ │ │ │ +208 const std::vector >& grid2Coords, │ │ │ │ │ +209 const std::vector& grid2_element_types); │ │ │ │ │ +210 │ │ │ │ │ +214 int insertIntersections(unsigned int candidate1, unsigned int │ │ │ │ │ +candidate2,std::vector& intersections); │ │ │ │ │ +215 │ │ │ │ │ +219 int bruteForceSearch(int candidate1, │ │ │ │ │ +220 const std::vector >& grid1Coords, │ │ │ │ │ +221 const std::vector& grid1_element_types, │ │ │ │ │ +222 const std::vector >& grid2Coords, │ │ │ │ │ +223 const std::vector& grid2_element_types); │ │ │ │ │ +224 │ │ │ │ │ +228 std::pair │ │ │ │ │ +229 intersectionIndex(unsigned int grid1Index, unsigned int grid2Index, │ │ │ │ │ +230 SimplicialIntersection& intersection); │ │ │ │ │ +231 │ │ │ │ │ +235 template │ │ │ │ │ +236 void computeNeighborsPerElement(const std::vector& │ │ │ │ │ +gridElementTypes, │ │ │ │ │ +237 const std::vector >& gridElementCorners, │ │ │ │ │ +238 std::vector >& elementNeighbors); │ │ │ │ │ +239 │ │ │ │ │ +240 void buildAdvancingFront( │ │ │ │ │ +241 const std::vector >& grid1_Coords, │ │ │ │ │ +242 const std::vector& grid1_elements, │ │ │ │ │ +243 const std::vector& grid1_element_types, │ │ │ │ │ +244 const std::vector >& grid2_coords, │ │ │ │ │ +245 const std::vector& grid2_elements, │ │ │ │ │ +246 const std::vector& grid2_element_types │ │ │ │ │ +247 ); │ │ │ │ │ +248 │ │ │ │ │ +249 void buildBruteForce( │ │ │ │ │ +250 const std::vector >& grid1_Coords, │ │ │ │ │ +251 const std::vector& grid1_elements, │ │ │ │ │ +252 const std::vector& grid1_element_types, │ │ │ │ │ +253 const std::vector >& grid2_coords, │ │ │ │ │ +254 const std::vector& grid2_elements, │ │ │ │ │ +255 const std::vector& grid2_element_types │ │ │ │ │ +256 ); │ │ │ │ │ +257}; │ │ │ │ │ +258 │ │ │ │ │ +259 │ │ │ │ │ +260/* IMPLEMENTATION */ │ │ │ │ │ +261 │ │ │ │ │ +262template │ │ │ │ │ +263bool StandardMerge::computeIntersection │ │ │ │ │ +(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ +264 const std::vector >& grid1Coords, │ │ │ │ │ +265 const std::vector& grid1_element_types, │ │ │ │ │ +266 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +267 const std::vector >& grid2Coords, │ │ │ │ │ +268 const std::vector& grid2_element_types, │ │ │ │ │ +269 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +270 bool insert) │ │ │ │ │ +271{ │ │ │ │ │ +272 // Select vertices of the grid1 element │ │ │ │ │ +273 int grid1NumVertices = grid1ElementCorners_[candidate0].size(); │ │ │ │ │ +274 std::vector > grid1ElementCorners │ │ │ │ │ +(grid1NumVertices); │ │ │ │ │ +275 for (int i=0; i > grid2ElementCorners │ │ │ │ │ +(grid2NumVertices); │ │ │ │ │ +281 for (int i=0; i intersections(0); │ │ │ │ │ +289 │ │ │ │ │ +290 // compute the intersections │ │ │ │ │ +291 computeIntersections(grid1_element_types[candidate0], grid1ElementCorners, │ │ │ │ │ +292 neighborIntersects1, candidate0, │ │ │ │ │ +293 grid2_element_types[candidate1], grid2ElementCorners, │ │ │ │ │ +294 neighborIntersects2, candidate1, │ │ │ │ │ +295 intersections); │ │ │ │ │ +296 │ │ │ │ │ +297 // insert intersections if needed │ │ │ │ │ +298 if(insert && !intersections.empty()) │ │ │ │ │ +299 insertIntersections(candidate0,candidate1,intersections); │ │ │ │ │ +300 │ │ │ │ │ +301 // Have we found an intersection? │ │ │ │ │ +302 return !intersections.empty() || neighborIntersects1.any() || │ │ │ │ │ +neighborIntersects2.any(); │ │ │ │ │ +303 │ │ │ │ │ +304} │ │ │ │ │ +305 │ │ │ │ │ +306template │ │ │ │ │ +307int StandardMerge::bruteForceSearch(int │ │ │ │ │ +candidate1, │ │ │ │ │ +308 const std::vector >& grid1Coords, │ │ │ │ │ +309 const std::vector& grid1_element_types, │ │ │ │ │ +310 const std::vector >& grid2Coords, │ │ │ │ │ +311 const std::vector& grid2_element_types) │ │ │ │ │ +312{ │ │ │ │ │ +313 std::bitset<(1< neighborIntersects1; │ │ │ │ │ +314 std::bitset<(1< neighborIntersects2; │ │ │ │ │ +315 for (std::size_t i=0; i │ │ │ │ │ +333template │ │ │ │ │ +334void StandardMerge:: │ │ │ │ │ +335computeNeighborsPerElement(const std::vector& │ │ │ │ │ +gridElementTypes, │ │ │ │ │ +336 const std::vector >& gridElementCorners, │ │ │ │ │ +337 std::vector >& elementNeighbors) │ │ │ │ │ +338{ │ │ │ │ │ +339 typedef std::vector FaceType; │ │ │ │ │ +340 typedef std::map > │ │ │ │ │ +FaceSetType; │ │ │ │ │ +341 │ │ │ │ │ +343 // First: grid 1 │ │ │ │ │ +345 FaceSetType faces; │ │ │ │ │ +346 elementNeighbors.resize(gridElementTypes.size()); │ │ │ │ │ +347 │ │ │ │ │ +348 for (size_t i=0; i::general │ │ │ │ │ +(gridElementTypes[i]).size(1), -1); │ │ │ │ │ +350 │ │ │ │ │ +351 for (size_t i=0; i::general │ │ │ │ │ +(gridElementTypes[i]); │ │ │ │ │ +353 │ │ │ │ │ +354 for (size_t j=0; j<(size_t)refElement.size(1); j++) { // iterate over all │ │ │ │ │ +faces of the element │ │ │ │ │ +355 │ │ │ │ │ +356 FaceType face; │ │ │ │ │ +357 // extract element face │ │ │ │ │ +358 for (size_t k=0; k<(size_t)refElement.size(j,1,gridDim); k++) │ │ │ │ │ +359 face.push_back(gridElementCorners[i][refElement.subEntity(j,1,k,gridDim)]); │ │ │ │ │ +360 │ │ │ │ │ +361 // sort the face vertices to get rid of twists and other permutations │ │ │ │ │ +362 std::sort(face.begin(), face.end()); │ │ │ │ │ +363 │ │ │ │ │ +364 typename FaceSetType::iterator faceHandle = faces.find(face); │ │ │ │ │ +365 │ │ │ │ │ +366 if (faceHandle == faces.end()) { │ │ │ │ │ +367 │ │ │ │ │ +368 // face has not been visited before │ │ │ │ │ +369 faces.insert(std::make_pair(face, std::make_pair(i,j))); │ │ │ │ │ +370 │ │ │ │ │ +371 } else { │ │ │ │ │ +372 │ │ │ │ │ +373 // face has been visited before: store the mutual neighbor information │ │ │ │ │ +374 elementNeighbors[i][j] = faceHandle->second.first; │ │ │ │ │ +375 elementNeighbors[faceHandle->second.first][faceHandle->second.second] = i; │ │ │ │ │ +376 │ │ │ │ │ +377 faces.erase(faceHandle); │ │ │ │ │ +378 │ │ │ │ │ +379 } │ │ │ │ │ +380 │ │ │ │ │ +381 } │ │ │ │ │ +382 │ │ │ │ │ +383 } │ │ │ │ │ +384} │ │ │ │ │ +385 │ │ │ │ │ +386// ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +387// Compute the intersection of all pairs of elements │ │ │ │ │ +388// Linear algorithm by Gander and Japhet, Proc. of DD18 │ │ │ │ │ +389// ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +390 │ │ │ │ │ +391template │ │ │ │ │ +392void StandardMerge::build(const std:: │ │ │ │ │ +vector >& grid1Coords, │ │ │ │ │ +393 const std::vector& grid1_elements, │ │ │ │ │ +394 const std::vector& grid1_element_types, │ │ │ │ │ +395 const std::vector >& grid2Coords, │ │ │ │ │ +396 const std::vector& grid2_elements, │ │ │ │ │ +397 const std::vector& grid2_element_types │ │ │ │ │ +398 ) │ │ │ │ │ +399{ │ │ │ │ │ +400 │ │ │ │ │ +401 std::cout << "StandardMerge building merged grid..." << std::endl; │ │ │ │ │ +402 Dune::Timer watch; │ │ │ │ │ +403 │ │ │ │ │ +404 clear(); │ │ │ │ │ +405 // clear global intersection list │ │ │ │ │ +406 intersectionListProvider_->clear(); │ │ │ │ │ +407 this->counter = 0; │ │ │ │ │ +408 │ │ │ │ │ +409 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +410 // Copy element corners into a data structure with block-structure. │ │ │ │ │ +411 // This is not as efficient but a lot easier to use. │ │ │ │ │ +412 // We may think about efficiency later. │ │ │ │ │ +413 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +414 │ │ │ │ │ +415 // first the grid1 side │ │ │ │ │ +416 grid1ElementCorners_.resize(grid1_element_types.size()); │ │ │ │ │ +417 │ │ │ │ │ +418 unsigned int grid1CornerCounter = 0; │ │ │ │ │ +419 │ │ │ │ │ +420 for (std::size_t i=0; i::general(grid1_ │ │ │ │ │ +element_types[i]).size(grid1Dim); │ │ │ │ │ +424 grid1ElementCorners_[i].resize(numVertices); │ │ │ │ │ +425 for (int j=0; j::general(grid2_ │ │ │ │ │ +element_types[i]).size(grid2Dim); │ │ │ │ │ +439 grid2ElementCorners_[i].resize(numVertices); │ │ │ │ │ +440 for (int j=0; j(grid1_element_types, │ │ │ │ │ +grid1ElementCorners_, elementNeighbors1_); │ │ │ │ │ +450 computeNeighborsPerElement(grid2_element_types, │ │ │ │ │ +grid2ElementCorners_, elementNeighbors2_); │ │ │ │ │ +451 │ │ │ │ │ +452 std::cout << "setup took " << watch.elapsed() << " seconds." << std::endl; │ │ │ │ │ +453 │ │ │ │ │ +454 if (m_enableBruteForce) │ │ │ │ │ +455 buildBruteForce(grid1Coords, grid1_elements, grid1_element_types, │ │ │ │ │ +grid2Coords, grid2_elements, grid2_element_types); │ │ │ │ │ +456 else │ │ │ │ │ +457 buildAdvancingFront(grid1Coords, grid1_elements, grid1_element_types, │ │ │ │ │ +grid2Coords, grid2_elements, grid2_element_types); │ │ │ │ │ +458 │ │ │ │ │ +459 valid = true; │ │ │ │ │ +460 std::cout << "intersection construction took " << watch.elapsed() << " │ │ │ │ │ +seconds." << std::endl; │ │ │ │ │ +461} │ │ │ │ │ +462 │ │ │ │ │ +463template │ │ │ │ │ +464void StandardMerge::buildAdvancingFront( │ │ │ │ │ +465 const std::vector >& grid1Coords, │ │ │ │ │ +466 const std::vector& grid1_elements, │ │ │ │ │ +467 const std::vector& grid1_element_types, │ │ │ │ │ +468 const std::vector >& grid2Coords, │ │ │ │ │ +469 const std::vector& grid2_elements, │ │ │ │ │ +470 const std::vector& grid2_element_types │ │ │ │ │ +471 ) │ │ │ │ │ +472{ │ │ │ │ │ +474 // Data structures for the advancing-front algorithm │ │ │ │ │ +476 │ │ │ │ │ +477 std::stack candidates1; │ │ │ │ │ +478 std::stack candidates2; │ │ │ │ │ +479 │ │ │ │ │ +480 std::vector seeds(grid2_element_types.size(), -1); │ │ │ │ │ +481 │ │ │ │ │ +482 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +483 // Do a brute-force search to find one pair of intersecting elements │ │ │ │ │ +484 // to start the advancing-front type algorithm with. │ │ │ │ │ +485 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +486 │ │ │ │ │ +487 // Set flag if element has been handled │ │ │ │ │ +488 Dune::BitSetVector<1> isHandled2(grid2_element_types.size()); │ │ │ │ │ +489 │ │ │ │ │ +490 // Set flag if the element has been entered in the queue │ │ │ │ │ +491 Dune::BitSetVector<1> isCandidate2(grid2_element_types.size()); │ │ │ │ │ +492 │ │ │ │ │ +493 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_ │ │ │ │ │ +types, grid2Coords, grid2_element_types); │ │ │ │ │ +494 │ │ │ │ │ +495 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +496 // Main loop │ │ │ │ │ +497 // ///////////////////////////////////////////////////////////////////// │ │ │ │ │ +498 │ │ │ │ │ +499 std::set isHandled1; │ │ │ │ │ +500 │ │ │ │ │ +501 std::set isCandidate1; │ │ │ │ │ +502 │ │ │ │ │ +503 while (!candidates2.empty()) { │ │ │ │ │ +504 │ │ │ │ │ +505 // Get the next element on the grid2 side │ │ │ │ │ +506 unsigned int currentCandidate2 = candidates2.top(); │ │ │ │ │ +507 int seed = seeds[currentCandidate2]; │ │ │ │ │ +508 assert(seed >= 0); │ │ │ │ │ +509 │ │ │ │ │ +510 candidates2.pop(); │ │ │ │ │ +511 isHandled2[currentCandidate2] = true; │ │ │ │ │ +512 │ │ │ │ │ +513 // Start advancing front algorithm on the grid1 side from the 'seed' │ │ │ │ │ +element that │ │ │ │ │ +514 // we stored along with the current grid2 element │ │ │ │ │ +515 candidates1.push(seed); │ │ │ │ │ +516 │ │ │ │ │ +517 isHandled1.clear(); │ │ │ │ │ +518 isCandidate1.clear(); │ │ │ │ │ +519 │ │ │ │ │ +520 while (!candidates1.empty()) { │ │ │ │ │ +521 │ │ │ │ │ +522 unsigned int currentCandidate1 = candidates1.top(); │ │ │ │ │ +523 candidates1.pop(); │ │ │ │ │ +524 isHandled1.insert(currentCandidate1); │ │ │ │ │ +525 │ │ │ │ │ +526 // Test whether there is an intersection between currentCandidate0 and │ │ │ │ │ +currentCandidate1 │ │ │ │ │ +527 std::bitset<(1< neighborIntersects1; │ │ │ │ │ +528 std::bitset<(1< neighborIntersects2; │ │ │ │ │ +529 bool intersectionFound = computeIntersection(currentCandidate1, │ │ │ │ │ +currentCandidate2, │ │ │ │ │ +530 grid1Coords,grid1_element_types, neighborIntersects1, │ │ │ │ │ +531 grid2Coords,grid2_element_types, neighborIntersects2); │ │ │ │ │ +532 │ │ │ │ │ +533 for (size_t i=0; i-1) { │ │ │ │ │ +574 │ │ │ │ │ +575 isCandidate2[neighbor][0] = true; │ │ │ │ │ +576 candidates2.push(neighbor); │ │ │ │ │ +577 seedFound = true; │ │ │ │ │ +578 } │ │ │ │ │ +579 } │ │ │ │ │ +580 │ │ │ │ │ +581 if (seedFound || !m_enableFallback) │ │ │ │ │ +582 continue; │ │ │ │ │ +583 │ │ │ │ │ +584 // There is no neighbor with a seed, so we need to be a bit more │ │ │ │ │ +aggressive... │ │ │ │ │ +585 // get all neighbors of currentCandidate2, but not currentCandidate2 itself │ │ │ │ │ +586 for (size_t i=0; i::iterator seedIt = isHandled1.begin(); │ │ │ │ │ +601 seedIt != isHandled1.end(); ++seedIt) { │ │ │ │ │ +602 │ │ │ │ │ +603 std::bitset<(1< neighborIntersects1; │ │ │ │ │ +604 std::bitset<(1< neighborIntersects2; │ │ │ │ │ +605 bool intersectionFound = computeIntersection(*seedIt, neighbor, │ │ │ │ │ +606 grid1Coords, grid1_element_types, neighborIntersects1, │ │ │ │ │ +607 grid2Coords, grid2_element_types, neighborIntersects2, │ │ │ │ │ +608 false); │ │ │ │ │ +609 │ │ │ │ │ +610 // if the intersection is nonempty, *seedIt is our new seed candidate on │ │ │ │ │ +the grid1 side │ │ │ │ │ +611 if (intersectionFound) { │ │ │ │ │ +612 seed = *seedIt; │ │ │ │ │ +613 Dune::dwarn << "Algorithm entered first fallback method and found a new │ │ │ │ │ +seed in the build algorithm." << │ │ │ │ │ +614 "Probably, the neighborIntersects bitsets computed in computeIntersection │ │ │ │ │ +specialization is wrong." << std::endl; │ │ │ │ │ +615 break; │ │ │ │ │ +616 } │ │ │ │ │ +617 │ │ │ │ │ +618 } │ │ │ │ │ +619 │ │ │ │ │ +620 if (seed < 0) { │ │ │ │ │ +621 // The fast method didn't find a grid1 element that intersects with │ │ │ │ │ +622 // the new grid2 candidate. We have to do a brute-force search. │ │ │ │ │ +623 seed = bruteForceSearch(neighbor, │ │ │ │ │ +624 grid1Coords,grid1_element_types, │ │ │ │ │ +625 grid2Coords,grid2_element_types); │ │ │ │ │ +626 Dune::dwarn << "Algorithm entered second fallback method. This probably │ │ │ │ │ +should not happen." << std::endl; │ │ │ │ │ +627 │ │ │ │ │ +628 } │ │ │ │ │ +629 │ │ │ │ │ +630 // We have tried all we could: the candidate is 'handled' now │ │ │ │ │ +631 isCandidate2[neighbor] = true; │ │ │ │ │ +632 │ │ │ │ │ +633 // still no seed? Then the new grid2 candidate isn't overlapped by anything │ │ │ │ │ +634 if (seed < 0) │ │ │ │ │ +635 continue; │ │ │ │ │ +636 │ │ │ │ │ +637 // we have a seed now │ │ │ │ │ +638 candidates2.push(neighbor); │ │ │ │ │ +639 seeds[neighbor] = seed; │ │ │ │ │ +640 seedFound = true; │ │ │ │ │ +641 │ │ │ │ │ +642 } │ │ │ │ │ +643 │ │ │ │ │ +644 } │ │ │ │ │ +645 │ │ │ │ │ +646 /* Do a brute-force search if there is still no seed: │ │ │ │ │ +647 * There might still be a disconnected region out there. │ │ │ │ │ +648 */ │ │ │ │ │ +649 if (!seedFound && candidates2.empty()) { │ │ │ │ │ +650 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_ │ │ │ │ │ +types, grid2Coords, grid2_element_types); │ │ │ │ │ +651 } │ │ │ │ │ +652 } │ │ │ │ │ +653} │ │ │ │ │ +654 │ │ │ │ │ +655template │ │ │ │ │ +656void StandardMerge::buildBruteForce( │ │ │ │ │ +657 const std::vector >& grid1Coords, │ │ │ │ │ +658 const std::vector& grid1_elements, │ │ │ │ │ +659 const std::vector& grid1_element_types, │ │ │ │ │ +660 const std::vector >& grid2Coords, │ │ │ │ │ +661 const std::vector& grid2_elements, │ │ │ │ │ +662 const std::vector& grid2_element_types │ │ │ │ │ +663 ) │ │ │ │ │ +664{ │ │ │ │ │ +665 std::bitset<(1< neighborIntersects1; │ │ │ │ │ +666 std::bitset<(1< neighborIntersects2; │ │ │ │ │ +667 │ │ │ │ │ +668 for (unsigned i = 0; i < grid1_element_types.size(); ++i) { │ │ │ │ │ +669 for (unsigned j = 0; j < grid2_element_types.size(); ++j) { │ │ │ │ │ +670 (void) computeIntersection(i, j, │ │ │ │ │ +671 grid1Coords, grid1_element_types, neighborIntersects1, │ │ │ │ │ +672 grid2Coords, grid2_element_types, neighborIntersects2); │ │ │ │ │ +673 } │ │ │ │ │ +674 } │ │ │ │ │ +675} │ │ │ │ │ +676 │ │ │ │ │ +677template │ │ │ │ │ +678void StandardMerge::generateSeed(std:: │ │ │ │ │ +vector& seeds, Dune::BitSetVector<1>& isHandled2, std::stack& │ │ │ │ │ +candidates2, const std::vector >& grid1Coords, │ │ │ │ │ +const std::vector& grid1_element_types, const std:: │ │ │ │ │ +vector >& grid2Coords, const std::vector& grid2_element_types) │ │ │ │ │ +679{ │ │ │ │ │ +680 for (std::size_t j=0; j 0 || isHandled2[j][0]) │ │ │ │ │ +683 continue; │ │ │ │ │ +684 │ │ │ │ │ +685 int seed = bruteForceSearch(j,grid1Coords,grid1_element_ │ │ │ │ │ +types,grid2Coords,grid2_element_types); │ │ │ │ │ +686 │ │ │ │ │ +687 if (seed >= 0) { │ │ │ │ │ +688 candidates2.push(j); // the candidate and a seed for the candidate │ │ │ │ │ +689 seeds[j] = seed; │ │ │ │ │ +690 break; │ │ │ │ │ +691 } else // If the brute force search did not find any intersection we can │ │ │ │ │ +skip this element │ │ │ │ │ +692 isHandled2[j] = true; │ │ │ │ │ +693 } │ │ │ │ │ +694} │ │ │ │ │ +695 │ │ │ │ │ +696template │ │ │ │ │ +697int StandardMerge::insertIntersections │ │ │ │ │ +(unsigned int candidate1, unsigned int candidate2, │ │ │ │ │ +698 std::vector& intersections) │ │ │ │ │ +699{ │ │ │ │ │ +700 typedef typename std::vector::size_type size_t; │ │ │ │ │ +701 int count = 0; │ │ │ │ │ +702 │ │ │ │ │ +703 for (size_t i = 0; i < intersections.size(); ++i) { │ │ │ │ │ +704 // get the intersection index of the current intersection from │ │ │ │ │ +intersections in this->intersections │ │ │ │ │ +705 bool found; │ │ │ │ │ +706 unsigned int index; │ │ │ │ │ +707 std::tie(found, index) = intersectionIndex │ │ │ │ │ +(candidate1,candidate2,intersections[i]); │ │ │ │ │ +708 │ │ │ │ │ +709 if (found && index >= this->intersections().size()) { //the intersection is │ │ │ │ │ +not yet contained in this->intersections │ │ │ │ │ +710 this->intersections().push_back(intersections[i]); // insert │ │ │ │ │ +711 │ │ │ │ │ +712 ++count; │ │ │ │ │ +713 } else if (found) { │ │ │ │ │ +714 auto& intersection = this->intersections()[index]; │ │ │ │ │ +715 │ │ │ │ │ +716 // insert each grid1 element and local representation of intersections[i] │ │ │ │ │ +with parent candidate1 │ │ │ │ │ +717 for (size_t j = 0; j < intersections[i].parents0.size(); ++j) { │ │ │ │ │ +718 intersection.parents0.push_back(candidate1); │ │ │ │ │ +719 intersection.corners0.push_back(intersections[i].corners0[j]); │ │ │ │ │ +720 } │ │ │ │ │ +721 │ │ │ │ │ +722 // insert each grid2 element and local representation of intersections[i] │ │ │ │ │ +with parent candidate2 │ │ │ │ │ +723 for (size_t j = 0; j < intersections[i].parents1.size(); ++j) { │ │ │ │ │ +724 intersection.parents1.push_back(candidate2); │ │ │ │ │ +725 intersection.corners1.push_back(intersections[i].corners1[j]); │ │ │ │ │ +726 } │ │ │ │ │ +727 │ │ │ │ │ +728 ++count; │ │ │ │ │ +729 } else { │ │ │ │ │ +730 Dune::dwarn << "Computed the same intersection twice!" << std::endl; │ │ │ │ │ +731 } │ │ │ │ │ +732 } │ │ │ │ │ +733 return count; │ │ │ │ │ +734} │ │ │ │ │ +735 │ │ │ │ │ +736template │ │ │ │ │ +737std::pair │ │ │ │ │ +738StandardMerge::intersectionIndex(unsigned int │ │ │ │ │ +grid1Index, unsigned int grid2Index, │ │ │ │ │ +739 SimplicialIntersection& intersection) { │ │ │ │ │ +740 │ │ │ │ │ +741 │ │ │ │ │ +742 // return index in intersections_ if at least one local representation of a │ │ │ │ │ +Simplicial Intersection (SI) │ │ │ │ │ +743 // of intersections_ is equal to the local representation of one element in │ │ │ │ │ +intersections │ │ │ │ │ +744 │ │ │ │ │ +745 std::size_t n_intersections = this->intersections().size(); │ │ │ │ │ +746 if (grid1Dim == grid2Dim) │ │ │ │ │ +747 return {true, n_intersections}; │ │ │ │ │ +748 │ │ │ │ │ +749 T eps = 1e-10; │ │ │ │ │ +750 │ │ │ │ │ +751 for (std::size_t i = 0; i < n_intersections; ++i) { │ │ │ │ │ +752 │ │ │ │ │ +753 // compare the local representation of the subelements of the SI │ │ │ │ │ +754 for (std::size_t ei = 0; ei < this->intersections()[i].parents0.size(); │ │ │ │ │ +++ei) // merger subelement │ │ │ │ │ +755 { │ │ │ │ │ +756 if (this->intersections()[i].parents0[ei] == grid1Index) │ │ │ │ │ +757 { │ │ │ │ │ +758 for (std::size_t er = 0; er < intersection.parents0.size(); ++er) // list │ │ │ │ │ +subelement │ │ │ │ │ +759 { │ │ │ │ │ +760 bool found_all = true; │ │ │ │ │ +761 // compare the local coordinate representations │ │ │ │ │ +762 for (std::size_t ci = 0; ci < this->intersections()[i].corners0[ei].size(); │ │ │ │ │ +++ci) │ │ │ │ │ +763 { │ │ │ │ │ +764 Dune::FieldVector ni = this->intersections()[i].corners0[ei] │ │ │ │ │ +[ci]; │ │ │ │ │ +765 bool found_ni = false; │ │ │ │ │ +766 for (std::size_t cr = 0; cr < intersection.corners0[er].size(); ++cr) │ │ │ │ │ +767 { │ │ │ │ │ +768 Dune::FieldVector nr = intersection.corners0[er][cr]; │ │ │ │ │ +769 │ │ │ │ │ +770 found_ni = found_ni || ((ni-nr).infinity_norm() < eps); │ │ │ │ │ +771 if (found_ni) │ │ │ │ │ +772 break; │ │ │ │ │ +773 } │ │ │ │ │ +774 found_all = found_all && found_ni; │ │ │ │ │ +775 │ │ │ │ │ +776 if (!found_ni) │ │ │ │ │ +777 break; │ │ │ │ │ +778 } │ │ │ │ │ +779 │ │ │ │ │ +780 if (found_all && (this->intersections()[i].parents1[ei] != grid2Index)) │ │ │ │ │ +781 return {true, i}; │ │ │ │ │ +782 else if (found_all) │ │ │ │ │ +783 return {false, 0}; │ │ │ │ │ +784 } │ │ │ │ │ +785 } │ │ │ │ │ +786 } │ │ │ │ │ +787 │ │ │ │ │ +788 // compare the local representation of the subelements of the SI │ │ │ │ │ +789 for (std::size_t ei = 0; ei < this->intersections()[i].parents1.size(); │ │ │ │ │ +++ei) // merger subelement │ │ │ │ │ +790 { │ │ │ │ │ +791 if (this->intersections()[i].parents1[ei] == grid2Index) │ │ │ │ │ +792 { │ │ │ │ │ +793 for (std::size_t er = 0; er < intersection.parents1.size(); ++er) // list │ │ │ │ │ +subelement │ │ │ │ │ +794 { │ │ │ │ │ +795 bool found_all = true; │ │ │ │ │ +796 // compare the local coordinate representations │ │ │ │ │ +797 for (std::size_t ci = 0; ci < this->intersections()[i].corners1[ei].size(); │ │ │ │ │ +++ci) │ │ │ │ │ +798 { │ │ │ │ │ +799 Dune::FieldVector ni = this->intersections()[i].corners1[ei] │ │ │ │ │ +[ci]; │ │ │ │ │ +800 bool found_ni = false; │ │ │ │ │ +801 for (std::size_t cr = 0; cr < intersection.corners1[er].size(); ++cr) │ │ │ │ │ +802 { │ │ │ │ │ +803 Dune::FieldVector nr = intersection.corners1[er][cr]; │ │ │ │ │ +804 found_ni = found_ni || ((ni-nr).infinity_norm() < eps); │ │ │ │ │ +805 │ │ │ │ │ +806 if (found_ni) │ │ │ │ │ +807 break; │ │ │ │ │ +808 } │ │ │ │ │ +809 found_all = found_all && found_ni; │ │ │ │ │ +810 │ │ │ │ │ +811 if (!found_ni) │ │ │ │ │ +812 break; │ │ │ │ │ +813 } │ │ │ │ │ +814 │ │ │ │ │ +815 if (found_all && (this->intersections()[i].parents0[ei] != grid1Index)) │ │ │ │ │ +816 return {true, i}; │ │ │ │ │ +817 else if (found_all) │ │ │ │ │ +818 return {false, 0}; │ │ │ │ │ +819 } │ │ │ │ │ +820 } │ │ │ │ │ +821 } │ │ │ │ │ +822 } │ │ │ │ │ +823 │ │ │ │ │ +824 return {true, n_intersections}; │ │ │ │ │ +825} │ │ │ │ │ +826 │ │ │ │ │ +827#define DECL extern │ │ │ │ │ +828#define STANDARD_MERGE_INSTANTIATE(T,A,B,C) \ │ │ │ │ │ +829 DECL template \ │ │ │ │ │ +830 void StandardMerge::build(const std::vector │ │ │ │ │ +>& grid1Coords, \ │ │ │ │ │ +831 const std::vector& grid1_elements, \ │ │ │ │ │ +832 const std::vector& grid1_element_types, \ │ │ │ │ │ +833 const std::vector >& grid2Coords, \ │ │ │ │ │ +834 const std::vector& grid2_elements, \ │ │ │ │ │ +835 const std::vector& grid2_element_types \ │ │ │ │ │ +836 ) │ │ │ │ │ +837 │ │ │ │ │ +838STANDARD_MERGE_INSTANTIATE(double,1,1,1); │ │ │ │ │ +839STANDARD_MERGE_INSTANTIATE(double,2,2,2); │ │ │ │ │ +840STANDARD_MERGE_INSTANTIATE(double,3,3,3); │ │ │ │ │ +841#undef STANDARD_MERGE_INSTANTIATE │ │ │ │ │ +842#undef DECL │ │ │ │ │ +843 │ │ │ │ │ +844} /* namespace GridGlue */ │ │ │ │ │ +845} /* namespace Dune */ │ │ │ │ │ +846 │ │ │ │ │ +847#endif // DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH │ │ │ │ │ +STANDARD_MERGE_INSTANTIATE │ │ │ │ │ +#define STANDARD_MERGE_INSTANTIATE(T, A, B, C) │ │ │ │ │ +Definition standardmerge.cc:13 │ │ │ │ │ +merger.hh │ │ │ │ │ +intersectionlist.hh │ │ │ │ │ computeintersection.hh │ │ │ │ │ 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::GridGlue::intersections │ │ │ │ │ +IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ +> &reverse=!reversed) │ │ │ │ │ +Iterate over all intersections of a GridGlue. │ │ │ │ │ +Dune::GridGlue::SimplicialIntersectionListProvider │ │ │ │ │ +Definition intersectionlist.hh:207 │ │ │ │ │ +Dune::GridGlue::SimplicialIntersectionListProvider::SimplicialIntersection │ │ │ │ │ +Definition intersectionlist.hh:222 │ │ │ │ │ +Dune::GridGlue::Merger │ │ │ │ │ +Abstract base for all classes that take extracted grids and build sets of │ │ │ │ │ +intersections. │ │ │ │ │ +Definition merger.hh:27 │ │ │ │ │ +Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::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 │ │ │ │ │ +Definition merger.hh:37 │ │ │ │ │ +Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::IntersectionList │ │ │ │ │ +Dune::GridGlue::IntersectionList< Grid1Coords, Grid2Coords > IntersectionList │ │ │ │ │ +Definition merger.hh:39 │ │ │ │ │ +Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::Grid1Coords │ │ │ │ │ +Dune::FieldVector< T, grid1Dim > Grid1Coords │ │ │ │ │ +the local coordinate type for the grid1 coordinates │ │ │ │ │ +Definition merger.hh:31 │ │ │ │ │ +Dune::GridGlue::Merger<_T,_grid1Dim,_grid2Dim,_dimworld_>::Grid2Coords │ │ │ │ │ +Dune::FieldVector< T, grid2Dim > Grid2Coords │ │ │ │ │ +the local coordinate type for the grid2 coordinates │ │ │ │ │ +Definition merger.hh:34 │ │ │ │ │ Dune::GridGlue::StandardMerge │ │ │ │ │ Common base class for many merger implementations: produce pairs of entities │ │ │ │ │ that may intersect. │ │ │ │ │ Definition standardmerge.hh:58 │ │ │ │ │ +Dune::GridGlue::StandardMerge::computeIntersections │ │ │ │ │ +virtual void computeIntersections(const Dune::GeometryType &grid1ElementType, │ │ │ │ │ +const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, │ │ │ │ │ +std::bitset<(1<< grid1Dim)> &neighborIntersects1, unsigned int grid1Index, │ │ │ │ │ +const Dune::GeometryType &grid2ElementType, const std::vector< Dune:: │ │ │ │ │ +FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< grid2Dim)> │ │ │ │ │ +&neighborIntersects2, unsigned int grid2Index, std::vector< │ │ │ │ │ +SimplicialIntersection > &intersections)=0 │ │ │ │ │ +Compute the intersection between two overlapping elements. │ │ │ │ │ +Dune::GridGlue::StandardMerge::intersectionList_ │ │ │ │ │ +std::shared_ptr< IntersectionList > intersectionList_ │ │ │ │ │ +Definition standardmerge.hh:124 │ │ │ │ │ +Dune::GridGlue::StandardMerge::Grid1Coords │ │ │ │ │ +typename Base::Grid1Coords Grid1Coords │ │ │ │ │ +Type used for local coordinates on the grid1 side. │ │ │ │ │ +Definition standardmerge.hh:69 │ │ │ │ │ +Dune::GridGlue::StandardMerge::enableFallback │ │ │ │ │ +void enableFallback(bool fallback) │ │ │ │ │ +Definition standardmerge.hh:166 │ │ │ │ │ +Dune::GridGlue::StandardMerge::elementNeighbors2_ │ │ │ │ │ +std::vector< std::vector< int > > elementNeighbors2_ │ │ │ │ │ +Definition standardmerge.hh:131 │ │ │ │ │ +Dune::GridGlue::StandardMerge::elementNeighbors1_ │ │ │ │ │ +std::vector< std::vector< int > > elementNeighbors1_ │ │ │ │ │ +Definition standardmerge.hh:130 │ │ │ │ │ +Dune::GridGlue::StandardMerge::ctype │ │ │ │ │ +T ctype │ │ │ │ │ +the numeric type used in this interface │ │ │ │ │ +Definition standardmerge.hh:66 │ │ │ │ │ +Dune::GridGlue::StandardMerge::clear │ │ │ │ │ +void clear() override │ │ │ │ │ +Definition standardmerge.hh:150 │ │ │ │ │ +Dune::GridGlue::StandardMerge::IntersectionList │ │ │ │ │ +typename Base::IntersectionList IntersectionList │ │ │ │ │ +Definition standardmerge.hh:77 │ │ │ │ │ +Dune::GridGlue::StandardMerge::computeIntersection │ │ │ │ │ +bool computeIntersection(unsigned int candidate0, unsigned int candidate1, │ │ │ │ │ +const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std:: │ │ │ │ │ +vector< Dune::GeometryType > &grid1_element_types, std::bitset<(1<< grid1Dim)> │ │ │ │ │ +&neighborIntersects1, const std::vector< Dune::FieldVector< T, dimworld > > │ │ │ │ │ +&grid2Coords, const std::vector< Dune::GeometryType > &grid2_element_types, │ │ │ │ │ +std::bitset<(1<< grid2Dim)> &neighborIntersects2, bool insert=true) │ │ │ │ │ +Compute the intersection between two overlapping elements. │ │ │ │ │ +Definition standardmerge.hh:263 │ │ │ │ │ +Dune::GridGlue::StandardMerge::enableBruteForce │ │ │ │ │ +void enableBruteForce(bool bruteForce) │ │ │ │ │ +Definition standardmerge.hh:171 │ │ │ │ │ +Dune::GridGlue::StandardMerge::intersectionListProvider_ │ │ │ │ │ +std::shared_ptr< IntersectionListProvider > intersectionListProvider_ │ │ │ │ │ +Definition standardmerge.hh:123 │ │ │ │ │ +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 standardmerge.hh:392 │ │ │ │ │ +Dune::GridGlue::StandardMerge::grid1ElementCorners_ │ │ │ │ │ +std::vector< std::vector< unsigned int > > grid1ElementCorners_ │ │ │ │ │ +Temporary internal data. │ │ │ │ │ +Definition standardmerge.hh:127 │ │ │ │ │ +Dune::GridGlue::StandardMerge::grid2ElementCorners_ │ │ │ │ │ +std::vector< std::vector< unsigned int > > grid2ElementCorners_ │ │ │ │ │ +Definition standardmerge.hh:128 │ │ │ │ │ +Dune::GridGlue::StandardMerge::Grid2Coords │ │ │ │ │ +typename Base::Grid2Coords Grid2Coords │ │ │ │ │ +Type used for local coordinates on the grid2 side. │ │ │ │ │ +Definition standardmerge.hh:72 │ │ │ │ │ +Dune::GridGlue::StandardMerge::intersectionList │ │ │ │ │ +std::shared_ptr< IntersectionList > intersectionList() const final │ │ │ │ │ +Definition standardmerge.hh:160 │ │ │ │ │ +Dune::GridGlue::StandardMerge::~StandardMerge │ │ │ │ │ +virtual ~StandardMerge()=default │ │ │ │ │ +Dune::GridGlue::StandardMerge::RemoteSimplicialIntersection │ │ │ │ │ +SimplicialIntersection RemoteSimplicialIntersection │ │ │ │ │ +Definition standardmerge.hh:84 │ │ │ │ │ +Dune::GridGlue::StandardMerge::valid │ │ │ │ │ +bool valid │ │ │ │ │ +Definition standardmerge.hh:86 │ │ │ │ │ +Dune::GridGlue::StandardMerge::StandardMerge │ │ │ │ │ +StandardMerge() │ │ │ │ │ +Definition standardmerge.hh:88 │ │ │ │ │ Dune::GridGlue::StandardMerge::SimplicialIntersection │ │ │ │ │ typename IntersectionListProvider::SimplicialIntersection │ │ │ │ │ SimplicialIntersection │ │ │ │ │ Definition standardmerge.hh:83 │ │ │ │ │ +Dune::GridGlue::StandardMerge::WorldCoords │ │ │ │ │ +typename Base::WorldCoords WorldCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition standardmerge.hh:75 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.hh File Reference │ │ │ │ +dune-grid-glue: contactmerge.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,47 +70,29 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ -
computeintersection.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
contactmerge.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <dune/common/fvector.hh>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ -#include "simplexintersection.cc"
│ │ │ │ -#include "computeintersection.cc"
│ │ │ │ +
#include <dune/grid-glue/common/crossproduct.hh>
│ │ │ │ +#include <dune/grid-glue/common/projection.hh>
│ │ │ │
│ │ │ │

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...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

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

│ │ │ │ -Functions

template<class V >
int Dune::GridGlue::insertPoint (const V p, std::vector< V > &P)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,32 +1,19 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -computeintersection.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include "simplexintersection.cc" │ │ │ │ │ -#include "computeintersection.cc" │ │ │ │ │ +Namespaces │ │ │ │ │ +contactmerge.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ 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... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   │ │ │ │ │ namespace   Dune::GridGlue │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -int  Dune::GridGlue::insertPoint (const V p, std::vector< V > &P) │ │ │ │ │ -  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00098_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-grid-glue: computeintersection.hh Source File │ │ │ │ +dune-grid-glue: contactmerge.cc Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,190 +74,389 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
computeintersection.hh
│ │ │ │ +
contactmerge.cc
│ │ │ │
│ │ │ │
│ │ │ │ -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
│ │ │ │ +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
│ │ │ │ -
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);
│ │ │ │ +
12template<int dimworld, typename T>
│ │ │ │ +
13void ContactMerge<dimworld, T>::computeIntersections(const Dune::GeometryType& grid1ElementType,
│ │ │ │ +
14 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
│ │ │ │ +
15 std::bitset<(1<<dim)>& neighborIntersects1,
│ │ │ │ +
16 unsigned int grid1Index,
│ │ │ │ +
17 const Dune::GeometryType& grid2ElementType,
│ │ │ │ +
18 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
│ │ │ │ +
19 std::bitset<(1<<dim)>& neighborIntersects2,
│ │ │ │ +
20 unsigned int grid2Index,
│ │ │ │ +
21 std::vector<SimplicialIntersection>& intersections)
│ │ │ │ +
22{
│ │ │ │ +
23 using std::get;
│ │ │ │ +
24
│ │ │ │ +
25 std::vector<std::array<LocalCoords,2> > polytopeCorners;
│ │ │ │ +
26
│ │ │ │ +
27 // Initialize
│ │ │ │ +
28 neighborIntersects1.reset();
│ │ │ │ +
29 neighborIntersects2.reset();
│ │ │ │ +
30
│ │ │ │ +
31 const int nCorners1 = grid1ElementCorners.size();
│ │ │ │ +
32 const int nCorners2 = grid2ElementCorners.size();
│ │ │ │ +
33
│ │ │ │ +
34 if (nCorners1 != dimworld)
│ │ │ │ +
35 DUNE_THROW(Dune::Exception, "element1 must have " << dimworld << " corners, but has " << nCorners1);
│ │ │ │ +
36 if (nCorners2 != dimworld)
│ │ │ │ +
37 DUNE_THROW(Dune::Exception, "element2 must have " << dimworld << " corners, but has " << nCorners2);
│ │ │ │ +
38
│ │ │ │ +
39 // The grid1 projection directions
│ │ │ │ +
40 std::vector<WorldCoords> directions1(nCorners1);
│ │ │ │ +
41 for (size_t i=0; i<directions1.size(); i++)
│ │ │ │ +
42 directions1[i] = nodalDomainDirections_[this->grid1ElementCorners_[grid1Index][i]];
│ │ │ │ +
43
│ │ │ │ +
44 // The grid2 projection directions
│ │ │ │ +
45 std::vector<WorldCoords> directions2(nCorners2);
│ │ │ │ +
46 for (size_t i=0; i<directions2.size(); i++)
│ │ │ │ +
47 directions2[i] = nodalTargetDirections_[this->grid2ElementCorners_[grid2Index][i]];
│ │ │ │ +
48
│ │ │ │ +
49 // The difference between the closest point projection and the normal projection is just the ordering
│ │ │ │ +
50 // of the involved surfaces. The closest point projection is done along the outer normal field of grid2
│ │ │ │ +
51 // (due to being a best approximation) and the outer normal projection is using the outer normal field
│ │ │ │ +
52 // of grid1 instead.
│ │ │ │ +
53 std::array<decltype(std::cref(grid1ElementCorners)),2> cornersRef ={std::cref(grid1ElementCorners), std::cref(grid2ElementCorners)};
│ │ │ │ +
54 std::array<decltype(std::cref(directions1)),2> directionsRef ={std::cref(directions1), std::cref(directions2)};
│ │ │ │ +
55 std::array<Dune::GeometryType,2> elementTypes = {grid1ElementType, grid2ElementType};
│ │ │ │ +
56
│ │ │ │ +
57 // Determine which is the grid we use for outer normal projection
│ │ │ │ +
58 const size_t domGrid = (type_==ProjectionType::OUTER_NORMAL) ? 0 : 1;
│ │ │ │ +
59 const size_t tarGrid = (type_==ProjectionType::OUTER_NORMAL) ? 1 : 0;
│ │ │ │ +
60
│ │ │ │ +
62 // Compute all corners of the intersection polytope
│ │ │ │
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};
│ │ │ │ -
│ │ │ │ +
65 const auto corners = std::tie(cornersRef[domGrid].get(),cornersRef[tarGrid].get());
│ │ │ │ +
66 const auto normals = std::tie(directionsRef[domGrid].get(), directionsRef[tarGrid].get());
│ │ │ │ +
67 Projection<WorldCoords> p(overlap_, maxNormalProduct_);
│ │ │ │ +
68 p.project(corners, normals);
│ │ │ │ +
69
│ │ │ │ +
70 /* projection */
│ │ │ │ +
71 {
│ │ │ │ +
72 const auto& success = get<0>(p.success());
│ │ │ │ +
73 const auto& images = get<0>(p.images());
│ │ │ │ +
74 for (unsigned i = 0; i < dimworld; ++i) {
│ │ │ │ +
75 if (success[i]) {
│ │ │ │ +
76 std::array<LocalCoords, 2> corner;
│ │ │ │ +
77 corner[domGrid] = localCornerCoords(i, elementTypes[domGrid]);
│ │ │ │ +
78 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ +
79 corner[tarGrid][j] = images[i][j];
│ │ │ │ +
80 polytopeCorners.push_back(corner);
│ │ │ │ +
81 }
│ │ │ │ +
82 }
│ │ │ │ +
83 }
│ │ │ │ +
84
│ │ │ │ +
85 /* inverse projection */
│ │ │ │ +
86 {
│ │ │ │ +
87 const auto& success = get<1>(p.success());
│ │ │ │ +
88 const auto& preimages = get<1>(p.images());
│ │ │ │ +
89 for (unsigned i = 0; i < dimworld; ++i) {
│ │ │ │ +
90 if (success[i]) {
│ │ │ │ +
91 std::array<LocalCoords, 2> corner;
│ │ │ │ +
92 for (unsigned j = 0; j < dim; ++j)
│ │ │ │ +
93 corner[domGrid][j] = preimages[i][j];
│ │ │ │ +
94 corner[tarGrid] = localCornerCoords(i, elementTypes[tarGrid]);
│ │ │ │ +
95 polytopeCorners.push_back(corner);
│ │ │ │ +
96 }
│ │ │ │ +
97 }
│ │ │ │ +
98 }
│ │ │ │ +
99
│ │ │ │ +
100 /* edge intersections */
│ │ │ │ +
101 {
│ │ │ │ +
102 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) {
│ │ │ │ +
103 std::array<LocalCoords, 2> corner;
│ │ │ │ +
104 const auto& local = p.edgeIntersections()[i].local;
│ │ │ │ +
105 for (unsigned j = 0; j < dim; ++j) {
│ │ │ │ +
106 corner[domGrid][j] = local[0][j];
│ │ │ │ +
107 corner[tarGrid][j] = local[1][j];
│ │ │ │ +
108 }
│ │ │ │ +
109 polytopeCorners.push_back(corner);
│ │ │ │ +
110 }
│ │ │ │ +
111 }
│ │ │ │ +
112
│ │ │ │ +
113 // check which neighbors might also intersect
│ │ │ │ +
114 std::array<decltype(std::ref(neighborIntersects1)),2> neighborIntersectsRef = {std::ref(neighborIntersects1), std::ref(neighborIntersects2)};
│ │ │ │ +
115 const auto& refTar = Dune::ReferenceElements<T,dim>::general(elementTypes[tarGrid]);
│ │ │ │ +
116 for (int i=0; i<refTar.size(1); i++) {
│ │ │ │ +
117
│ │ │ │ +
118 // if all face corners hit the other element then
│ │ │ │ +
119 // the neighbor might also intersect
│ │ │ │ +
120
│ │ │ │ +
121 bool intersects(true);
│ │ │ │ +
122 for (int k=0; k<refTar.size(i,1,dim); k++)
│ │ │ │ +
123 intersects &= get<1>(p.success())[refTar.subEntity(i,1,k,dim)];
│ │ │ │ +
124
│ │ │ │ +
125 if (intersects)
│ │ │ │ +
126 neighborIntersectsRef[tarGrid].get()[i] = true;
│ │ │ │ +
127 }
│ │ │ │ +
128
│ │ │ │ +
129 const auto& refDom = Dune::ReferenceElements<T,dim>::general(elementTypes[domGrid]);
│ │ │ │ +
130 for (int i=0; i<refDom.size(1); i++) {
│ │ │ │ +
131
│ │ │ │ +
132 // if all face corners hit the other element then
│ │ │ │ +
133 // the neighbor might also intersect
│ │ │ │ +
134
│ │ │ │ +
135 bool intersects(true);
│ │ │ │ +
136 for (int k=0; k<refDom.size(i,1,dim); k++)
│ │ │ │ +
137 intersects &= get<0>(p.success())[refDom.subEntity(i,1,k,dim)];
│ │ │ │ +
138
│ │ │ │ +
139 if (intersects)
│ │ │ │ +
140 neighborIntersectsRef[domGrid].get()[i] = true;
│ │ │ │ +
141 }
│ │ │ │ +
142
│ │ │ │ +
143 // Compute the edge intersections
│ │ │ │ +
144 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) {
│ │ │ │ +
145 const auto& edge = p.edgeIntersections()[i].edge;
│ │ │ │ +
146 neighborIntersects1[edge[domGrid]] = true;
│ │ │ │ +
147 neighborIntersects2[edge[tarGrid]] = true;
│ │ │ │ +
148 }
│ │ │ │ +
149
│ │ │ │ +
150 // remove possible doubles
│ │ │ │ +
151 removeDoubles(polytopeCorners);
│ │ │ │ +
152
│ │ │ │ +
153 // Compute an interior point of the polytope
│ │ │ │ +
154 int nPolyCorners = polytopeCorners.size();
│ │ │ │ +
155
│ │ │ │ +
156 // If the polytope is degenerated then there is no intersection
│ │ │ │ +
157 if (nPolyCorners<dimworld)
│ │ │ │ +
158 return;
│ │ │ │ +
159
│ │ │ │ +
160 // If the polytope is a simplex return it
│ │ │ │ +
161 if (nPolyCorners==dim+1) {
│ │ │ │
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
│ │ │ │ +
163 // std::cout<<"Add intersection: 1\n";
│ │ │ │ +
164 typename Base::SimplicialIntersection intersect(grid1Index, grid2Index);
│ │ │ │ +
165
│ │ │ │ +
166 for (int j=0;j<dim+1; j++) {
│ │ │ │ +
167 intersect.corners0[0][j]=polytopeCorners[j][0];
│ │ │ │ +
168 intersect.corners1[0][j]=polytopeCorners[j][1];
│ │ │ │ +
169 }
│ │ │ │ +
170 intersections.push_back(intersect);
│ │ │ │ +
171
│ │ │ │ +
172 return;
│ │ │ │ +
173 }
│ │ │ │ +
174
│ │ │ │ +
175 // At this point we must have dimworld>=3
│ │ │ │ +
176
│ │ │ │ +
178 // Compute a point in the middle of the polytope and order all corners cyclic
│ │ │ │
180
│ │ │ │ -
181 }
│ │ │ │ -
182 else
│ │ │ │ -
183 P.push_back(p);
│ │ │ │ -
184
│ │ │ │ -
185 return k ;
│ │ │ │ -
186}
│ │ │ │ -
│ │ │ │ +
181 std::array<LocalCoords,2> center;
│ │ │ │ +
182 center[0] = 0; center[1] = 0;
│ │ │ │ +
183 for (int i=0; i<nPolyCorners; i++) {
│ │ │ │ +
184 center[0].axpy(1.0/nPolyCorners,polytopeCorners[i][0]);
│ │ │ │ +
185 center[1].axpy(1.0/nPolyCorners,polytopeCorners[i][1]);
│ │ │ │ +
186 }
│ │ │ │
187
│ │ │ │ -
188
│ │ │ │ -
189} /* namespace Dune::GridGlue */
│ │ │ │ -
190} /* namespace Dune */
│ │ │ │ +
188 // Order cyclic
│ │ │ │ +
189 std::vector<int> ordering;
│ │ │ │ +
190 computeCyclicOrder(polytopeCorners,center[0],ordering);
│ │ │ │
191
│ │ │ │ -
192#include "simplexintersection.cc"
│ │ │ │ -
193#include "computeintersection.cc"
│ │ │ │ -
194
│ │ │ │ -
195#endif
│ │ │ │ - │ │ │ │ - │ │ │ │ +
193 // Add intersections
│ │ │ │ +
195
│ │ │ │ +
196 for (size_t i=1; i<polytopeCorners.size()-1; i++) {
│ │ │ │ +
197
│ │ │ │ +
198 typename Base::SimplicialIntersection intersect(grid1Index, grid2Index);
│ │ │ │ +
199
│ │ │ │ +
200 for (int j=0;j<dim; j++) {
│ │ │ │ +
201 intersect.corners0[0][j]=polytopeCorners[ordering[i+j]][0];
│ │ │ │ +
202 intersect.corners1[0][j]=polytopeCorners[ordering[i+j]][1];
│ │ │ │ +
203 }
│ │ │ │ +
204
│ │ │ │ +
205 // last corner is the first for all intersections
│ │ │ │ +
206 intersect.corners0[0][dim]=polytopeCorners[ordering[0]][0];
│ │ │ │ +
207 intersect.corners1[0][dim]=polytopeCorners[ordering[0]][1];
│ │ │ │ +
208
│ │ │ │ +
209 intersections.push_back(intersect);
│ │ │ │ +
210 }
│ │ │ │ +
211}
│ │ │ │ +
212
│ │ │ │ +
213template<int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
214void ContactMerge<dimworld, T>::computeCyclicOrder(const std::vector<std::array<LocalCoords,2> >& polytopeCorners,
│ │ │ │ +
215 const LocalCoords& center, std::vector<int>& ordering) const
│ │ │ │ +
216{
│ │ │ │ +
217 ordering.resize(polytopeCorners.size());
│ │ │ │ +
218
│ │ │ │ +
219 for (size_t k=0; k<ordering.size(); k++)
│ │ │ │ +
220 ordering[k] = k;
│ │ │ │ +
221
│ │ │ │ +
222 //TODO Do I have to order triangles to get some correct orientation?
│ │ │ │ +
223 if (polytopeCorners.size()<=3)
│ │ │ │ +
224 return;
│ │ │ │ +
225
│ │ │ │ +
226 // compute angles inside the polygon plane w.r.t to this axis
│ │ │ │ +
227 LocalCoords edge0 = polytopeCorners[1][0] - polytopeCorners[0][0];
│ │ │ │ +
228
│ │ │ │ +
229 // Compute a vector that is perpendicular to the edge but lies in the polytope plane
│ │ │ │ +
230 // So we have a unique ordering
│ │ │ │ +
231 LocalCoords edge1 = polytopeCorners[2][0] - polytopeCorners[0][0];
│ │ │ │ +
232 LocalCoords normal0 = edge1;
│ │ │ │ +
233 normal0.axpy(-(edge0*edge1),edge0);
│ │ │ │ +
234
│ │ │ │ +
235 std::vector<T> angles(polytopeCorners.size());
│ │ │ │ +
236
│ │ │ │ +
237 for (size_t i=0; i<polytopeCorners.size(); i++) {
│ │ │ │ +
238
│ │ │ │ +
239 LocalCoords edge = polytopeCorners[i][0] - center;
│ │ │ │ +
240
│ │ │ │ +
241 T x(edge*edge0);
│ │ │ │ +
242 T y(edge*normal0);
│ │ │ │ +
243
│ │ │ │ +
244 angles[i] = std::atan2(y, x);
│ │ │ │ +
245 if (angles[i]<0)
│ │ │ │ +
246 angles[i] += 2*M_PI;
│ │ │ │ +
247 }
│ │ │ │ +
248
│ │ │ │ +
249 // bubblesort
│ │ │ │ +
250
│ │ │ │ +
251 for (int i=polytopeCorners.size(); i>1; i--){
│ │ │ │ +
252 bool swapped = false;
│ │ │ │ +
253
│ │ │ │ +
254 for (int j=0; j<i-1; j++){
│ │ │ │ +
255
│ │ │ │ +
256 if (angles[j] > angles[j+1]){
│ │ │ │ +
257 swapped = true;
│ │ │ │ +
258 std::swap(angles[j], angles[j+1]);
│ │ │ │ +
259 std::swap(ordering[j], ordering[j+1]);
│ │ │ │ +
260 }
│ │ │ │ +
261 }
│ │ │ │ +
262
│ │ │ │ +
263 if (!swapped)
│ │ │ │ +
264 break;
│ │ │ │ +
265 }
│ │ │ │ +
266}
│ │ │ │ +
│ │ │ │ +
267
│ │ │ │ +
268template<int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
269void ContactMerge<dimworld, T>::setupNodalDirections(const std::vector<WorldCoords>& coords1,
│ │ │ │ +
270 const std::vector<unsigned int>& elements1,
│ │ │ │ +
271 const std::vector<Dune::GeometryType>& elementTypes1,
│ │ │ │ +
272 const std::vector<WorldCoords>& coords2,
│ │ │ │ +
273 const std::vector<unsigned int>& elements2,
│ │ │ │ +
274 const std::vector<Dune::GeometryType>& elementTypes2)
│ │ │ │ +
275{
│ │ │ │ +
276 if (domainDirections_) {
│ │ │ │ +
277
│ │ │ │ +
278 // Sample the provided analytical contact direction field
│ │ │ │ +
279 nodalDomainDirections_.resize(coords1.size());
│ │ │ │ +
280 for (size_t i=0; i<coords1.size(); i++)
│ │ │ │ +
281 nodalDomainDirections_[i] = domainDirections_(coords1[i]);
│ │ │ │ +
282 } else
│ │ │ │ +
283 computeOuterNormalField(coords1,elements1,elementTypes1, nodalDomainDirections_);
│ │ │ │ +
284
│ │ │ │ +
285 if (targetDirections_) {
│ │ │ │ +
286
│ │ │ │ +
287 // Sample the provided analytical target direction field
│ │ │ │ +
288 nodalTargetDirections_.resize(coords2.size());
│ │ │ │ +
289 for (size_t i=0; i<coords2.size(); i++)
│ │ │ │ +
290 nodalTargetDirections_[i] = targetDirections_(coords2[i]);
│ │ │ │ +
291 } else
│ │ │ │ +
292 computeOuterNormalField(coords2,elements2,elementTypes2, nodalTargetDirections_);
│ │ │ │ +
293}
│ │ │ │ +
│ │ │ │ +
294
│ │ │ │ +
295template<int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
296void ContactMerge<dimworld, T>::computeOuterNormalField(const std::vector<WorldCoords>& coords,
│ │ │ │ +
297 const std::vector<unsigned int>& elements,
│ │ │ │ +
298 const std::vector<Dune::GeometryType>& elementTypes,
│ │ │ │ +
299 std::vector<WorldCoords>& normals)
│ │ │ │ +
300{
│ │ │ │ +
301 normals.assign(coords.size(),WorldCoords(0));
│ │ │ │ +
302
│ │ │ │ +
303
│ │ │ │ +
304 int offset = 0;
│ │ │ │ +
305
│ │ │ │ +
306 for (size_t i=0; i<elementTypes.size(); i++) {
│ │ │ │ +
307
│ │ │ │ +
308 int nCorners = Dune::ReferenceElements<T,dim>::general(elementTypes[i]).size(dim);
│ │ │ │ +
309
│ │ │ │ +
310 // For segments 1, for triangles or quadrilaterals take the first 2
│ │ │ │ +
311 std::array<WorldCoords, dim> edges;
│ │ │ │ +
312 for (int j=1; j<=dim; j++)
│ │ │ │ +
313 edges[j-1] = coords[elements[offset + j]] - coords[elements[offset]];
│ │ │ │ +
314
│ │ │ │ +
315 WorldCoords elementNormal;
│ │ │ │ +
316
│ │ │ │ +
317 if (dim==1) {
│ │ │ │ +
318 elementNormal[0] = edges[0][1]; elementNormal[1] = -edges[0][0];
│ │ │ │ +
319 } else
│ │ │ │ +
320 elementNormal = crossProduct(edges[0], edges[1]);
│ │ │ │ +
321
│ │ │ │ +
322 elementNormal /= elementNormal.two_norm();
│ │ │ │ +
323
│ │ │ │ +
324 for (int j=0; j<nCorners;j++)
│ │ │ │ +
325 normals[elements[offset + j]] += elementNormal;
│ │ │ │ +
326
│ │ │ │ +
327 offset += nCorners;
│ │ │ │ +
328 }
│ │ │ │ +
329
│ │ │ │ +
330 for (size_t i=0; i<coords.size(); i++)
│ │ │ │ +
331 normals[i] /= normals[i].two_norm();
│ │ │ │ +
332}
│ │ │ │ +
│ │ │ │ +
333
│ │ │ │ +
334template<int dimworld, typename T>
│ │ │ │ +
│ │ │ │ +
335void ContactMerge<dimworld, T>::removeDoubles(std::vector<std::array<LocalCoords,2> >& polytopeCorners)
│ │ │ │ +
336{
│ │ │ │ +
337
│ │ │ │ +
338 size_t counter(1);
│ │ │ │ +
339 for (size_t i=1; i<polytopeCorners.size(); i++) {
│ │ │ │ +
340 bool contained = false;
│ │ │ │ +
341 for (size_t j=0; j<counter; j++)
│ │ │ │ +
342 if ( (polytopeCorners[j][0]-polytopeCorners[i][0]).two_norm()<1e-10) {
│ │ │ │ +
343 assert((polytopeCorners[j][1]-polytopeCorners[i][1]).two_norm()<1e-10);
│ │ │ │ +
344 contained = true;
│ │ │ │ +
345 break;
│ │ │ │ +
346 }
│ │ │ │ +
347
│ │ │ │ +
348 if (!contained) {
│ │ │ │ +
349 if (counter < i)
│ │ │ │ +
350 polytopeCorners[counter] = polytopeCorners[i];
│ │ │ │ +
351 counter++;
│ │ │ │ +
352 }
│ │ │ │ +
353 }
│ │ │ │ +
354 polytopeCorners.resize(counter);
│ │ │ │ +
355}
│ │ │ │ +
│ │ │ │ +
356
│ │ │ │ +
357} /* namespace GridGlue */
│ │ │ │ +
358} /* namespace Dune */
│ │ │ │ + │ │ │ │ + │ │ │ │
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
│ │ │ │ +
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
│ │ │ │ +
Coordinate corner(unsigned c)
Definition projection_impl.hh:24
│ │ │ │ +
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
│ │ │ │ +
void removeDoubles(std::vector< std::array< LocalCoords, 2 > > &polytopeCorners)
Remove all multiples.
Definition contactmerge.cc:335
│ │ │ │ +
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 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::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition contactmerge.hh:62
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,214 +1,439 @@ │ │ │ │ │ dune-grid-glue 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * grid-glue │ │ │ │ │ * merging │ │ │ │ │ -computeintersection.hh │ │ │ │ │ +contactmerge.cc │ │ │ │ │ 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-with- │ │ │ │ │ +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 │ │ │ │ │ +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); │ │ │ │ │ +12template │ │ │ │ │ +13void ContactMerge::computeIntersections(const Dune:: │ │ │ │ │ +GeometryType& grid1ElementType, │ │ │ │ │ +14 const std::vector >& grid1ElementCorners, │ │ │ │ │ +15 std::bitset<(1<& neighborIntersects1, │ │ │ │ │ +16 unsigned int grid1Index, │ │ │ │ │ +17 const Dune::GeometryType& grid2ElementType, │ │ │ │ │ +18 const std::vector >& grid2ElementCorners, │ │ │ │ │ +19 std::bitset<(1<& neighborIntersects2, │ │ │ │ │ +20 unsigned int grid2Index, │ │ │ │ │ +21 std::vector& intersections) │ │ │ │ │ +22{ │ │ │ │ │ +23 using std::get; │ │ │ │ │ +24 │ │ │ │ │ +25 std::vector > polytopeCorners; │ │ │ │ │ +26 │ │ │ │ │ +27 // Initialize │ │ │ │ │ +28 neighborIntersects1.reset(); │ │ │ │ │ +29 neighborIntersects2.reset(); │ │ │ │ │ +30 │ │ │ │ │ +31 const int nCorners1 = grid1ElementCorners.size(); │ │ │ │ │ +32 const int nCorners2 = grid2ElementCorners.size(); │ │ │ │ │ +33 │ │ │ │ │ +34 if (nCorners1 != dimworld) │ │ │ │ │ +35 DUNE_THROW(Dune::Exception, "element1 must have " << dimworld << " corners, │ │ │ │ │ +but has " << nCorners1); │ │ │ │ │ +36 if (nCorners2 != dimworld) │ │ │ │ │ +37 DUNE_THROW(Dune::Exception, "element2 must have " << dimworld << " corners, │ │ │ │ │ +but has " << nCorners2); │ │ │ │ │ +38 │ │ │ │ │ +39 // The grid1 projection directions │ │ │ │ │ +40 std::vector directions1(nCorners1); │ │ │ │ │ +41 for (size_t i=0; igrid1ElementCorners_ │ │ │ │ │ +[grid1Index][i]]; │ │ │ │ │ +43 │ │ │ │ │ +44 // The grid2 projection directions │ │ │ │ │ +45 std::vector directions2(nCorners2); │ │ │ │ │ +46 for (size_t i=0; igrid2ElementCorners_ │ │ │ │ │ +[grid2Index][i]]; │ │ │ │ │ +48 │ │ │ │ │ +49 // The difference between the closest point projection and the normal │ │ │ │ │ +projection is just the ordering │ │ │ │ │ +50 // of the involved surfaces. The closest point projection is done along the │ │ │ │ │ +outer normal field of grid2 │ │ │ │ │ +51 // (due to being a best approximation) and the outer normal projection is │ │ │ │ │ +using the outer normal field │ │ │ │ │ +52 // of grid1 instead. │ │ │ │ │ +53 std::array cornersRef ={std:: │ │ │ │ │ +cref(grid1ElementCorners), std::cref(grid2ElementCorners)}; │ │ │ │ │ +54 std::array directionsRef ={std::cref │ │ │ │ │ +(directions1), std::cref(directions2)}; │ │ │ │ │ +55 std::array elementTypes = {grid1ElementType, │ │ │ │ │ +grid2ElementType}; │ │ │ │ │ +56 │ │ │ │ │ +57 // Determine which is the grid we use for outer normal projection │ │ │ │ │ +58 const size_t domGrid = (type_==ProjectionType::OUTER_NORMAL) ? 0 : 1; │ │ │ │ │ +59 const size_t tarGrid = (type_==ProjectionType::OUTER_NORMAL) ? 1 : 0; │ │ │ │ │ +60 │ │ │ │ │ +62 // Compute all corners of the intersection polytope │ │ │ │ │ 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}; │ │ │ │ │ +65 const auto corners = std::tie(cornersRef[domGrid].get(),cornersRef │ │ │ │ │ +[tarGrid].get()); │ │ │ │ │ +66 const auto normals = std::tie(directionsRef[domGrid].get(), directionsRef │ │ │ │ │ +[tarGrid].get()); │ │ │ │ │ +67 Projection p(overlap_, maxNormalProduct_); │ │ │ │ │ +68 p.project(corners, normals); │ │ │ │ │ +69 │ │ │ │ │ +70 /* projection */ │ │ │ │ │ +71 { │ │ │ │ │ +72 const auto& success = get<0>(p.success()); │ │ │ │ │ +73 const auto& images = get<0>(p.images()); │ │ │ │ │ +74 for (unsigned i = 0; i < dimworld; ++i) { │ │ │ │ │ +75 if (success[i]) { │ │ │ │ │ +76 std::array corner; │ │ │ │ │ +77 corner[domGrid] = localCornerCoords(i, elementTypes[domGrid]); │ │ │ │ │ +78 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ +79 corner[tarGrid][j] = images[i][j]; │ │ │ │ │ +80 polytopeCorners.push_back(corner); │ │ │ │ │ +81 } │ │ │ │ │ +82 } │ │ │ │ │ +83 } │ │ │ │ │ +84 │ │ │ │ │ +85 /* inverse projection */ │ │ │ │ │ +86 { │ │ │ │ │ +87 const auto& success = get<1>(p.success()); │ │ │ │ │ +88 const auto& preimages = get<1>(p.images()); │ │ │ │ │ +89 for (unsigned i = 0; i < dimworld; ++i) { │ │ │ │ │ +90 if (success[i]) { │ │ │ │ │ +91 std::array corner; │ │ │ │ │ +92 for (unsigned j = 0; j < dim; ++j) │ │ │ │ │ +93 corner[domGrid][j] = preimages[i][j]; │ │ │ │ │ +94 corner[tarGrid] = localCornerCoords(i, elementTypes[tarGrid]); │ │ │ │ │ +95 polytopeCorners.push_back(corner); │ │ │ │ │ +96 } │ │ │ │ │ +97 } │ │ │ │ │ +98 } │ │ │ │ │ +99 │ │ │ │ │ +100 /* edge intersections */ │ │ │ │ │ +101 { │ │ │ │ │ +102 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ +103 std::array corner; │ │ │ │ │ +104 const auto& local = p.edgeIntersections()[i].local; │ │ │ │ │ +105 for (unsigned j = 0; j < dim; ++j) { │ │ │ │ │ +106 corner[domGrid][j] = local[0][j]; │ │ │ │ │ +107 corner[tarGrid][j] = local[1][j]; │ │ │ │ │ +108 } │ │ │ │ │ +109 polytopeCorners.push_back(corner); │ │ │ │ │ +110 } │ │ │ │ │ +111 } │ │ │ │ │ +112 │ │ │ │ │ +113 // check which neighbors might also intersect │ │ │ │ │ +114 std::array neighborIntersectsRef │ │ │ │ │ += {std::ref(neighborIntersects1), std::ref(neighborIntersects2)}; │ │ │ │ │ +115 const auto& refTar = Dune::ReferenceElements::general(elementTypes │ │ │ │ │ +[tarGrid]); │ │ │ │ │ +116 for (int i=0; i(p.success())[refTar.subEntity(i,1,k,dim)]; │ │ │ │ │ +124 │ │ │ │ │ +125 if (intersects) │ │ │ │ │ +126 neighborIntersectsRef[tarGrid].get()[i] = true; │ │ │ │ │ +127 } │ │ │ │ │ +128 │ │ │ │ │ +129 const auto& refDom = Dune::ReferenceElements::general(elementTypes │ │ │ │ │ +[domGrid]); │ │ │ │ │ +130 for (int i=0; i(p.success())[refDom.subEntity(i,1,k,dim)]; │ │ │ │ │ +138 │ │ │ │ │ +139 if (intersects) │ │ │ │ │ +140 neighborIntersectsRef[domGrid].get()[i] = true; │ │ │ │ │ +141 } │ │ │ │ │ +142 │ │ │ │ │ +143 // Compute the edge intersections │ │ │ │ │ +144 for (unsigned i = 0; i < p.numberOfEdgeIntersections(); ++i) { │ │ │ │ │ +145 const auto& edge = p.edgeIntersections()[i].edge; │ │ │ │ │ +146 neighborIntersects1[edge[domGrid]] = true; │ │ │ │ │ +147 neighborIntersects2[edge[tarGrid]] = true; │ │ │ │ │ +148 } │ │ │ │ │ +149 │ │ │ │ │ +150 // remove possible doubles │ │ │ │ │ +151 removeDoubles(polytopeCorners); │ │ │ │ │ +152 │ │ │ │ │ +153 // Compute an interior point of the polytope │ │ │ │ │ +154 int nPolyCorners = polytopeCorners.size(); │ │ │ │ │ +155 │ │ │ │ │ +156 // If the polytope is degenerated then there is no intersection │ │ │ │ │ +157 if (nPolyCorners │ │ │ │ │ -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 │ │ │ │ │ +163 // std::cout<<"Add intersection: 1\n"; │ │ │ │ │ +164 typename Base::SimplicialIntersection intersect(grid1Index, grid2Index); │ │ │ │ │ +165 │ │ │ │ │ +166 for (int j=0;j=3 │ │ │ │ │ +176 │ │ │ │ │ +178 // Compute a point in the middle of the polytope and order all corners │ │ │ │ │ +cyclic │ │ │ │ │ 180 │ │ │ │ │ -181 } │ │ │ │ │ -182 else │ │ │ │ │ -183 P.push_back(p); │ │ │ │ │ -184 │ │ │ │ │ -185 return k ; │ │ │ │ │ -186} │ │ │ │ │ +181 std::array center; │ │ │ │ │ +182 center[0] = 0; center[1] = 0; │ │ │ │ │ +183 for (int i=0; i ordering; │ │ │ │ │ +190 computeCyclicOrder(polytopeCorners,center[0],ordering); │ │ │ │ │ 191 │ │ │ │ │ -192#include "simplexintersection.cc" │ │ │ │ │ -193#include "computeintersection.cc" │ │ │ │ │ -194 │ │ │ │ │ -195#endif │ │ │ │ │ -computeintersection.cc │ │ │ │ │ -simplexintersection.cc │ │ │ │ │ +193 // Add intersections │ │ │ │ │ +195 │ │ │ │ │ +196 for (size_t i=1; i │ │ │ │ │ +214void ContactMerge::computeCyclicOrder(const std::vector >& polytopeCorners, │ │ │ │ │ +215 const LocalCoords& center, std::vector& ordering) const │ │ │ │ │ +216{ │ │ │ │ │ +217 ordering.resize(polytopeCorners.size()); │ │ │ │ │ +218 │ │ │ │ │ +219 for (size_t k=0; k angles(polytopeCorners.size()); │ │ │ │ │ +236 │ │ │ │ │ +237 for (size_t i=0; i1; i--){ │ │ │ │ │ +252 bool swapped = false; │ │ │ │ │ +253 │ │ │ │ │ +254 for (int j=0; j angles[j+1]){ │ │ │ │ │ +257 swapped = true; │ │ │ │ │ +258 std::swap(angles[j], angles[j+1]); │ │ │ │ │ +259 std::swap(ordering[j], ordering[j+1]); │ │ │ │ │ +260 } │ │ │ │ │ +261 } │ │ │ │ │ +262 │ │ │ │ │ +263 if (!swapped) │ │ │ │ │ +264 break; │ │ │ │ │ +265 } │ │ │ │ │ +266} │ │ │ │ │ +267 │ │ │ │ │ +268template │ │ │ │ │ +269void ContactMerge::setupNodalDirections(const std:: │ │ │ │ │ +vector& coords1, │ │ │ │ │ +270 const std::vector& elements1, │ │ │ │ │ +271 const std::vector& elementTypes1, │ │ │ │ │ +272 const std::vector& coords2, │ │ │ │ │ +273 const std::vector& elements2, │ │ │ │ │ +274 const std::vector& elementTypes2) │ │ │ │ │ +275{ │ │ │ │ │ +276 if (domainDirections_) { │ │ │ │ │ +277 │ │ │ │ │ +278 // Sample the provided analytical contact direction field │ │ │ │ │ +279 nodalDomainDirections_.resize(coords1.size()); │ │ │ │ │ +280 for (size_t i=0; i │ │ │ │ │ +296void ContactMerge::computeOuterNormalField(const std:: │ │ │ │ │ +vector& coords, │ │ │ │ │ +297 const std::vector& elements, │ │ │ │ │ +298 const std::vector& elementTypes, │ │ │ │ │ +299 std::vector& normals) │ │ │ │ │ +300{ │ │ │ │ │ +301 normals.assign(coords.size(),WorldCoords(0)); │ │ │ │ │ +302 │ │ │ │ │ +303 │ │ │ │ │ +304 int offset = 0; │ │ │ │ │ +305 │ │ │ │ │ +306 for (size_t i=0; i::general(elementTypes │ │ │ │ │ +[i]).size(dim); │ │ │ │ │ +309 │ │ │ │ │ +310 // For segments 1, for triangles or quadrilaterals take the first 2 │ │ │ │ │ +311 std::array edges; │ │ │ │ │ +312 for (int j=1; j<=dim; j++) │ │ │ │ │ +313 edges[j-1] = coords[elements[offset + j]] - coords[elements[offset]]; │ │ │ │ │ +314 │ │ │ │ │ +315 WorldCoords elementNormal; │ │ │ │ │ +316 │ │ │ │ │ +317 if (dim==1) { │ │ │ │ │ +318 elementNormal[0] = edges[0][1]; elementNormal[1] = -edges[0][0]; │ │ │ │ │ +319 } else │ │ │ │ │ +320 elementNormal = crossProduct(edges[0], edges[1]); │ │ │ │ │ +321 │ │ │ │ │ +322 elementNormal /= elementNormal.two_norm(); │ │ │ │ │ +323 │ │ │ │ │ +324 for (int j=0; j │ │ │ │ │ +335void ContactMerge::removeDoubles(std::vector >& polytopeCorners) │ │ │ │ │ +336{ │ │ │ │ │ +337 │ │ │ │ │ +338 size_t counter(1); │ │ │ │ │ +339 for (size_t i=1; i &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::intersections │ │ │ │ │ +IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... │ │ │ │ │ +> &reverse=!reversed) │ │ │ │ │ +Iterate over all intersections of a GridGlue. │ │ │ │ │ +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::ProjectionImplementation::corner │ │ │ │ │ +Coordinate corner(unsigned c) │ │ │ │ │ +Definition projection_impl.hh:24 │ │ │ │ │ +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::removeDoubles │ │ │ │ │ +void removeDoubles(std::vector< std::array< LocalCoords, 2 > > │ │ │ │ │ +&polytopeCorners) │ │ │ │ │ +Remove all multiples. │ │ │ │ │ +Definition contactmerge.cc:335 │ │ │ │ │ +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::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::LocalCoords │ │ │ │ │ +Dune::FieldVector< T, dim > LocalCoords │ │ │ │ │ +the coordinate type used in this interface │ │ │ │ │ +Definition contactmerge.hh:62 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00101.html │ │ │ │ @@ -69,15 +69,15 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
Todo List
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -
Member CheckMPIStatus (A, B)
│ │ │ │ +
Member CheckMPIStatus (A, B)
│ │ │ │
Implement MPI Status check with exception handling
│ │ │ │
Class Dune::GridGlue::GridGlue< P0, P1 >
│ │ │ │
adapt member names according to style guide
│ │ │ │
Member Dune::GridGlue::GridGlue< P0, P1 >::communicate (Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
│ │ │ │

fix mixed communication: seq->par use commSeq, par->seq use commPar

│ │ │ │

│ │ │ │

add directed version communicate<FROM,TO, DH,DT>(data,iftype,dir)

│ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00926.html │ │ │ │ @@ -1531,15 +1531,15 @@ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following files: │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00930.html │ │ │ │ @@ -83,15 +83,15 @@ │ │ │ │
Dune::GridGlue::IntersectionData< P0, P1 > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

storage class for Dune::GridGlue::Intersection related data │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -640,15 +640,15 @@ │ │ │ │ │ │ │ │

Dimension of the intersection.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00934.html │ │ │ │ @@ -81,15 +81,15 @@ │ │ │ │
Dune::GridGlue::Intersection< P0, P1, I, O > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

The intersection of two entities of the two patches of a GridGlue. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::Intersection< P0, P1, I, O >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1082,15 +1082,15 @@ │ │ │ │ │ │ │ │

outside patch

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00938.html │ │ │ │ @@ -77,15 +77,15 @@ │ │ │ │ Public Types | │ │ │ │ Public Member Functions | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/intersectioniterator.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/intersectioniterator.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::IntersectionIterator< P0, P1, inside, outside >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -267,15 +267,15 @@ │ │ │ │

│ │ │ │ Public Types

typedef ::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
 
typedef GridGlue::IndexType IndexType
 
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00942.html │ │ │ │ @@ -77,15 +77,15 @@ │ │ │ │ Public Types | │ │ │ │ Public Member Functions | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::IntersectionIndexSet< P0, P1 > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/intersectionindexset.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/intersectionindexset.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -199,15 +199,15 @@ │ │ │ │ │ │ │ │

Return total number of intersections.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00946.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::GridGlueAmiraWriter Class Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Write remote intersections to a AmiraMesh file for debugging purposes. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridglueamirawriter.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridglueamirawriter.hh>

│ │ │ │

│ │ │ │ Public Types

typedef GridGlue::IndexType IndexType
 The type used for the indices.
 
typedef size_t SizeType
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Static Public Member Functions

template<typename Glue >
static void write (const Glue &glue, const std::string &path, int appendix=1)
 
│ │ │ │ @@ -135,15 +135,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00950.html │ │ │ │ @@ -76,15 +76,15 @@ │ │ │ │
│ │ │ │ Public Member Functions | │ │ │ │ List of all members
│ │ │ │
Dune::GridGlue::GlobalId Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::GlobalId:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -202,15 +202,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00954.html │ │ │ │ @@ -81,15 +81,15 @@ │ │ │ │
Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

describes the features of a data handle for communication in parallel runs using the GridGlue::communicate methods. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Public Types

typedef DataTypeImp DataType
 data type of data to communicate
 
│ │ │ │ @@ -315,15 +315,15 @@ │ │ │ │
│ │ │ │
│ │ │ │

how many objects of type DataType have to be sent for a given intersection Note: Both sender and receiver side need to know this size.

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00958.html │ │ │ │ @@ -78,15 +78,15 @@ │ │ │ │ Public Member Functions | │ │ │ │ Public Attributes | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::StreamingMessageBuffer< DT > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::StreamingMessageBuffer< DT >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -341,15 +341,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00962.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::CommunicationOperator< dir > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

forward gather scatter to user defined CommInfo class │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -197,15 +197,15 @@ │ │ │ │ │ │ │ │

│ │ │ │ Static Public Member Functions

template<class CommInfo >
static const CommInfo::DataTypegather (const CommInfo &commInfo, size_t i, size_t j=0)
 
template<class CommInfo >
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00966.html │ │ │ │ @@ -81,15 +81,15 @@ │ │ │ │
Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Struct Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

collects all GridGlue data required for communication │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -290,15 +290,15 @@ │ │ │ │ │ │ │ │

│ │ │ │ Public Types

typedef DataTypeImp value_type
 
typedef GG GridGlue
 
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00970.html │ │ │ │ @@ -80,15 +80,15 @@ │ │ │ │
Dune::CommPolicy< ::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > > Struct Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

specialization of the CommPolicy struct, required for the ParallelIndexsets │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluecommunicate.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -200,15 +200,15 @@ │ │ │ │
│ │ │ │ │ │ │ │

Get the number of objects at an intersection.

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00974.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::GridGlueVtkWriter Class Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Write remote intersections to a vtk file for debugging purposes. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/gridgluevtkwriter.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/gridgluevtkwriter.hh>

│ │ │ │

│ │ │ │ Public Types

typedef ::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > Type
 The type of the GridGlueCommInfo.
 
typedef DataTypeImp IndexedType
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Static Public Member Functions

template<typename Glue >
static void write (const Glue &glue, const std::string &filenameTrunk)
 
│ │ │ │ @@ -129,15 +129,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00982.html │ │ │ │ @@ -77,15 +77,15 @@ │ │ │ │ Public Types | │ │ │ │ Static Public Attributes | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::IntersectionTraits< P0, P1, inside, outside > Struct Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/intersection.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -393,15 +393,15 @@ │ │ │ │ │ │ │ │

│ │ │ │ Public Types

using GridGlue = ::Dune::GridGlue::GridGlue< P0, P1 >
 
using IntersectionData = Dune::GridGlue::IntersectionData< P0, P1 >
 
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00986.html │ │ │ │ @@ -78,15 +78,15 @@ │ │ │ │ Public Member Functions | │ │ │ │ Related Symbols | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::Reverse< reverse > Struct Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/adapter/rangegenerators.hh>

│ │ │ │ +

#include <dune/grid-glue/adapter/rangegenerators.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::Reverse< reverse >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -182,15 +182,15 @@ │ │ │ │ │ │ │ │
│ │ │ │

Static tag representing reversal of in- and outside of intersections.

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00990.html │ │ │ │ @@ -76,15 +76,15 @@ │ │ │ │
│ │ │ │ Public Member Functions | │ │ │ │ List of all members
│ │ │ │
Dune::GridGlue::AreaWriterImplementation::FacetLayout< dimgrid > Struct Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/common/areawriter_impl.hh>

│ │ │ │ +

#include <dune/grid-glue/common/areawriter_impl.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Public Member Functions

bool contains (Dune::GeometryType gt) const
 
│ │ │ │

Member Function Documentation

│ │ │ │ @@ -113,15 +113,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00994.html │ │ │ │ @@ -82,15 +82,15 @@ │ │ │ │
Dune::GridGlue::Projection< Coordinate > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Projection of a line (triangle) on another line (triangle). │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/common/projection.hh>

│ │ │ │ +

#include <dune/grid-glue/common/projection.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  EdgeIntersection
 Intersection between two edges of a triangle. More...
 
│ │ │ │ @@ -492,16 +492,16 @@ │ │ │ │ │ │ │ │

maximum number of edge-edge intersections

│ │ │ │

See also \seealso edgeIntersections()

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a00998.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::Projection< Coordinate >::EdgeIntersection Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Intersection between two edges of a triangle. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/common/projection.hh>

│ │ │ │ +

#include <dune/grid-glue/common/projection.hh>

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -133,15 +133,15 @@ │ │ │ │ │ │ │ │

Local coordinates of intersection and distance along normals.

│ │ │ │

Local coordinate of intersection point in barycentric coordinates with respect to image and preimage triangle.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01034.html │ │ │ │ @@ -80,15 +80,15 @@ │ │ │ │ Protected Types | │ │ │ │ Protected Attributes | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::Codim1Extractor< GV > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/codim1extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/codim1extractor.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::Codim1Extractor< GV >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1336,15 +1336,15 @@ │ │ │ │ │ │ │ │

a map enabling faster access to vertices and coordinates

│ │ │ │

Maps a vertex' index (from index set) to an object holding the locally associated index of the vertex' coordinate in coords_ and an entity pointer to the codim<dim> entity.

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01038.html │ │ │ │ @@ -84,15 +84,15 @@ │ │ │ │
Dune::GridGlue::Extractor< GV, cd > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Provides codimension-independent methods for grid extraction. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::Extractor< GV, cd >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1230,15 +1230,15 @@ │ │ │ │ │ │ │ │

a map enabling faster access to vertices and coordinates

│ │ │ │

Maps a vertex' index (from index set) to an object holding the locally associated index of the vertex' coordinate in coords_ and an entity pointer to the codim<dim> entity.

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01042.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::Extractor< GV, cd >::CornerInfo Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Helpful struct holding one index for the coordinate (vertex) to which it is associated and the element's corner index;. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │

│ │ │ │ Public Attributes

std::array< unsigned, 2 > edge
 Edge numbers in image and preimage triangle.
 
std::array< Coordinate, 2 > local
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -131,15 +131,15 @@ │ │ │ │
│ │ │ │ │ │ │ │

element corner

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01046.html │ │ │ │ @@ -77,15 +77,15 @@ │ │ │ │ Public Member Functions | │ │ │ │ Public Attributes | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::Extractor< GV, cd >::CoordinateInfo Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │

│ │ │ │ Public Attributes

unsigned int idx: 28
 index of the vertex
 
unsigned int num: 4
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -220,15 +220,15 @@ │ │ │ │
│ │ │ │ │ │ │ │

the index of the parent element (from index set)

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01050.html │ │ │ │ @@ -80,15 +80,15 @@ │ │ │ │
Dune::GridGlue::Extractor< GV, cd >::VertexInfo Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

simple struct holding a vertex pointer and an index │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │

│ │ │ │ Public Member Functions

 CoordinateInfo ()
 
 CoordinateInfo (unsigned int index_, IndexType vtxindex_)
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Public Member Functions

 VertexInfo (unsigned int idx_, const Vertex &p_)
 
│ │ │ │ │ │ │ │

│ │ │ │ @@ -170,15 +170,15 @@ │ │ │ │

│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01054.html │ │ │ │ @@ -80,15 +80,15 @@ │ │ │ │
Dune::GridGlue::Extractor< GV, cd >::ElementInfo Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

simple struct holding an element seed and an index │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Public Member Functions

 ElementInfo (unsigned int idx_, const Element &p_, unsigned int f_)
 
│ │ │ │ │ │ │ │

│ │ │ │ @@ -203,15 +203,15 @@ │ │ │ │
│ │ │ │ │ │ │ │

the entity seed for the element

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01058.html │ │ │ │ @@ -80,15 +80,15 @@ │ │ │ │
Dune::GridGlue::Extractor< GV, cd >::SubEntityInfo Struct Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Holds some information about an element's subentity involved in a coupling. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ +

#include <dune/grid-glue/extractors/extractor.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -284,15 +284,15 @@ │ │ │ │
│ │ │ │ │ │ │ │

the index of the parent element (from index set)

│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this struct was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01066.html │ │ │ │ @@ -78,15 +78,15 @@ │ │ │ │ Static Public Member Functions | │ │ │ │ Static Public Attributes | │ │ │ │ List of all members │ │ │ │
Dune::GridGlue::ComputationMethod< dimWorld, dim1, dim2, T > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/computeintersection.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/computeintersection.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::ComputationMethod< dimWorld, dim1, dim2, T >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -391,15 +391,15 @@ │ │ │ │ │ │ │ │

│ │ │ │ Public Member Functions

 SubEntityInfo ()
 
 SubEntityInfo (IndexType parent_, unsigned int num_in_parent_, const Dune::GeometryType &geometryType)
 
│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01070.html │ │ │ │ @@ -79,15 +79,15 @@ │ │ │ │
Dune::GridGlue::IntersectionComputation< CM > Class Template Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Intersection computation method for two elements of arbitrary dimension. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/computeintersection.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/computeintersection.hh>

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -248,16 +248,16 @@ │ │ │ │

│ │ │ │ Static Public Member Functions

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, where X is of dimension dim1 and Y is of dimension dim2 and return a vector P containing the corner points of the intersection polyhedron.
 
template<int isDim, int dW>
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01074.html │ │ │ │ @@ -85,15 +85,15 @@ │ │ │ │
Dune::GridGlue::ConformingMerge< dim, dimworld, T > Class Template Referenceabstract
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

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

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/conformingmerge.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/conformingmerge.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::ConformingMerge< dim, dimworld, T >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1147,15 +1147,15 @@ │ │ │ │

│ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01078.html │ │ │ │ @@ -84,15 +84,15 @@ │ │ │ │
Dune::GridGlue::ContactMerge< dimworld, T > Class Template Referenceabstract
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Merge two codimension-1 surfaces that may be a positive distance apart. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/contactmerge.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/contactmerge.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::ContactMerge< dimworld, T >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1636,16 +1636,16 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01110.html │ │ │ │ @@ -81,15 +81,15 @@ │ │ │ │
Dune::GridGlue::Merger< ctype, grid1Dim, grid2Dim, dimworld > Class Template Referenceabstract
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Abstract base for all classes that take extracted grids and build sets of intersections. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/merger.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/merger.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::Merger< ctype, grid1Dim, grid2Dim, dimworld >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -576,15 +576,15 @@ │ │ │ │ │ │ │ │

Counts the number of times the computeIntersection method has been called.

│ │ │ │

Used temporarily to speed up the implementation

│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01114.html │ │ │ │ @@ -84,15 +84,15 @@ │ │ │ │
Dune::GridGlue::OverlappingMerge< dim1, dim2, dimworld, T > Class Template Referenceabstract
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

Computing overlapping grid intersections for grids of different dimensions. │ │ │ │ More...

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/overlappingmerge.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/overlappingmerge.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::OverlappingMerge< dim1, dim2, dimworld, T >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1220,15 +1220,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following files: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01118.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01122.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01126.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01130.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01134.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01138.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01142.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01146.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01150.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01154.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01158.html │ │ │ │ @@ -493,15 +493,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/a01162.html │ │ │ │ @@ -84,15 +84,15 @@ │ │ │ │
Dune::GridGlue::StandardMerge< T, grid1Dim, grid2Dim, dimworld > Class Template Referenceabstract
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │

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

│ │ │ │ │ │ │ │ -

#include <dune/grid-glue/merging/standardmerge.hh>

│ │ │ │ +

#include <dune/grid-glue/merging/standardmerge.hh>

│ │ │ │
│ │ │ │ Inheritance diagram for Dune::GridGlue::StandardMerge< T, grid1Dim, grid2Dim, dimworld >:
│ │ │ │
│ │ │ │
Inheritance graph
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1138,15 +1138,15 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
The documentation for this class was generated from the following file: │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000000_000001.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -

adapter → common Relation

File in dune/grid-glue/adapterIncludes file in dune/grid-glue/common
gridglue.ccringcomm.hh
│ │ │ │ +

adapter → common Relation

File in dune/grid-glue/adapterIncludes file in dune/grid-glue/common
gridglue.ccringcomm.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000003_000000.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -

extractors → adapter Relation

File in dune/grid-glue/extractorsIncludes file in dune/grid-glue/adapter
vtksurfacewriter.hhgridgluevtkwriter.hh
│ │ │ │ +

extractors → adapter Relation

File in dune/grid-glue/extractorsIncludes file in dune/grid-glue/adapter
vtksurfacewriter.hhgridgluevtkwriter.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000003_000001.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -

extractors → common Relation

File in dune/grid-glue/extractorsIncludes file in dune/grid-glue/common
codim1extractor.hhcrossproduct.hh
│ │ │ │ +

extractors → common Relation

File in dune/grid-glue/extractorsIncludes file in dune/grid-glue/common
codim1extractor.hhcrossproduct.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000004_000000.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

grid-glue → adapter Relation

File in dune/grid-glueIncludes file in dune/grid-glue/adapter
gridglue.hhgridglue.cc
gridglue.hhgridgluecommunicate.hh
gridglue.hhintersection.hh
gridglue.hhintersectionindexset.hh
gridglue.hhintersectioniterator.hh
gridglue.hhrangegenerators.hh
extractors / vtksurfacewriter.hhgridgluevtkwriter.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000004_000005.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -

grid-glue → merging Relation

File in dune/grid-glueIncludes file in dune/grid-glue/merging
gridglue.hhmerger.hh
│ │ │ │ +

grid-glue → merging Relation

File in dune/grid-glueIncludes file in dune/grid-glue/merging
gridglue.hhmerger.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_000005_000001.html │ │ │ │ @@ -69,14 +69,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -

merging → common Relation

File in dune/grid-glue/mergingIncludes file in dune/grid-glue/common
contactmerge.cccrossproduct.hh
contactmerge.ccprojection.hh
│ │ │ │ +

merging → common Relation

File in dune/grid-glue/mergingIncludes file in dune/grid-glue/common
contactmerge.cccrossproduct.hh
contactmerge.ccprojection.hh
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_0d8f660a135565b225f6b14e80c278b4.html │ │ │ │ @@ -87,40 +87,40 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Files

 computeintersection.cc
 computeintersection.cc
 
 computeintersection.hh
 computeintersection.hh
 
 conformingmerge.hh
 Implementation of the Merger concept for conforming interfaces.
 conformingmerge.hh
 Implementation of the Merger concept for conforming interfaces.
 
 contactmerge.cc
 contactmerge.cc
 
 contactmerge.hh
 Merge two grid boundary surfaces that may be a positive distance apart.
 contactmerge.hh
 Merge two grid boundary surfaces that may be a positive distance apart.
 
 intersectionlist.hh
 
 merger.hh
 merger.hh
 
 overlappingmerge.cc
 
 overlappingmerge.hh
 overlappingmerge.hh
 
 simplexintersection.cc
 simplexintersection.cc
 
 standardmerge.cc
 standardmerge.cc
 
 standardmerge.hh
 Common base class for many merger implementations: produce pairs of entities that may intersect.
 standardmerge.hh
 Common base class for many merger implementations: produce pairs of entities that may intersect.
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_1b444a177590012656060e8a0bca20fc.html │ │ │ │ @@ -91,32 +91,32 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Files

 gridglue.cc
 
 gridglue.hh
 
 gridglueamirawriter.hh
 Write all remote intersections to a AmiraMesh file.
 gridglueamirawriter.hh
 Write all remote intersections to a AmiraMesh file.
 
 gridgluecommunicate.hh
 Describes the parallel communication interface class for Dune::GridGlue.
 gridgluecommunicate.hh
 Describes the parallel communication interface class for Dune::GridGlue.
 
 gridgluevtkwriter.hh
 Write all remote intersections to a vtk file for debugging.
 gridgluevtkwriter.hh
 Write all remote intersections to a vtk file for debugging.
 
 intersection.hh
 Model of the Intersection concept provided by GridGlue.
 intersection.hh
 Model of the Intersection concept provided by GridGlue.
 
 intersectionindexset.hh
 intersectionindexset.hh
 
 intersectioniterator.hh
 Implement iterators over GridGlue intersections.
 intersectioniterator.hh
 Implement iterators over GridGlue intersections.
 
 rangegenerators.hh
 rangegenerators.hh
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_65f347cff0208f20f00d27c542208238.html │ │ │ │ @@ -84,29 +84,29 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Files

 areawriter.hh
 areawriter.hh
 
 areawriter_impl.hh
 areawriter_impl.hh
 
 crossproduct.hh
 crossproduct.hh
 
 projection.hh
 projection.hh
 
 projection_impl.hh
 projection_impl.hh
 
 projectionwriter.hh
 projectionwriter.hh
 
 projectionwriter_impl.hh
 projectionwriter_impl.hh
 
 ringcomm.hh
 ringcomm.hh
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dir_eaad0bdad6fc03850e65b1fdad9faad4.html │ │ │ │ @@ -93,19 +93,19 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Files

 codim0extractor.hh
 Mesh grid extractor base class.
 
 codim1extractor.hh
 Grid extractor class for codim 1 subgrids.
 codim1extractor.hh
 Grid extractor class for codim 1 subgrids.
 
 extractor.hh
 extractor base class
 extractor.hh
 extractor base class
 
 vtksurfacewriter.hh
 helper class for graphical output of grids in generic representation
 
│ │ │ │ │ │ │ │ │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/dune-grid-glue.tag.gz │ │ │ │ ├── dune-grid-glue.tag │ │ │ │ │ ├── dune-grid-glue.tag │ │ │ │ │ │ @@ -1,272 +1,272 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ gridglue.cc │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ a00026.html │ │ │ │ │ │ - intersection.hh │ │ │ │ │ │ + intersection.hh │ │ │ │ │ │ ../gridglue.hh │ │ │ │ │ │ - ../common/ringcomm.hh │ │ │ │ │ │ + ../common/ringcomm.hh │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ gridglueamirawriter.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00005.html │ │ │ │ │ │ + a00017.html │ │ │ │ │ │ Dune::GridGlue::GridGlueAmiraWriter │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ gridgluecommunicate.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00014.html │ │ │ │ │ │ + a00023.html │ │ │ │ │ │ Dune::GridGlue::GlobalId │ │ │ │ │ │ Dune::GridGlue::CommDataHandle │ │ │ │ │ │ Dune::GridGlue::StreamingMessageBuffer │ │ │ │ │ │ Dune::GridGlue::CommunicationOperator │ │ │ │ │ │ Dune::GridGlue::CommInfo │ │ │ │ │ │ Dune::CommPolicy< ::Dune::GridGlue::CommInfo< GG, DataHandleImp, DataTypeImp > > │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ gridgluevtkwriter.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00020.html │ │ │ │ │ │ + a00014.html │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ Dune::GridGlue::GridGlueVtkWriter │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ intersection.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00017.html │ │ │ │ │ │ + a00005.html │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ Dune::GridGlue::IntersectionData │ │ │ │ │ │ Dune::GridGlue::IntersectionTraits │ │ │ │ │ │ Dune::GridGlue::Intersection │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ ONLY_SIMPLEX_INTERSECTIONS │ │ │ │ │ │ - a00017.html │ │ │ │ │ │ + a00005.html │ │ │ │ │ │ aac752eae6e9ad7d1e576f1fe3f7c8a6b │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ intersectionindexset.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00023.html │ │ │ │ │ │ + a00008.html │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ - dune/grid-glue/adapter/intersection.hh │ │ │ │ │ │ + dune/grid-glue/adapter/intersection.hh │ │ │ │ │ │ Dune::GridGlue::IntersectionIndexSet │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ intersectioniterator.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00011.html │ │ │ │ │ │ + a00020.html │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ Dune::GridGlue::IntersectionIterator │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ rangegenerators.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ - a00008.html │ │ │ │ │ │ + a00011.html │ │ │ │ │ │ Dune::GridGlue::Reverse │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ areawriter.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00032.html │ │ │ │ │ │ - areawriter_impl.hh │ │ │ │ │ │ + a00038.html │ │ │ │ │ │ + areawriter_impl.hh │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ areawriter_impl.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00044.html │ │ │ │ │ │ + a00050.html │ │ │ │ │ │ Dune::GridGlue::AreaWriterImplementation::FacetLayout │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ Dune::GridGlue::AreaWriterImplementation │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ crossproduct.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00041.html │ │ │ │ │ │ + a00044.html │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ projection.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00038.html │ │ │ │ │ │ - projection_impl.hh │ │ │ │ │ │ + a00047.html │ │ │ │ │ │ + projection_impl.hh │ │ │ │ │ │ Dune::GridGlue::Projection │ │ │ │ │ │ Dune::GridGlue::Projection::EdgeIntersection │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ projection_impl.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00047.html │ │ │ │ │ │ + a00029.html │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ Dune::GridGlue::ProjectionImplementation │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ projectionwriter.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00050.html │ │ │ │ │ │ - dune/grid-glue/common/projection.hh │ │ │ │ │ │ - projectionwriter_impl.hh │ │ │ │ │ │ + a00041.html │ │ │ │ │ │ + dune/grid-glue/common/projection.hh │ │ │ │ │ │ + projectionwriter_impl.hh │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ projectionwriter_impl.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00029.html │ │ │ │ │ │ + a00035.html │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ Dune::GridGlue::ProjectionWriterImplementation │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ringcomm.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/common/ │ │ │ │ │ │ - a00035.html │ │ │ │ │ │ + a00032.html │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::Parallel │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ CheckMPIStatus │ │ │ │ │ │ - a00035.html │ │ │ │ │ │ + a00032.html │ │ │ │ │ │ a1a95f4074572a7a9e13bcb072afef070 │ │ │ │ │ │ (A, B) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ codim0extractor.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/extractors/ │ │ │ │ │ │ a00062.html │ │ │ │ │ │ - extractor.hh │ │ │ │ │ │ + extractor.hh │ │ │ │ │ │ Dune::GridGlue::Codim0Extractor │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ codim1extractor.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/extractors/ │ │ │ │ │ │ - a00059.html │ │ │ │ │ │ - extractor.hh │ │ │ │ │ │ - dune/grid-glue/common/crossproduct.hh │ │ │ │ │ │ + a00056.html │ │ │ │ │ │ + extractor.hh │ │ │ │ │ │ + dune/grid-glue/common/crossproduct.hh │ │ │ │ │ │ Dune::GridGlue::Codim1Extractor │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ extractor.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/extractors/ │ │ │ │ │ │ - a00056.html │ │ │ │ │ │ + a00059.html │ │ │ │ │ │ Dune::GridGlue::Extractor │ │ │ │ │ │ Dune::GridGlue::Extractor::CornerInfo │ │ │ │ │ │ Dune::GridGlue::Extractor::CoordinateInfo │ │ │ │ │ │ Dune::GridGlue::Extractor::VertexInfo │ │ │ │ │ │ Dune::GridGlue::Extractor::ElementInfo │ │ │ │ │ │ Dune::GridGlue::Extractor::SubEntityInfo │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ vtksurfacewriter.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/extractors/ │ │ │ │ │ │ a00053.html │ │ │ │ │ │ - ../adapter/gridgluevtkwriter.hh │ │ │ │ │ │ + ../adapter/gridgluevtkwriter.hh │ │ │ │ │ │ Dune::GridGlue::VtkSurfaceWriter │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ adapter/gridglue.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/adapter/ │ │ │ │ │ │ a01963.html │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ gridglue.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/ │ │ │ │ │ │ a00002.html │ │ │ │ │ │ - adapter/gridgluecommunicate.hh │ │ │ │ │ │ - dune/grid-glue/merging/merger.hh │ │ │ │ │ │ - adapter/rangegenerators.hh │ │ │ │ │ │ + adapter/gridgluecommunicate.hh │ │ │ │ │ │ + dune/grid-glue/merging/merger.hh │ │ │ │ │ │ + adapter/rangegenerators.hh │ │ │ │ │ │ adapter/gridglue.cc │ │ │ │ │ │ - adapter/intersection.hh │ │ │ │ │ │ - adapter/intersectioniterator.hh │ │ │ │ │ │ - adapter/intersectionindexset.hh │ │ │ │ │ │ + adapter/intersection.hh │ │ │ │ │ │ + adapter/intersectioniterator.hh │ │ │ │ │ │ + adapter/intersectionindexset.hh │ │ │ │ │ │ Dune::GridGlue::GridGlue │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ computeintersection.cc │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00077.html │ │ │ │ │ │ + a00089.html │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ computeintersection.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00098.html │ │ │ │ │ │ - simplexintersection.cc │ │ │ │ │ │ - computeintersection.cc │ │ │ │ │ │ + a00086.html │ │ │ │ │ │ + simplexintersection.cc │ │ │ │ │ │ + computeintersection.cc │ │ │ │ │ │ Dune::GridGlue::ComputationMethod │ │ │ │ │ │ Dune::GridGlue::IntersectionComputation │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ conformingmerge.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00080.html │ │ │ │ │ │ - dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ + a00074.html │ │ │ │ │ │ + dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ Dune::GridGlue::ConformingMerge │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ contactmerge.cc │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00071.html │ │ │ │ │ │ - dune/grid-glue/common/crossproduct.hh │ │ │ │ │ │ - dune/grid-glue/common/projection.hh │ │ │ │ │ │ + a00098.html │ │ │ │ │ │ + dune/grid-glue/common/crossproduct.hh │ │ │ │ │ │ + dune/grid-glue/common/projection.hh │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ contactmerge.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00089.html │ │ │ │ │ │ - dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ + a00092.html │ │ │ │ │ │ + dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ dune/grid-glue/gridglue.hh │ │ │ │ │ │ - contactmerge.cc │ │ │ │ │ │ + contactmerge.cc │ │ │ │ │ │ Dune::GridGlue::ContactMerge │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ intersectionlist.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ @@ -277,15 +277,15 @@ │ │ │ │ │ │ Dune::GridGlue::SimplicialIntersectionListProvider::SimplicialIntersection │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ merger.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00074.html │ │ │ │ │ │ + a00080.html │ │ │ │ │ │ dune/grid-glue/merging/intersectionlist.hh │ │ │ │ │ │ Dune::GridGlue::Merger │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ overlappingmerge.cc │ │ │ │ │ │ @@ -300,26 +300,26 @@ │ │ │ │ │ │ ad63267c6d27a8f09d98506419b206db8 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ overlappingmerge.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00095.html │ │ │ │ │ │ - dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ - dune/grid-glue/merging/computeintersection.hh │ │ │ │ │ │ + a00068.html │ │ │ │ │ │ + dune/grid-glue/merging/standardmerge.hh │ │ │ │ │ │ + dune/grid-glue/merging/computeintersection.hh │ │ │ │ │ │ overlappingmerge.cc │ │ │ │ │ │ Dune::GridGlue::OverlappingMerge │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ simplexintersection.cc │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00086.html │ │ │ │ │ │ + a00071.html │ │ │ │ │ │ Dune::GridGlue::SimplexMethod │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 0, 0, T > │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 0, 1, T > │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 0, 2, T > │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 0, 3, T > │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 1, 1, T > │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 1, 2, T > │ │ │ │ │ │ @@ -329,54 +329,54 @@ │ │ │ │ │ │ Dune::GridGlue::SimplexMethod< dimWorld, 3, 3, T > │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ standardmerge.cc │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00092.html │ │ │ │ │ │ - standardmerge.hh │ │ │ │ │ │ + a00077.html │ │ │ │ │ │ + standardmerge.hh │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ DECL │ │ │ │ │ │ - a00092.html │ │ │ │ │ │ + a00077.html │ │ │ │ │ │ ad5c7ca0181fea7823b37d06d5f61e9cd │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ STANDARD_MERGE_INSTANTIATE │ │ │ │ │ │ - a00092.html │ │ │ │ │ │ + a00077.html │ │ │ │ │ │ a4a2b0f7fb92723749fc6d5cca82a4297 │ │ │ │ │ │ (T, A, B, C) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ standardmerge.hh │ │ │ │ │ │ /build/reproducible-path/dune-grid-glue-2.10.0/dune/grid-glue/merging/ │ │ │ │ │ │ - a00068.html │ │ │ │ │ │ + a00095.html │ │ │ │ │ │ dune/grid-glue/merging/intersectionlist.hh │ │ │ │ │ │ - dune/grid-glue/merging/merger.hh │ │ │ │ │ │ - dune/grid-glue/merging/computeintersection.hh │ │ │ │ │ │ + dune/grid-glue/merging/merger.hh │ │ │ │ │ │ + dune/grid-glue/merging/computeintersection.hh │ │ │ │ │ │ Dune::GridGlue::StandardMerge │ │ │ │ │ │ Dune │ │ │ │ │ │ Dune::GridGlue │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ DECL │ │ │ │ │ │ - a00068.html │ │ │ │ │ │ + a00095.html │ │ │ │ │ │ ad5c7ca0181fea7823b37d06d5f61e9cd │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ #define │ │ │ │ │ │ STANDARD_MERGE_INSTANTIATE │ │ │ │ │ │ - a00068.html │ │ │ │ │ │ + a00095.html │ │ │ │ │ │ a4a2b0f7fb92723749fc6d5cca82a4297 │ │ │ │ │ │ (T, A, B, C) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ Dune::GridGlue::Codim0Extractor │ │ │ │ │ │ a01030.html │ │ │ ├── ./usr/share/doc/libdune-grid-glue-doc/doxygen/files.html │ │ │ │ @@ -75,48 +75,48 @@ │ │ │ │
Here is a list of all files with brief descriptions:
│ │ │ │
[detail level 1234]
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │
  dune
  grid-glue
  adapter
 gridglue.cc
 gridglue.hh
 gridglueamirawriter.hhWrite all remote intersections to a AmiraMesh file
 gridgluecommunicate.hhDescribes the parallel communication interface class for Dune::GridGlue
 gridgluevtkwriter.hhWrite all remote intersections to a vtk file for debugging
 intersection.hhModel of the Intersection concept provided by GridGlue
 intersectionindexset.hh
 intersectioniterator.hhImplement iterators over GridGlue intersections
 rangegenerators.hh
 gridglueamirawriter.hhWrite all remote intersections to a AmiraMesh file
 gridgluecommunicate.hhDescribes the parallel communication interface class for Dune::GridGlue
 gridgluevtkwriter.hhWrite all remote intersections to a vtk file for debugging
 intersection.hhModel of the Intersection concept provided by GridGlue
 intersectionindexset.hh
 intersectioniterator.hhImplement iterators over GridGlue intersections
 rangegenerators.hh
  common
 areawriter.hh
 areawriter_impl.hh
 crossproduct.hh
 projection.hh
 projection_impl.hh
 projectionwriter.hh
 projectionwriter_impl.hh
 ringcomm.hh
 areawriter.hh
 areawriter_impl.hh
 crossproduct.hh
 projection.hh
 projection_impl.hh
 projectionwriter.hh
 projectionwriter_impl.hh
 ringcomm.hh
  extractors
 codim0extractor.hhMesh grid extractor base class
 codim1extractor.hhGrid extractor class for codim 1 subgrids
 extractor.hhExtractor base class
 codim1extractor.hhGrid extractor class for codim 1 subgrids
 extractor.hhExtractor base class
 vtksurfacewriter.hhHelper class for graphical output of grids in generic representation
  merging
 computeintersection.cc
 computeintersection.hh
 conformingmerge.hhImplementation of the Merger concept for conforming interfaces
 contactmerge.cc
 contactmerge.hhMerge two grid boundary surfaces that may be a positive distance apart
 computeintersection.cc
 computeintersection.hh
 conformingmerge.hhImplementation of the Merger concept for conforming interfaces
 contactmerge.cc
 contactmerge.hhMerge two grid boundary surfaces that may be a positive distance apart
 intersectionlist.hh
 merger.hh
 merger.hh
 overlappingmerge.cc
 overlappingmerge.hh
 simplexintersection.cc
 standardmerge.cc
 standardmerge.hhCommon base class for many merger implementations: produce pairs of entities that may intersect
 overlappingmerge.hh
 simplexintersection.cc
 standardmerge.cc
 standardmerge.hhCommon base class for many merger implementations: produce pairs of entities that may intersect
 gridglue.hhCentral component of the module implementing the coupling of two grids
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │