131 int inGlobalIndexOffset = 0)
133 int meshDimension = inMeshSpec.at(0).position.size();
134 int valueDimension = inMeshSpec.at(0).value.size();
138 int inDataID = inData->
getID();
144 int outDataID = outData->
getID();
153 Eigen::VectorXd guess;
158 for (
auto run : {1, 2, 3, 4}) {
165 mapping.
map(inDataID, outDataID, guess);
168 for (
auto &referenceVertex : referenceSpec) {
169 if (referenceVertex.first == context.
rank or referenceVertex.first == -1) {
170 for (
int dim = 0; dim < valueDimension; ++dim) {
171 BOOST_TEST_INFO(
"Index of vertex: " <<
index <<
" - Dimension: " << dim);
172 BOOST_TEST(outData->
values()(
index * valueDimension + dim) == referenceVertex.second.at(dim));
177 BOOST_TEST(outData->
values().size() ==
index * valueDimension);
351 PRECICE_TEST(
""_on(4_ranks).setupIntraComm(), Require::PETSc);
360 {0, 0, {0, 0}, {1, 4}},
361 {0, 0, {0, 1}, {2, 5}},
362 {0, 0, {1, 0}, {3, 6}},
363 {0, -1, {1, 1}, {4, 7}},
364 {0, -1, {2, 0}, {5, 8}},
365 {0, -1, {2, 1}, {6, 9}},
368 {2, -1, {0, 0}, {1, 4}},
369 {2, -1, {0, 1}, {2, 5}},
370 {2, -1, {1, 0}, {3, 6}},
371 {2, 2, {1, 1}, {4, 7}},
372 {2, -1, {2, 0}, {5, 8}},
373 {2, 2, {2, 1}, {6, 9}},
374 {2, -1, {3, 0}, {7, 10}},
375 {2, -1, {3, 1}, {8, 11}},
377 {3, 3, {2, 0}, {5, 8}},
378 {3, -1, {2, 1}, {6, 9}},
379 {3, 3, {3, 0}, {7, 10}},
380 {3, 3, {3, 1}, {8, 11}},
383 {0, -1, {0, 0}, {0, 0}},
384 {0, -1, {0, 1}, {0, 0}},
385 {0, -1, {1, 0}, {0, 0}},
386 {2, -1, {1, 1}, {0, 0}},
387 {2, -1, {2, 0}, {0, 0}},
388 {2, -1, {2, 1}, {0, 0}},
389 {3, -1, {3, 0}, {0, 0}},
390 {3, -1, {3, 1}, {0, 0}}},
401 globalIndexOffsets.at(context.rank));
1032 int meshDimension = inMeshSpec.at(0).position.size();
1033 int valueDimension = inMeshSpec.at(0).value.size();
1042 BOOST_TEST_MESSAGE(
"Mesh sizes in: " << inMesh->
nVertices() <<
" out: " << outMesh->
nVertices());
1045 BOOST_TEST_MESSAGE(
"Basis function has support radius " << fct.
getSupportRadius());
1054 mapping.setMeshes(inMesh, outMesh);
1055 mapping.tagMeshFirstRound();
1057 const auto &taggedMesh = consistent ? inMesh : outMesh;
1061 for (
const auto &vspec : shouldTagFirstRound) {
1062 expectedFirst.
emplace(vspec.asEigen());
1065 for (
const auto &v : taggedMesh->vertices()) {
1066 bool found = expectedFirst.
count(v.getCoords()) != 0;
1067 BOOST_TEST((!found || v.isTagged()),
1068 "FirstRound: Vertex " << v <<
" is tagged, but should not be.");
1069 BOOST_TEST((found || !v.isTagged()),
1070 "FirstRound: Vertex " << v <<
" is not tagged, but should be.");
1075 expectedFirst.
begin(), expectedFirst.
end());
1076 for (
const auto &vspec : shouldTagSecondRound) {
1077 expectedSecond.
emplace(vspec.asEigen());
1080 mapping.tagMeshSecondRound();
1082 for (
const auto &v : taggedMesh->vertices()) {
1083 bool found = expectedSecond.
count(v.getCoords()) != 0;
1084 BOOST_TEST((!found || v.isTagged()),
1085 "SecondRound: Vertex " << v <<
" is tagged, but should not be.");
1086 BOOST_TEST((found || !v.isTagged()),
1087 "SecondRound: Vertex " << v <<
" is not tagged, but should be.");
1155 using Eigen::Vector2d;
1160 int inDataID = inData->
getID();
1168 auto &values = inData->
values();
1169 values << 1.0, 2.0, 2.0, 1.0;
1174 int outDataID = outData->
getID();
1180 mapping.setMeshes(inMesh, outMesh);
1181 BOOST_TEST(mapping.hasComputedMapping() ==
false);
1184 mapping.computeMapping();
1185 Eigen::VectorXd guess;
1186 mapping.map(inDataID, outDataID, guess);
1187 double value = outData->
values()(0);
1188 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1189 BOOST_TEST(value == 1.0);
1190 BOOST_TEST(guess.size() > 0);
1194 mapping.computeMapping();
1195 mapping.map(inDataID, outDataID, guess);
1196 value = outData->
values()(0);
1197 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1198 BOOST_TEST(value == 1.0);
1199 BOOST_TEST(guess.size() > 0);
1203 mapping.computeMapping();
1204 mapping.map(inDataID, outDataID, guess);
1205 value = outData->
values()(0);
1206 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1207 BOOST_TEST(value == 1.0);
1208 BOOST_TEST(guess.size() > 0);
1212 mapping.computeMapping();
1213 mapping.map(inDataID, outDataID, guess);
1214 value = outData->
values()(0);
1215 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1216 BOOST_TEST(value == 2.0);
1217 BOOST_TEST(guess.size() > 0);
1221 mapping.computeMapping();
1222 mapping.map(inDataID, outDataID, guess);
1223 value = outData->
values()(0);
1224 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1225 BOOST_TEST(value == 2.0);
1226 BOOST_TEST(guess.size() > 0);
1230 mapping.computeMapping();
1231 mapping.map(inDataID, outDataID, guess);
1232 value = outData->
values()(0);
1233 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1234 BOOST_TEST(value == 2.0);
1235 BOOST_TEST(guess.size() > 0);
1239 mapping.computeMapping();
1240 mapping.map(inDataID, outDataID, guess);
1241 value = outData->
values()(0);
1242 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1243 BOOST_TEST(value == 1.5);
1244 BOOST_TEST(guess.size() > 0);
1248 mapping.computeMapping();
1249 mapping.map(inDataID, outDataID, guess);
1250 value = outData->
values()(0);
1251 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1252 BOOST_TEST(value == 1.5);
1253 BOOST_TEST(guess.size() > 0);
1257 mapping.computeMapping();
1258 mapping.map(inDataID, outDataID, guess);
1259 value = outData->
values()(0);
1260 BOOST_TEST(mapping.hasComputedMapping() ==
true);
1261 BOOST_TEST(value == 1.5);
1262 BOOST_TEST(guess.size() > 0);
1268 using Eigen::Vector2d;
1273 int inDataID = inData->
getID();
1281 auto &values = inData->
values();
1282 values << 1.0, 4.0, 2.0, 5.0, 2.0, 5.0, 1.0, 4.0;
1287 int outDataID = outData->
getID();
1298 Eigen::VectorXd guess;
1299 mapping.
map(inDataID, outDataID, guess);
1300 double value1 = outData->
values()(0);
1301 double value2 = outData->
values()(1);
1303 BOOST_TEST(value1 == 1.0);
1304 BOOST_TEST(value2 == 4.0);
1305 BOOST_TEST(guess.size() > 0);
1310 mapping.
map(inDataID, outDataID, guess);
1311 value1 = outData->
values()(0);
1312 value2 = outData->
values()(1);
1314 BOOST_TEST(value1 == 1.0);
1315 BOOST_TEST(value2 == 4.0);
1316 BOOST_TEST(guess.size() > 0);
1321 mapping.
map(inDataID, outDataID, guess);
1322 value1 = outData->
values()(0);
1323 value2 = outData->
values()(1);
1325 BOOST_TEST(value1 == 1.0);
1326 BOOST_TEST(value2 == 4.0);
1327 BOOST_TEST(guess.size() > 0);
1332 mapping.
map(inDataID, outDataID, guess);
1333 value1 = outData->
values()(0);
1334 value2 = outData->
values()(1);
1336 BOOST_TEST(value1 == 2.0);
1337 BOOST_TEST(value2 == 5.0);
1338 BOOST_TEST(guess.size() > 0);
1343 mapping.
map(inDataID, outDataID, guess);
1344 value1 = outData->
values()(0);
1345 value2 = outData->
values()(1);
1347 BOOST_TEST(value1 == 2.0);
1348 BOOST_TEST(value2 == 5.0);
1349 BOOST_TEST(guess.size() > 0);
1354 mapping.
map(inDataID, outDataID, guess);
1355 value1 = outData->
values()(0);
1356 value2 = outData->
values()(1);
1358 BOOST_TEST(value1 == 2.0);
1359 BOOST_TEST(value2 == 5.0);
1360 BOOST_TEST(guess.size() > 0);
1365 mapping.
map(inDataID, outDataID, guess);
1366 value1 = outData->
values()(0);
1367 value2 = outData->
values()(1);
1369 BOOST_TEST(value1 == 1.5);
1370 BOOST_TEST(value2 == 4.5);
1371 BOOST_TEST(guess.size() > 0);
1376 mapping.
map(inDataID, outDataID, guess);
1377 value1 = outData->
values()(0);
1378 value2 = outData->
values()(1);
1380 BOOST_TEST(value1 == 1.5);
1381 BOOST_TEST(value2 == 4.5);
1382 BOOST_TEST(guess.size() > 0);
1387 mapping.
map(inDataID, outDataID, guess);
1388 value1 = outData->
values()(0);
1389 value2 = outData->
values()(1);
1391 BOOST_TEST(value1 == 1.5);
1392 BOOST_TEST(value2 == 4.5);
1393 BOOST_TEST(guess.size() > 0);
1403 int inDataID = inData->
getID();
1415 auto &values = inData->
values();
1416 values << 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0;
1421 int outDataID = outData->
getID();
1430 vertex.
setCoords(Eigen::Vector3d(0.0, 0.0, 0.0));
1432 Eigen::VectorXd guess;
1433 mapping.
map(inDataID, outDataID, guess);
1434 double value = outData->
values()(0);
1436 BOOST_TEST(value == 1.0);
1437 BOOST_TEST(guess.size() > 0);
1440 vertex.
setCoords(Eigen::Vector3d(0.0, 0.5, 0.0));
1442 mapping.
map(inDataID, outDataID, guess);
1443 value = outData->
values()(0);
1445 BOOST_TEST(value == 1.0);
1446 BOOST_TEST(guess.size() > 0);
1449 vertex.
setCoords(Eigen::Vector3d(0.5, 0.5, 0.0));
1451 mapping.
map(inDataID, outDataID, guess);
1452 value = outData->
values()(0);
1454 BOOST_TEST(value == 1.0);
1455 BOOST_TEST(guess.size() > 0);
1458 vertex.
setCoords(Eigen::Vector3d(1.0, 0.0, 0.0));
1460 mapping.
map(inDataID, outDataID, guess);
1461 value = outData->
values()(0);
1463 BOOST_TEST(value == 1.0);
1464 BOOST_TEST(guess.size() > 0);
1467 vertex.
setCoords(Eigen::Vector3d(1.0, 1.0, 0.0));
1469 mapping.
map(inDataID, outDataID, guess);
1470 value = outData->
values()(0);
1472 BOOST_TEST(value == 1.0);
1473 BOOST_TEST(guess.size() > 0);
1476 vertex.
setCoords(Eigen::Vector3d(0.0, 0.0, 1.0));
1478 mapping.
map(inDataID, outDataID, guess);
1479 value = outData->
values()(0);
1481 BOOST_TEST(value == 2.0);
1482 BOOST_TEST(guess.size() > 0);
1485 vertex.
setCoords(Eigen::Vector3d(1.0, 0.0, 1.0));
1487 mapping.
map(inDataID, outDataID, guess);
1488 value = outData->
values()(0);
1490 BOOST_TEST(value == 2.0);
1491 BOOST_TEST(guess.size() > 0);
1494 vertex.
setCoords(Eigen::Vector3d(1.0, 1.0, 1.0));
1496 mapping.
map(inDataID, outDataID, guess);
1497 value = outData->
values()(0);
1499 BOOST_TEST(value == 2.0);
1500 BOOST_TEST(guess.size() > 0);
1503 vertex.
setCoords(Eigen::Vector3d(0.5, 0.5, 1.0));
1505 mapping.
map(inDataID, outDataID, guess);
1506 value = outData->
values()(0);
1508 BOOST_TEST(value == 2.0);
1509 BOOST_TEST(guess.size() > 0);
1512 vertex.
setCoords(Eigen::Vector3d(0.0, 0.0, 0.5));
1514 mapping.
map(inDataID, outDataID, guess);
1515 value = outData->
values()(0);
1517 BOOST_TEST(value, 1.5);
1518 BOOST_TEST(guess.size() > 0);
1521 vertex.
setCoords(Eigen::Vector3d(1.0, 0.0, 0.5));
1523 mapping.
map(inDataID, outDataID, guess);
1524 value = outData->
values()(0);
1526 BOOST_TEST(value == 1.5);
1527 BOOST_TEST(guess.size() > 0);
1530 vertex.
setCoords(Eigen::Vector3d(0.0, 1.0, 0.5));
1532 mapping.
map(inDataID, outDataID, guess);
1533 value = outData->
values()(0);
1535 BOOST_TEST(value == 1.5);
1536 BOOST_TEST(guess.size() > 0);
1539 vertex.
setCoords(Eigen::Vector3d(1.0, 1.0, 0.5));
1541 mapping.
map(inDataID, outDataID, guess);
1542 value = outData->
values()(0);
1544 BOOST_TEST(value == 1.5);
1545 BOOST_TEST(guess.size() > 0);
1548 vertex.
setCoords(Eigen::Vector3d(0.5, 0.5, 0.5));
1550 mapping.
map(inDataID, outDataID, guess);
1551 value = outData->
values()(0);
1553 BOOST_TEST(value == 1.5);
1554 BOOST_TEST(guess.size() > 0);
1616 int inDataID = inData->
getID();
1617 auto & inV1 = inMesh->
createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
1618 auto & inV2 = inMesh->
createVertex(Eigen::Vector3d(1.0, 0.0, 0.0));
1619 auto & inV3 = inMesh->
createVertex(Eigen::Vector3d(0.0, 1.0, 0.5));
1620 auto & inV4 = inMesh->
createVertex(Eigen::Vector3d(2.0, 0.0, 0.0));
1621 auto & inV5 = inMesh->
createVertex(Eigen::Vector3d(0.0, 2.0, 0.0));
1622 auto & inV6 = inMesh->
createVertex(Eigen::Vector3d(0.0, 2.0, 1.0));
1623 auto & inE1 = inMesh->
createEdge(inV1, inV2);
1624 auto & inE2 = inMesh->
createEdge(inV2, inV3);
1625 auto & inE3 = inMesh->
createEdge(inV1, inV3);
1626 auto & inE4 = inMesh->
createEdge(inV4, inV5);
1627 auto & inE5 = inMesh->
createEdge(inV5, inV6);
1628 auto & inE6 = inMesh->
createEdge(inV4, inV6);
1635 auto &inValues = inData->
values();
1636 inValues << 1.0, 2.0, 4.0, 6.0, 8.0, 9.0;
1641 int outDataID = outData->
getID();
1642 auto & outV1 = outMesh->
createVertex(Eigen::Vector3d(0.0, 0.0, 0.0));
1643 auto & outV2 = outMesh->
createVertex(Eigen::Vector3d(1.0, 0.0, 0.0));
1644 auto & outV3 = outMesh->
createVertex(Eigen::Vector3d(0.0, 1.1, 0.6));
1645 auto & outE1 = outMesh->
createEdge(outV1, outV2);
1646 auto & outE2 = outMesh->
createEdge(outV2, outV3);
1647 auto & outE3 = outMesh->
createEdge(outV1, outV3);
1658 Eigen::VectorXd guess;
1659 mapping.
map(inDataID, outDataID, guess);
1660 BOOST_TEST(guess.size() > 0);
1667 const int dimensions = 2;
1668 const double tolerance = 1e-6;
1669 using Eigen::Vector2d;
1674 int inDataID = inData->
getID();
1678 inData->
values() << 1.0, 2.0;
1684 int outDataID = outData->
getID();
1692 auto &values = outData->
values();
1700 Eigen::VectorXd guess;
1701 mapping.
map(inDataID, outDataID, guess);
1703 BOOST_TEST(
testing::equals(values, Eigen::Vector4d(0.5, 0.5, 1.0, 1.0), tolerance));
1704 BOOST_TEST(guess.size() > 0);
1710 mapping.
map(inDataID, outDataID, guess);
1712 BOOST_TEST(
testing::equals(values, Eigen::Vector4d(0.5, 1.0, 1.0, 0.5), tolerance));
1713 BOOST_TEST(guess.size() > 0);
1719 mapping.
map(inDataID, outDataID, guess);
1721 BOOST_TEST(
testing::equals(values, Eigen::Vector4d(0.0, 2.0, 0.0, 1.0), tolerance));
1722 BOOST_TEST(guess.size() > 0);
1728 mapping.
map(inDataID, outDataID, guess);
1730 BOOST_TEST(
testing::equals(values, Eigen::Vector4d(1.0, 0.0, 2.0, 0.0), tolerance));
1731 BOOST_TEST(guess.size() > 0);
1737 mapping.
map(inDataID, outDataID, guess);
1739 BOOST_TEST(values.sum() == 3.0);
1740 BOOST_TEST(guess.size() > 0);
1745 const int dimensions = 2;
1746 const double tolerance = 1e-6;
1747 using Eigen::Vector2d;
1752 int inDataID = inData->
getID();
1756 inData->
values() << 1.0, 4.0, 2.0, 5.0;
1762 int outDataID = outData->
getID();
1770 auto &values = outData->
values();
1778 Eigen::VectorXd guess;
1779 mapping.
map(inDataID, outDataID, guess);
1781 Eigen::VectorXd refValues(8);
1782 refValues << 0.5, 2, 0.5, 2, 1.0, 2.5, 1.0, 2.5;
1784 BOOST_TEST(guess.size() > 0);
1790 mapping.
map(inDataID, outDataID, guess);
1792 refValues << 0.5, 2, 1.0, 2.5, 1.0, 2.5, 0.5, 2;
1794 BOOST_TEST(guess.size() > 0);
1800 mapping.
map(inDataID, outDataID, guess);
1802 refValues << 0.0, 0.0, 2.0, 5.0, 0.0, 0.0, 1.0, 4.0;
1804 BOOST_TEST(guess.size() > 0);
1810 mapping.
map(inDataID, outDataID, guess);
1812 refValues << 1.0, 4.0, 0.0, 0.0, 2.0, 5.0, 0.0, 0.0;
1814 BOOST_TEST(guess.size() > 0);
1820 mapping.
map(inDataID, outDataID, guess);
1822 BOOST_TEST(values.sum() == 12.0);
1823 BOOST_TEST(guess.size() > 0);
1828 using Eigen::Vector3d;
1834 int inDataID = inData->
getID();
1838 inData->
values() << 1.0, 2.0;
1844 int outDataID = outData->
getID();
1856 auto & values = outData->
values();
1857 double expectedSum = inData->
values().sum();
1862 vertex0.
setCoords(Vector3d(0.5, 0.0, 0.0));
1863 vertex1.
setCoords(Vector3d(0.5, 1.0, 0.0));
1865 Eigen::VectorXd guess;
1866 mapping.
map(inDataID, outDataID, guess);
1868 BOOST_TEST(values.sum() == expectedSum);
1869 BOOST_TEST(guess.size() > 0);
2053 using Eigen::Vector2d;
2062 {{xDead, yDead, zDead}});
2066 mesh::PtrData inData = inMesh->createData(
"InData", 1, 0_dataID);
2067 int inDataID = inData->
getID();
2068 inMesh->createVertex(Vector2d(0.0, 1.0));
2069 inMesh->createVertex(Vector2d(1.0, 1.0));
2070 inMesh->createVertex(Vector2d(2.0, 1.0));
2071 inMesh->createVertex(Vector2d(3.0, 1.0));
2072 inMesh->allocateDataValues();
2075 auto &values = inData->
values();
2076 values << 1.0, 2.0, 2.0, 1.0;
2081 int outDataID = outData->
getID();
2087 mapping.setMeshes(inMesh, outMesh);
2088 BOOST_TEST(mapping.hasComputedMapping() ==
false);
2091 mapping.computeMapping();
2092 Eigen::VectorXd guess;
2093 mapping.map(inDataID, outDataID, guess);
2094 double value = outData->
values()(0);
2095 BOOST_TEST(mapping.hasComputedMapping() ==
true);
2096 BOOST_TEST(value == 1.0);
2097 BOOST_TEST(guess.size() > 0);
2103 using Eigen::Vector3d;
2106 double supportRadius = 1.2;
2116 mesh::PtrData inData = inMesh->createData(
"InData", 1, 0_dataID);
2117 int inDataID = inData->
getID();
2118 inMesh->createVertex(Vector3d(0.0, 3.0, 0.0));
2119 inMesh->createVertex(Vector3d(1.0, 3.0, 0.0));
2120 inMesh->createVertex(Vector3d(0.0, 3.0, 1.0));
2121 inMesh->createVertex(Vector3d(1.0, 3.0, 1.0));
2122 inMesh->allocateDataValues();
2125 auto &values = inData->
values();
2126 values << 1.0, 2.0, 3.0, 4.0;
2131 int outDataID = outData->
getID();
2140 mapping.setMeshes(inMesh, outMesh);
2141 BOOST_TEST(mapping.hasComputedMapping() ==
false);
2143 mapping.computeMapping();
2144 Eigen::VectorXd guess;
2145 mapping.map(inDataID, outDataID, guess);
2146 BOOST_TEST(mapping.hasComputedMapping() ==
true);
2147 BOOST_TEST(guess.size() > 0);
2150 BOOST_TEST(outData->
values()(0) == 1.0);
2151 BOOST_TEST(outData->
values()(1) == 2.0);
2152 BOOST_TEST(outData->
values()(2) == 2.9);
2153 BOOST_TEST(outData->
values()(3) == 4.3);