56 Eigen::VectorXd inValues(3);
57 inValues = Eigen::VectorXd::Constant(inValues.size(), value);
58 Eigen::VectorXd values(2);
59 values = Eigen::VectorXd::Constant(values.size(), 0.0);
64 mapping.
map(inSample, values);
65 BOOST_TEST_CONTEXT(*inMesh)
67 BOOST_TEST(values(0) == value * 1.5);
68 BOOST_TEST(values(1) == value * 1.5);
80 Eigen::VectorXd inValues(3);
81 inValues = Eigen::VectorXd::Constant(inValues.size(), value);
82 Eigen::VectorXd values(2);
83 values = Eigen::VectorXd::Constant(values.size(), 0.0);
88 mapping.
map(inSample, values);
89 BOOST_TEST_CONTEXT(*inMesh)
91 BOOST_TEST(values(0) == value * 2.0);
92 BOOST_TEST(values(1) == value * 1.0);
97 values = Eigen::VectorXd::Constant(values.size(), 0.0);
99 mapping.
map(inSample, values);
100 BOOST_TEST_CONTEXT(*inMesh)
102 BOOST_TEST(values(0) == value * 2.0);
103 BOOST_TEST(values(1) == value * 1.0);
111 using namespace mesh;
119 double valueVertex1 = 1.0;
120 double valueVertex2 = 2.0;
121 Eigen::VectorXd inValues(2);
122 inValues(0) = valueVertex1;
123 inValues(1) = valueVertex2;
140 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
142 mapping.
map(inSample, outValues);
146 BOOST_TEST(outValues(0) == (valueVertex1 + valueVertex2) * 0.5);
147 BOOST_TEST(outValues(1) == valueVertex1);
148 BOOST_TEST(outValues(2) == valueVertex2);
152 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
154 mapping.
map(inSample, outValues);
155 BOOST_TEST(outValues(0) == (valueVertex1 + valueVertex2) * 0.5);
156 BOOST_TEST(outValues(1) == valueVertex1);
157 BOOST_TEST(outValues(2) == valueVertex2);
174 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
175 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
179 mapping.
map(inSample, outValues);
180 BOOST_TEST(outValues(0) == valueVertex1);
181 BOOST_TEST(outValues(1) == valueVertex2);
182 BOOST_TEST(outValues(2) == (valueVertex1 + valueVertex2) * 0.5);
186 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
188 mapping.
map(inSample, outValues);
189 BOOST_TEST(outValues(0) == valueVertex1);
190 BOOST_TEST(outValues(1) == valueVertex2);
191 BOOST_TEST(outValues(2) == (valueVertex1 + valueVertex2) * 0.5);
198 using namespace mesh;
206 double valueVertex1 = 1.0;
207 double valueVertex2 = 2.0;
208 Eigen::VectorXd inValues(2);
209 inValues(0) = valueVertex1;
210 inValues(1) = valueVertex2;
215 Eigen::VectorXd outValues(3);
229 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
235 mapping.
map(inSample, outValues);
238 double scaleFactor = outValues(1) / inValues(0);
239 BOOST_TEST(scaleFactor != 1.0);
243 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
244 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
246 BOOST_TEST(outValues(0) == (inValues(0) + inValues(1)) * 0.5 * scaleFactor);
247 BOOST_TEST(outValues(1) == inValues(0) * scaleFactor);
248 BOOST_TEST(outValues(2) == inValues(1) * scaleFactor);
254 using namespace mesh;
262 double valueVertex1 = 1.0;
263 double valueVertex2 = 2.0;
264 Eigen::VectorXd inValues(2);
265 inValues(0) = valueVertex1;
266 inValues(1) = valueVertex2;
272 Eigen::VectorXd outValues(3);
285 outValues = Eigen::VectorXd::Constant(outValues.size(), 0.0);
289 mapping.
map(inSample, outValues);
292 double scaleFactor = outValues(0) / inValues(0);
293 BOOST_TEST(scaleFactor != 1.0);
297 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
298 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
300 BOOST_TEST(outValues(0) == inValues(0) * scaleFactor);
301 BOOST_TEST(outValues(1) == inValues(1) * scaleFactor);
302 BOOST_TEST(outValues(2) == (inValues(0) + inValues(1)) * 0.5 * scaleFactor);
308 using namespace mesh;
320 double valueVertex1 = 1.0;
321 double valueVertex2 = 2.0;
322 double valueVertex3 = 3.0;
323 Eigen::VectorXd values(3);
324 values(0) = valueVertex1;
325 values(1) = valueVertex2;
326 values(2) = valueVertex3;
340 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
344 mapping.
map(inSample, outValues);
348 BOOST_TEST_CONTEXT(*inMesh)
350 BOOST_TEST(outValues(0) == (valueVertex1 + valueVertex2) * 0.5);
351 BOOST_TEST(outValues(1) == (valueVertex1 + valueVertex3) * 0.5);
352 BOOST_TEST(outValues(2) == (valueVertex2 + valueVertex3) * 0.5);
359 using namespace mesh;
368 double valueVertex1 = 1.0;
369 double valueVertex2 = 2.0;
370 double valueVertex3 = 3.0;
371 Eigen::VectorXd values(3);
372 values(0) = valueVertex1;
373 values(1) = valueVertex2;
374 values(2) = valueVertex3;
389 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(3);
392 mapping.
map(inSample, outValues);
396 BOOST_TEST_CONTEXT(*inMesh)
398 BOOST_TEST(outValues(0) == valueVertex1);
399 BOOST_TEST(outValues(1) == valueVertex2);
400 BOOST_TEST(outValues(2) == valueVertex3);
408 constexpr int dimensions = 3;
425 Eigen::VectorXd inValues = Eigen::VectorXd::Zero(4);
426 inValues << 1.0, 1.0, 1.0, 1.0;
432 Eigen::VectorXd outValues = Eigen::VectorXd::Zero(2);
433 outValues << 0.0, 0.0;
442 BOOST_TEST_INFO(
"In Data:" << inValues);
443 BOOST_TEST_INFO(
"Out Data before Mapping:" << outValues);
445 mapping.
map(inSample, outValues);
446 BOOST_TEST_INFO(
"Out Data after Mapping:" << outValues);
447 BOOST_TEST(outValues == outValues.cwiseAbs());
454 constexpr int dimensions = 3;
458 const double z1 = 0.1;
459 const double z2 = -0.1;
460 auto & v00 = inMesh->
createVertex(Eigen::Vector3d(0, 0, 0));
461 auto & v01 = inMesh->
createVertex(Eigen::Vector3d(0, 1, 0));
462 auto & v10 = inMesh->
createVertex(Eigen::Vector3d(1, 0, z1));
463 auto & v11 = inMesh->
createVertex(Eigen::Vector3d(1, 1, z1));
464 auto & v20 = inMesh->
createVertex(Eigen::Vector3d(2, 0, z2));
465 auto & v21 = inMesh->
createVertex(Eigen::Vector3d(2, 1, z2));
481 Eigen::VectorXd inValues = Eigen::VectorXd::Constant(6, 1.0);
486 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(1, 0.0);
496 BOOST_TEST_INFO(
"In Data:" << inValues);
497 BOOST_TEST_INFO(
"Out Data before Mapping:" << outValues);
499 mapping.
map(inSample, outValues);
500 BOOST_TEST_INFO(
"Out Data after Mapping:" << outValues);
501 BOOST_TEST(outValues(0) == 1.0);
508 constexpr int dimensions = 3;
511 const double z1 = 0.1;
512 const double z2 = -0.1;
513 auto & v00 = inMesh->
createVertex(Eigen::Vector3d(0, 0, 0));
514 auto & v01 = inMesh->
createVertex(Eigen::Vector3d(0, 1, 0));
515 auto & v10 = inMesh->
createVertex(Eigen::Vector3d(1, 0, z1));
516 auto & v11 = inMesh->
createVertex(Eigen::Vector3d(1, 1, z1));
517 auto & v20 = inMesh->
createVertex(Eigen::Vector3d(2, 0, z2));
518 auto & v21 = inMesh->
createVertex(Eigen::Vector3d(2, 1, z2));
534 Eigen::VectorXd inValues = Eigen::VectorXd::Constant(6, 1.0);
537 auto & outV1 = outMesh->
createVertex(Eigen::Vector3d{0.7, 0.5, 0.0});
538 auto & outV2 = outMesh->
createVertex(Eigen::Vector3d{0.5, 0.0, 0.05});
539 auto & outV3 = outMesh->
createVertex(Eigen::Vector3d{0.5, 0.0, 0.0});
540 auto & outE1 = outMesh->
createEdge(outV1, outV2);
541 auto & outE2 = outMesh->
createEdge(outV2, outV3);
542 auto & outE3 = outMesh->
createEdge(outV1, outV3);
544 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(3, 0.0);
555 mapping.
map(inSample, outValues);
560 for (
int dim = 0; dim < inputIntegral.size(); ++dim) {
561 BOOST_TEST(inputIntegral(dim) == outputIntegral(dim));
571 mapping.setMeshes(inMesh, outMesh);
572 BOOST_REQUIRE(mapping.hasComputedMapping() ==
false);
573 mapping.computeMapping();
574 BOOST_REQUIRE(mapping.hasComputedMapping() ==
true);
575 mapping.map(inData->
getID(), outData->
getID());
582 mapping.setMeshes(inMesh, outMesh);
583 BOOST_REQUIRE(mapping.hasComputedMapping() ==
false);
584 mapping.computeMapping();
585 BOOST_REQUIRE(mapping.hasComputedMapping() ==
true);
587 mapping.map(inSample, *outData);
604 constexpr int dimensions = 3;
608 auto &vc0 = inMesh->
createVertex(Eigen::Vector3d(3, 0, 0));
609 auto &vc1 = inMesh->
createVertex(Eigen::Vector3d(3, 2, 0));
610 auto &vc2 = inMesh->
createVertex(Eigen::Vector3d(4, 1, 0));
611 makeTriangle(inMesh, vc0, vc1, vc2);
614 auto &vf0 = inMesh->
createVertex(Eigen::Vector3d(0, 0, -1));
615 auto &vf1 = inMesh->
createVertex(Eigen::Vector3d(0, 2, -1));
616 auto &vf2 = inMesh->
createVertex(Eigen::Vector3d(0, 1, 1));
617 makeTriangle(inMesh, vf0, vf1, vf2);
619 Eigen::VectorXd inValues(5);
620 inValues << 0, 0, 0, 1, 1;
624 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(1, 0.0);
629 BOOST_TEST(values(0) == 0.0);
639 auto &vf0 = inMesh->
createVertex(Eigen::Vector3d(0, 0, -1));
640 auto &vf1 = inMesh->
createVertex(Eigen::Vector3d(0, 1, 1));
641 auto &vf2 = inMesh->
createVertex(Eigen::Vector3d(0, 2, -1));
642 makeTriangle(inMesh, vf0, vf1, vf2);
645 auto &vc0 = inMesh->
createVertex(Eigen::Vector3d(3, 0, 0));
646 auto &vc1 = inMesh->
createVertex(Eigen::Vector3d(3, 2, 0));
647 auto &vc2 = inMesh->
createVertex(Eigen::Vector3d(4, 1, 0));
648 makeTriangle(inMesh, vc0, vc1, vc2);
650 Eigen::VectorXd inValues(6);
651 inValues << 1, 1, 1, 0, 0, 0;
655 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(1, 0.0);
659 BOOST_TEST(values(0) == 1.0);
666 constexpr int dimensions = 3;
670 auto &vc0 = inMesh->
createVertex(Eigen::Vector3d(0, 0, 0));
671 auto &vc1 = inMesh->
createVertex(Eigen::Vector3d(0, 2, 0));
675 auto &vf0 = inMesh->
createVertex(Eigen::Vector3d(3, 0, 0));
676 auto &vf1 = inMesh->
createVertex(Eigen::Vector3d(3, 2, 2));
677 auto &vf2 = inMesh->
createVertex(Eigen::Vector3d(3, 1, 0));
678 makeTriangle(inMesh, vf0, vf1, vf2);
680 Eigen::VectorXd inValues(5);
681 inValues << 0, 1, 2, 2, 2;
685 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(1, 0.0);
691 BOOST_TEST(values(0) == 0.5);
698 constexpr int dimensions = 3;
703 auto &vc0 = inMesh->
createVertex(Eigen::Vector3d(0, 0, 0));
704 auto &vc1 = inMesh->
createVertex(Eigen::Vector3d(0, 2, 2));
705 auto &vc2 = inMesh->
createVertex(Eigen::Vector3d(0, 1, 0));
706 makeTriangle(inMesh, vc0, vc1, vc2);
709 auto &vf0 = inMesh->
createVertex(Eigen::Vector3d(3, 0, 0));
710 auto &vf1 = inMesh->
createVertex(Eigen::Vector3d(3, 2, 2));
711 auto &vf2 = inMesh->
createVertex(Eigen::Vector3d(3, 1, 0));
712 makeTriangle(inMesh, vf0, vf1, vf2);
714 Eigen::VectorXd inValues(6);
715 inValues << 1, 1, 1, 0, 0, 0;
719 Eigen::VectorXd outValues = Eigen::VectorXd::Constant(1, 0.0);
723 BOOST_TEST(values(0) == 1.0);
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(testConservativeNonIncremental)
#define PRECICE_TEST(...)
Constraint
Specifies additional constraints for a mapping.
@ 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)
Mapping using orthogonal projection to nearest triangle/edge/vertex and linear interpolation from pro...
void computeMapping() final override
Computes the projections and interpolation relations.
DataID getID() const
Returns the ID of the data set (supposed to be unique).
Eigen::VectorXd & values()
Returns a reference to the data values.
Linear edge of a mesh, defined by two Vertex objects.
Container and creator for meshes.
Triangle & createTriangle(Edge &edgeOne, Edge &edgeTwo, Edge &edgeThree)
Creates and initializes a Triangle object.
int getDimensions() const
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 allocateDataValues()
Allocates memory for the vertex data values and corresponding gradient values.
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...
Main namespace of the precice library.