TEST_F(OGSIOVer4InterfaceTest, StillCorrectTINWihtAdditionalValueAtEndOfLine) { std::string tin_fname(BaseLib::BuildInfo::tests_tmp_path+"Surface.tin"); std::ofstream tin_out (tin_fname); tin_out << "0 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 1.0 10\n"; tin_out << "1 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 1.0\n"; tin_out.close(); // read geometry GeoLib::GEOObjects geometries; std::vector<std::string> errors; std::string geometry_name("TestGeometry"); FileIO::Legacy::readGLIFileV4(_gli_fname, geometries, geometry_name, errors, "dummy_for_gmsh_path"); std::vector<GeoLib::Surface*> const* sfcs(geometries.getSurfaceVec(geometry_name)); ASSERT_TRUE(sfcs != nullptr); ASSERT_EQ(1u, geometries.getSurfaceVec(geometry_name)->size()); ASSERT_EQ(2u, (*geometries.getSurfaceVec(geometry_name))[0]->getNumberOfTriangles()); std::remove(tin_fname.c_str()); }
TEST_F(OGSIOVer4InterfaceTest, InvalidTIN_ZeroAreaTri) { std::string tin_fname(BaseLib::BuildInfo::tests_tmp_path+"Surface.tin"); std::ofstream tin_out (tin_fname); tin_out << "0 0.0 0.0 0.0 1.0 0.0.0 0.0 0.0 0.0\n"; tin_out.close(); // read geometry GeoLib::GEOObjects geometries; std::vector<std::string> errors; std::string geometry_name("TestGeometry"); FileIO::Legacy::readGLIFileV4(_gli_fname, geometries, geometry_name, errors, "dummy_for_gmsh_path"); std::vector<GeoLib::Surface*> const* sfcs(geometries.getSurfaceVec(geometry_name)); ASSERT_TRUE(sfcs == nullptr); std::remove(tin_fname.c_str()); }
TEST(GeoLib, SurfaceIsPointInSurface) { std::vector<std::function<double(double, double)>> surface_functions; surface_functions.push_back(constant); surface_functions.push_back(coscos); for (auto f : surface_functions) { std::random_device rd; std::string name("Surface"); // generate ll and ur in random way std::mt19937 random_engine_mt19937(rd()); std::normal_distribution<> normal_dist_ll(-10, 2); std::normal_distribution<> normal_dist_ur(10, 2); MathLib::Point3d ll(std::array<double,3>({{ normal_dist_ll(random_engine_mt19937), normal_dist_ll(random_engine_mt19937), 0.0 } })); MathLib::Point3d ur(std::array<double,3>({{ normal_dist_ur(random_engine_mt19937), normal_dist_ur(random_engine_mt19937), 0.0 } })); for (std::size_t k(0); k<3; ++k) if (ll[k] > ur[k]) std::swap(ll[k], ur[k]); // random discretization of the domain std::default_random_engine re(rd()); std::uniform_int_distribution<std::size_t> uniform_dist(2, 25); std::array<std::size_t,2> n_steps = {{uniform_dist(re),uniform_dist(re)}}; std::unique_ptr<MeshLib::Mesh> sfc_mesh( MeshLib::MeshGenerator::createSurfaceMesh( name, ll, ur, n_steps, f ) ); // random rotation angles std::normal_distribution<> normal_dist_angles( 0, boost::math::double_constants::two_pi); std::array<double,3> euler_angles = {{ normal_dist_angles(random_engine_mt19937), normal_dist_angles(random_engine_mt19937), normal_dist_angles(random_engine_mt19937) } }; MathLib::DenseMatrix<double, std::size_t> rot_mat(getRotMat( euler_angles[0], euler_angles[1], euler_angles[2])); std::vector<MeshLib::Node*> const& nodes(sfc_mesh->getNodes()); GeoLib::rotatePoints<MeshLib::Node>(rot_mat, nodes); MathLib::Vector3 const normal(0,0,1.0); MathLib::Vector3 const surface_normal(rot_mat * normal); double const eps(1e-6); MathLib::Vector3 const displacement(eps * surface_normal); GeoLib::GEOObjects geometries; MeshLib::convertMeshToGeo(*sfc_mesh, geometries); std::vector<GeoLib::Surface*> const& sfcs(*geometries.getSurfaceVec(name)); GeoLib::Surface const*const sfc(sfcs.front()); std::vector<GeoLib::Point*> const& pnts(*geometries.getPointVec(name)); // test triangle edge point of the surface triangles for (auto const p : pnts) { EXPECT_TRUE(sfc->isPntInSfc(*p)); MathLib::Point3d q(*p); for (std::size_t k(0); k<3; ++k) q[k] += displacement[k]; EXPECT_FALSE(sfc->isPntInSfc(q)); } // test edge middle points of the triangles for (std::size_t k(0); k<sfc->getNTriangles(); ++k) { MathLib::Point3d p, q, r; std::tie(p,q,r) = getEdgeMiddlePoints(*(*sfc)[k]); EXPECT_TRUE(sfc->isPntInSfc(p)); EXPECT_TRUE(sfc->isPntInSfc(q)); EXPECT_TRUE(sfc->isPntInSfc(r)); } } }