diff --git a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp index cc08613c723152a7169b07b763015803115a07ce..99928d989d0d78d186b4b4d9ad2ad3ccbd60e6c7 100644 --- a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp +++ b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp @@ -204,8 +204,9 @@ int main (int argc, char* argv[]) } GeoLib::GEOObjects geometry_sets; - MeshGeoToolsLib::MeshNodeSearcher mesh_searcher(*surface_mesh, - std::move(search_length_strategy)); + MeshGeoToolsLib::MeshNodeSearcher mesh_searcher( + *surface_mesh, std::move(search_length_strategy), + MeshGeoToolsLib::SearchAllNodes::Yes); for(std::size_t k(0); k<plys->size(); k++) { std::vector<std::size_t> ids (mesh_searcher.getMeshNodeIDsAlongPolyline(*((*plys)[k]))); diff --git a/MeshGeoToolsLib/MeshNodeSearcher.cpp b/MeshGeoToolsLib/MeshNodeSearcher.cpp index b60200744ff0bca922216ab21c06893697b0861e..bed40a420808ad625ea03b77af2ff853a5919a78 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.cpp +++ b/MeshGeoToolsLib/MeshNodeSearcher.cpp @@ -34,7 +34,7 @@ std::vector<std::unique_ptr<MeshNodeSearcher>> MeshNodeSearcher::_mesh_node_sear MeshNodeSearcher::MeshNodeSearcher( MeshLib::Mesh const& mesh, MeshGeoToolsLib::SearchLength&& search_length_algorithm, - bool search_all_nodes) + SearchAllNodes search_all_nodes) : _mesh(mesh), _mesh_grid(_mesh.getNodes().cbegin(), _mesh.getNodes().cend()), _search_length_algorithm(std::move(search_length_algorithm)), @@ -109,7 +109,7 @@ MeshNodesOnPoint& MeshNodeSearcher::getMeshNodesOnPoint( _mesh_grid, pnt, _search_length_algorithm.getSearchLength(), - _search_all_nodes)); + _search_all_nodes == SearchAllNodes::Yes)); return *_mesh_nodes_on_points.back(); } @@ -127,7 +127,7 @@ MeshNodesAlongPolyline& MeshNodeSearcher::getMeshNodesAlongPolyline( // compute nodes (and supporting points) along polyline _mesh_nodes_along_polylines.push_back(new MeshNodesAlongPolyline( _mesh, ply, _search_length_algorithm.getSearchLength(), - _search_all_nodes)); + _search_all_nodes == SearchAllNodes::Yes)); return *_mesh_nodes_along_polylines.back(); } @@ -147,7 +147,7 @@ MeshNodesAlongSurface& MeshNodeSearcher::getMeshNodesAlongSurface( new MeshNodesAlongSurface(_mesh, sfc, _search_length_algorithm.getSearchLength(), - _search_all_nodes)); + _search_all_nodes == SearchAllNodes::Yes)); return *_mesh_nodes_along_surfaces.back(); } @@ -174,7 +174,7 @@ MeshNodeSearcher const& MeshNodeSearcher::getMeshNodeSearcher( } _mesh_node_searchers[mesh_id].reset(new MeshGeoToolsLib::MeshNodeSearcher( - mesh, std::move(search_length_algorithm))); + mesh, std::move(search_length_algorithm), SearchAllNodes::Yes)); return *_mesh_node_searchers[mesh_id]; } diff --git a/MeshGeoToolsLib/MeshNodeSearcher.h b/MeshGeoToolsLib/MeshNodeSearcher.h index 747eba76869829fb650b3392d6381569d2c9096b..11c698efcacac5f48f01a1c6bfec5531c34b85f8 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.h +++ b/MeshGeoToolsLib/MeshNodeSearcher.h @@ -17,6 +17,7 @@ // MeshGeoToolsLib #include "MeshGeoToolsLib/SearchLength.h" +#include "MeshGeoToolsLib/SearchAllNodes.h" // forward declaration namespace GeoLib @@ -42,6 +43,7 @@ class MeshNodesAlongSurface; namespace MeshGeoToolsLib { + /** * Class for searching mesh node ids along polylines or points. This ids * can be used to set boundary conditions, source terms, initial conditions @@ -61,7 +63,7 @@ public: */ MeshNodeSearcher(MeshLib::Mesh const& mesh, MeshGeoToolsLib::SearchLength&& search_length_algorithm, - bool search_all_nodes = true); + SearchAllNodes search_all_nodes); virtual ~MeshNodeSearcher(); @@ -146,7 +148,7 @@ private: MeshLib::Mesh const& _mesh; GeoLib::Grid<MeshLib::Node> _mesh_grid; MeshGeoToolsLib::SearchLength _search_length_algorithm; - bool _search_all_nodes; + SearchAllNodes _search_all_nodes; // with newer compiler we can omit to use a pointer here mutable std::vector<MeshNodesOnPoint*> _mesh_nodes_on_points; mutable std::vector<MeshNodesAlongPolyline*> _mesh_nodes_along_polylines; diff --git a/MeshGeoToolsLib/SearchAllNodes.h b/MeshGeoToolsLib/SearchAllNodes.h new file mode 100644 index 0000000000000000000000000000000000000000..d06499911ce1b29dfd8c3a62128ef852ef6ead89 --- /dev/null +++ b/MeshGeoToolsLib/SearchAllNodes.h @@ -0,0 +1,19 @@ +/** + * + * @copyright + * Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ +#pragma once + +namespace MeshGeoToolsLib +{ +enum class SearchAllNodes : bool +{ + Yes = true, + No = false +}; + +} // end namespace MeshGeoToolsLib diff --git a/Tests/MeshLib/TestBoundaryElementSearch.cpp b/Tests/MeshLib/TestBoundaryElementSearch.cpp index 4ee32928d4758bb982755c2aad5d186786d5b422..25a20a4caf40a0e5c877ad6b43e97e8c8abc6a65 100644 --- a/Tests/MeshLib/TestBoundaryElementSearch.cpp +++ b/Tests/MeshLib/TestBoundaryElementSearch.cpp @@ -79,7 +79,8 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleQuadMesh, PolylineSearch) // perform search on the polyline MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, - MeshGeoToolsLib::HeuristicSearchLength(*_quad_mesh)); + MeshGeoToolsLib::HeuristicSearchLength(*_quad_mesh), + MeshGeoToolsLib::SearchAllNodes::Yes); MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(*_quad_mesh, mesh_node_searcher); std::vector<MeshLib::Element*> const& found_edges_ply0(boundary_element_searcher.getBoundaryElements(ply0)); @@ -146,8 +147,9 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleHexMesh, SurfaceSearch) std::unique_ptr<GeoLib::Surface> sfc_front(GeoLib::Surface::createSurface(ply_front)); // perform search on the bottom surface - MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_hex_mesh, - MeshGeoToolsLib::HeuristicSearchLength(*_hex_mesh)); + MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher( + *_hex_mesh, MeshGeoToolsLib::HeuristicSearchLength(*_hex_mesh), + MeshGeoToolsLib::SearchAllNodes::Yes); MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(*_hex_mesh, mesh_node_searcher); std::vector<MeshLib::Element*> const& found_faces_sfc_b(boundary_element_searcher.getBoundaryElements(*sfc_bottom)); ASSERT_EQ(n_eles_2d, found_faces_sfc_b.size()); diff --git a/Tests/MeshLib/TestMeshNodeSearch.cpp b/Tests/MeshLib/TestMeshNodeSearch.cpp index c6240df0367b0785ac19f5fbe01de31d667e8ff3..fbc28fd917b3b9f5c50f98c652a6ff201309f9f5 100644 --- a/Tests/MeshLib/TestMeshNodeSearch.cpp +++ b/Tests/MeshLib/TestMeshNodeSearch.cpp @@ -68,7 +68,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PointSearchEpsHalfEdge) // 2 perform search and compare results with expected vals MeshGeoToolsLib::SearchLength search_length(dx_half); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, - std::move(search_length)); + std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); GeoLib::Point p1(0.0, 0.0, 0.0); EXPECT_EQ(1u, mesh_node_searcher.getMeshNodeIDsForPoint(p1).size()); @@ -94,7 +94,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PointSearchZeroEps) // 2 perform search and compare results with expected vals MeshGeoToolsLib::SearchLength search_length; MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, - std::move(search_length)); + std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); // find ORIGIN GeoLib::Point pnt1(0.0, 0.0, 0.0); @@ -140,7 +140,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) // perform search and compare results with expected vals MeshGeoToolsLib::HeuristicSearchLength search_length(*_quad_mesh); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, - std::move(search_length)); + std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); std::vector<std::size_t> const& found_ids_ply0(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply0)); ASSERT_EQ(100u, found_ids_ply0.size()); @@ -222,7 +222,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, SurfaceSearch) MeshGeoToolsLib::SearchLength search_length; MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, - std::move(search_length)); + std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); // entire domain GeoLib::Polyline ply0(pnts); @@ -273,7 +273,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) MeshGeoToolsLib::SearchLength search_length; MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_hex_mesh, - std::move(search_length)); + std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); const std::size_t n_nodes_1d = _number_of_subdivisions_per_direction + 1; const std::size_t n_nodes_2d = n_nodes_1d * n_nodes_1d; diff --git a/Tests/NumLib/TestDistribution.cpp b/Tests/NumLib/TestDistribution.cpp index 0af55d1d0351b14477e789751b120af1d8a8b24b..4fc9016b8c794d0fff3de8172cfaf5f420ad53e8 100644 --- a/Tests/NumLib/TestDistribution.cpp +++ b/Tests/NumLib/TestDistribution.cpp @@ -29,12 +29,15 @@ class NumLibDistributionQuad : public testing::Test { public: - NumLibDistributionQuad() : - _geometric_size(10.0), _number_of_subdivisions_per_direction(10), - _msh(MeshLib::MeshGenerator::generateRegularQuadMesh(_geometric_size, _number_of_subdivisions_per_direction)), - _project_name("test"), - _mshNodesSearcher(*_msh,MeshGeoToolsLib::SearchLength()), - _ply0(nullptr) + NumLibDistributionQuad() + : _geometric_size(10.0), + _number_of_subdivisions_per_direction(10), + _msh(MeshLib::MeshGenerator::generateRegularQuadMesh( + _geometric_size, _number_of_subdivisions_per_direction)), + _project_name("test"), + _mshNodesSearcher(*_msh, MeshGeoToolsLib::SearchLength(), + MeshGeoToolsLib::SearchAllNodes::Yes), + _ply0(nullptr) { // create geometry auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( @@ -83,12 +86,15 @@ protected: class NumLibDistributionHex : public testing::Test { public: - NumLibDistributionHex() : - _geometric_size(10.0), _number_of_subdivisions_per_direction(10), - _msh(MeshLib::MeshGenerator::generateRegularHexMesh(_geometric_size, _number_of_subdivisions_per_direction)), - _project_name("test"), - _mshNodesSearcher(*_msh,MeshGeoToolsLib::SearchLength()), - _ply0(nullptr) + NumLibDistributionHex() + : _geometric_size(10.0), + _number_of_subdivisions_per_direction(10), + _msh(MeshLib::MeshGenerator::generateRegularHexMesh( + _geometric_size, _number_of_subdivisions_per_direction)), + _project_name("test"), + _mshNodesSearcher(*_msh, MeshGeoToolsLib::SearchLength(), + MeshGeoToolsLib::SearchAllNodes::Yes), + _ply0(nullptr) { // create geometry auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>(