35 Eigen::VectorXd inValuesScalar = Eigen::VectorXd::Zero(2);
36 Eigen::VectorXd inValuesVector = Eigen::VectorXd::Zero(4);
37 inValuesScalar << 1.0, 2.0;
38 inValuesVector << 1.0, 2.0, 3.0, 4.0;
52 Eigen::VectorXd outValuesScalar = Eigen::VectorXd::Zero(2);
54 mapping.
map(inSample, outValuesScalar);
56 BOOST_TEST(outValuesScalar(0) == inValuesScalar(0));
57 BOOST_TEST(outValuesScalar(1) == inValuesScalar(1));
58 Eigen::VectorXd outValuesVector = Eigen::VectorXd::Zero(4);
60 mapping.
map(inSample, outValuesVector);
61 BOOST_CHECK(equals(inValuesVector, outValuesVector));
68 mapping.
map(inSample, outValuesScalar);
70 BOOST_TEST(outValuesScalar(0) == inValuesScalar(0));
71 BOOST_TEST(outValuesScalar(1) == inValuesScalar(1));
73 mapping.
map(inSample, outValuesVector);
74 BOOST_CHECK(equals(inValuesVector, outValuesVector));
81 mapping.
map(inSample, outValuesScalar);
83 BOOST_TEST(outValuesScalar(1) == inValuesScalar(0));
84 BOOST_TEST(outValuesScalar(0) == inValuesScalar(1));
86 mapping.
map(inSample, outValuesVector);
87 Eigen::Vector4d expected(3.0, 4.0, 1.0, 2.0);
88 BOOST_CHECK(equals(expected, outValuesVector));
94 mapping.
map(inSample, outValuesScalar);
96 BOOST_TEST(outValuesScalar(1) == inValuesScalar(1));
97 BOOST_TEST(outValuesScalar(0) == inValuesScalar(1));
99 mapping.
map(inSample, outValuesVector);
100 expected << 3.0, 4.0, 3.0, 4.0;
101 BOOST_CHECK(equals(expected, outValuesVector));
113 Eigen::VectorXd inValues = Eigen::VectorXd::Zero(2);
129 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(2);
131 mapping.
map(inSample, outValues);
133 BOOST_TEST(outValues(0) == inValues(0));
134 BOOST_TEST(outValues(1) == inValues(1));
135 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
142 mapping.
map(inSample, outValues);
144 BOOST_TEST(outValues(0) == inValues(0));
145 BOOST_TEST(outValues(1) == inValues(1));
146 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
153 mapping.
map(inSample, outValues);
155 BOOST_TEST(outValues(1) == inValues(0));
156 BOOST_TEST(outValues(0) == inValues(1));
157 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
160 outVertex1.
setCoords(Eigen::Vector2d::Constant(-1.0));
163 mapping.
map(inSample, outValues);
165 BOOST_TEST(outValues(0) == inValues(0) + inValues(1));
166 BOOST_TEST(outValues(1) == 0.0);
185 Eigen::VectorXd inValues = Eigen::VectorXd::Zero(4);
210 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(4);
213 mapping.
map(inSample, outValues);
218 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
219 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
222 double scaleFactor = outValues(0) / inValues(0);
223 BOOST_TEST(scaleFactor != 1.0);
225 BOOST_TEST(inValues(0) * scaleFactor == outValues(0));
226 BOOST_TEST(inValues(1) * scaleFactor == outValues(1));
227 BOOST_TEST(inValues(2) * scaleFactor == outValues(2));
228 BOOST_TEST(inValues(3) * scaleFactor == outValues(3));
235 static_assert(N > 1,
"More than 1 vertex required");
238 double dx = (x1 - x0) / (
double) (N - 1);
239 for (
int i = 0; i < N; ++i) {
240 double x = x0 + dx * i;
241 vertices.
push_back(&mesh->createVertex(Eigen::Vector2d{x, 0.0}));
243 auto first = vertices.
begin();
244 auto second = ++vertices.
begin();
245 while (second != vertices.
end()) {
246 mesh->createEdge(**first, **second);
260 PtrMesh inMesh = create2DLinSpaceMesh<4>(
"InMesh", dimensions, 0, 1);
263 PtrMesh outMesh = create2DLinSpaceMesh<3>(
"OutMesh", dimensions, 0, 1);
273 Eigen::VectorXd inValues = Eigen::VectorXd::Zero(4);
275 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
276 mapping.
map(inSample, outValues);
278 BOOST_TEST(!outValues.hasNaN());
279 BOOST_TEST(outValues.isZero());
282 BOOST_TEST(!inputIntegral.hasNaN());
283 BOOST_TEST(inputIntegral.isZero());
286 BOOST_TEST(!outputIntegral.hasNaN());
287 BOOST_TEST(outputIntegral.isZero());
296 PtrMesh inMesh = create2DLinSpaceMesh<4>(
"InMesh", dimensions, 0, 1);
299 PtrMesh outMesh = create2DLinSpaceMesh<3>(
"OutMesh", dimensions, 0, 1);
309 Eigen::Vector4d inValues{1, 1, -1, -1};
311 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
312 mapping.
map(inSample, outValues);
314 BOOST_TEST(!outValues.hasNaN());
315 BOOST_TEST((outValues.array() == 0.0).count() == 0);
318 BOOST_TEST(!inputIntegral.hasNaN());
319 BOOST_TEST(inputIntegral(0) == 0.0);
322 BOOST_TEST(!outputIntegral.hasNaN());
323 BOOST_TEST(outputIntegral(0) == 0.0);
332 PtrMesh inMesh = create2DLinSpaceMesh<4>(
"InMesh", dimensions, 0, 1);
335 PtrMesh outMesh = create2DLinSpaceMesh<3>(
"OutMesh", dimensions, 0, 1);
345 Eigen::VectorXd inValues(8);
346 inValues << 1, 0, 0.5, 0, 1.5, 0, 1, 0;
348 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(6);
349 mapping.
map(inSample, outValues);
351 BOOST_TEST(!outValues.hasNaN());
352 BOOST_TEST((outValues.array() == 0.0).count() == 3);
355 BOOST_TEST(!inputIntegral.hasNaN());
356 BOOST_TEST(inputIntegral(0) == 1.0);
357 BOOST_TEST(inputIntegral(1) == 0.0);
360 BOOST_TEST(!outputIntegral.hasNaN());
361 BOOST_TEST(outputIntegral(0) == 1.0);
362 BOOST_TEST(outputIntegral(1) == 0.0);
371 PtrMesh inMesh = create2DLinSpaceMesh<4>(
"InMesh", dimensions, 0, 1);
374 PtrMesh outMesh = create2DLinSpaceMesh<3>(
"OutMesh", dimensions, 0, 1);
384 Eigen::VectorXd inValues(8);
385 inValues << 2, 1, 3, 1, 1, -1, 2, -1;
387 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(6);
388 mapping.
map(inSample, outValues);
390 BOOST_TEST(!outValues.hasNaN());
391 BOOST_TEST((outValues.array() == 0.0).count() == 0);
394 BOOST_TEST(!inputIntegral.hasNaN());
395 BOOST_TEST(inputIntegral(0) == 2.0);
396 BOOST_TEST(inputIntegral(1) == 0.0);
399 BOOST_TEST(!outputIntegral.hasNaN());
400 BOOST_TEST(outputIntegral(0) == 2.0);
401 BOOST_TEST(outputIntegral(1) == 0.0);
423 Eigen::VectorXd inValues(5);
448 Eigen::VectorXd outValues(5);
451 mapping.
map(inSample, outValues);
458 Eigen::VectorXd expectedIntegral(1);
459 expectedIntegral << 3.0;
461 BOOST_TEST(inputIntegral(0) == expectedIntegral(0));
463 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
464 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
467 double scaleFactor = outValues(0) / inValues(0);
468 BOOST_TEST(scaleFactor != 1.0);
470 BOOST_TEST(
math::equals(inValues(0) * scaleFactor, outValues(0)));
471 BOOST_TEST(inValues(1) * scaleFactor == outValues(1));
472 BOOST_TEST(inValues(2) * scaleFactor == outValues(2));
473 BOOST_TEST(inValues(3) * scaleFactor == outValues(3));
494 Eigen::VectorXd inValues(5);
518 Eigen::VectorXd outValues(5);
521 mapping.
map(inSample, outValues);
528 Eigen::VectorXd expectedIntegral(1);
529 expectedIntegral << 6.5 * 1. / 12;
531 BOOST_TEST(inputIntegral(0) == expectedIntegral(0));
533 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
534 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
537 double scaleFactor = outValues(0) / inValues(0);
538 BOOST_TEST(scaleFactor != 1.0);
540 BOOST_TEST(
math::equals(inValues(0) * scaleFactor, outValues(0)));
541 BOOST_TEST(inValues(1) * scaleFactor == outValues(1));
542 BOOST_TEST(inValues(2) * scaleFactor == outValues(2));
543 BOOST_TEST(inValues(3) * scaleFactor == outValues(3));
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ConsistentNonIncremental)
#define PRECICE_TEST(...)
@ SCALED_CONSISTENT_VOLUME
@ SCALED_CONSISTENT_SURFACE
void setMeshes(const mesh::PtrMesh &input, const mesh::PtrMesh &output)
Sets input and output meshes carrying data to be mapped.
bool hasComputedMapping() const
Returns true, if the mapping has been computed.
void map(int inputDataID, int outputDataID)
void computeMapping() final override
Computes the mapping coefficients from the in- and output mesh.
Mapping using nearest neighboring vertices.
Container and creator for meshes.
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
Tetrahedron & createTetrahedron(Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree, Vertex &vertexFour)
Creates and initializes a Tetrahedron object.
Edge & createEdge(Vertex &vertexOne, Vertex &vertexTwo)
Creates and initializes an Edge object.
Vertex & createVertex(const Eigen::VectorXd &coords)
Creates and initializes a Vertex object.
void setCoords(const VECTOR_T &coordinates)
Sets the coordinates of the vertex.
Eigen::VectorXd getCoords() const
Returns the coordinates of the vertex.
constexpr bool equals(const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares two Eigen::MatrixBase for equality up to tolerance.
provides Mesh, Data and primitives.
Eigen::VectorXd integrateSurface(const PtrMesh &mesh, const Eigen::VectorXd &input)
Given the data and the mesh, this function returns the surface integral. Assumes no overlap exists fo...
Eigen::VectorXd integrateVolume(const PtrMesh &mesh, const Eigen::VectorXd &input)
Given the data and the mesh, this function returns the volume integral. Assumes no overlap exists for...
boost::test_tools::predicate_result equals(const std::vector< float > &VectorA, const std::vector< float > &VectorB, float tolerance)
equals to be used in tests. Compares two std::vectors using a given tolerance. Prints both operands o...
Main namespace of the precice library.