Skip to content
Snippets Groups Projects
Commit 24b0bae1 authored by Tom Fischer's avatar Tom Fischer
Browse files

Constify MeshNodeSearcher, mutable cache.

parent 2cbebbec
No related branches found
No related tags found
No related merge requests found
Showing
with 105 additions and 91 deletions
......@@ -23,9 +23,10 @@
namespace MeshGeoToolsLib
{
BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher, GeoLib::Polyline const& ply)
: _mesh(mesh), _ply(ply)
BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline(
MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Polyline const& ply)
: _mesh(mesh), _ply(ply)
{
// search nodes and elements located along the polyline
auto node_ids_on_poly = mshNodeSearcher.getMeshNodeIDsAlongPolyline(ply);
......
......@@ -37,7 +37,9 @@ public:
* @param mshNodeSearcher a MeshNodeSearcher object which is internally used to search mesh nodes
* @param ply a polyline object where edges are searched
*/
BoundaryElementsAlongPolyline(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher, GeoLib::Polyline const& ply);
BoundaryElementsAlongPolyline(MeshLib::Mesh const& mesh,
MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Polyline const& ply);
/// destructor
virtual ~BoundaryElementsAlongPolyline();
......
......@@ -20,8 +20,8 @@
namespace MeshGeoToolsLib
{
BoundaryElementsAtPoint::BoundaryElementsAtPoint(
MeshLib::Mesh const &mesh, MeshNodeSearcher &mshNodeSearcher,
GeoLib::Point const &point)
MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Point const& point)
: _mesh(mesh), _point(point)
{
auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point);
......
......@@ -35,8 +35,8 @@ public:
/// used to search mesh nodes
/// \param point a point object where edges are searched
BoundaryElementsAtPoint(MeshLib::Mesh const& mesh,
MeshNodeSearcher& mshNodeSearcher,
GeoLib::Point const& point);
MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Point const& point);
~BoundaryElementsAtPoint();
......
......@@ -18,9 +18,10 @@
namespace MeshGeoToolsLib
{
BoundaryElementsOnSurface::BoundaryElementsOnSurface(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher, GeoLib::Surface const& sfc)
: _mesh(mesh), _sfc(sfc)
BoundaryElementsOnSurface::BoundaryElementsOnSurface(
MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Surface const& sfc)
: _mesh(mesh), _sfc(sfc)
{
// search elements near the surface
auto node_ids_on_sfc = mshNodeSearcher.getMeshNodeIDsAlongSurface(sfc);
......
......@@ -37,7 +37,9 @@ public:
* @param mshNodeSearcher a MeshNodeSearcher object which is internally used to search mesh nodes
* @param sfc a surface object where face elements are searched for
*/
BoundaryElementsOnSurface(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher, GeoLib::Surface const& sfc);
BoundaryElementsOnSurface(MeshLib::Mesh const& mesh,
MeshNodeSearcher const& mshNodeSearcher,
GeoLib::Surface const& sfc);
/// destructor
virtual ~BoundaryElementsOnSurface();
......
......@@ -25,8 +25,9 @@
namespace MeshGeoToolsLib
{
BoundaryElementsSearcher::BoundaryElementsSearcher(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher) : _mesh(mesh), _mshNodeSearcher(mshNodeSearcher)
BoundaryElementsSearcher::BoundaryElementsSearcher(
MeshLib::Mesh const& mesh, MeshNodeSearcher const& mshNodeSearcher)
: _mesh(mesh), _mshNodeSearcher(mshNodeSearcher)
{}
BoundaryElementsSearcher::~BoundaryElementsSearcher()
......
......@@ -42,7 +42,8 @@ public:
* @param mesh a mesh object
* @param mshNodeSearcher a MeshNodeSearcher object which is internally used to search mesh nodes
*/
BoundaryElementsSearcher(MeshLib::Mesh const& mesh, MeshNodeSearcher &mshNodeSearcher);
BoundaryElementsSearcher(MeshLib::Mesh const& mesh,
MeshNodeSearcher const& mshNodeSearcher);
/// destructor
virtual ~BoundaryElementsSearcher();
......@@ -79,7 +80,7 @@ public:
private:
MeshLib::Mesh const& _mesh;
MeshNodeSearcher &_mshNodeSearcher;
MeshNodeSearcher const& _mshNodeSearcher;
std::vector<BoundaryElementsAtPoint*> _boundary_elements_at_point;
std::vector<BoundaryElementsAlongPolyline*> _boundary_elements_along_polylines;
std::vector<BoundaryElementsOnSurface*> _boundary_elements_along_surfaces;
......
......@@ -54,7 +54,8 @@ MeshNodeSearcher::~MeshNodeSearcher()
delete pointer;
}
std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs(GeoLib::GeoObject const& geoObj)
std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs(
GeoLib::GeoObject const& geoObj) const
{
std::vector<std::size_t> vec_nodes;
switch (geoObj.getGeoType()) {
......@@ -75,24 +76,26 @@ std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs(GeoLib::GeoObject cons
return vec_nodes;
}
std::vector<std::size_t> const&
MeshNodeSearcher::getMeshNodeIDsForPoint(GeoLib::Point const& pnt)
std::vector<std::size_t> const& MeshNodeSearcher::getMeshNodeIDsForPoint(
GeoLib::Point const& pnt) const
{
return getMeshNodesOnPoint(pnt).getNodeIDs();
}
std::vector<std::size_t> const& MeshNodeSearcher::getMeshNodeIDsAlongPolyline(
GeoLib::Polyline const& ply)
GeoLib::Polyline const& ply) const
{
return getMeshNodesAlongPolyline(ply).getNodeIDs();
}
std::vector<std::size_t> const& MeshNodeSearcher::getMeshNodeIDsAlongSurface(GeoLib::Surface const& sfc)
std::vector<std::size_t> const& MeshNodeSearcher::getMeshNodeIDsAlongSurface(
GeoLib::Surface const& sfc) const
{
return getMeshNodesAlongSurface(sfc).getNodeIDs();
}
MeshNodesOnPoint& MeshNodeSearcher::getMeshNodesOnPoint(GeoLib::Point const& pnt)
MeshNodesOnPoint& MeshNodeSearcher::getMeshNodesOnPoint(
GeoLib::Point const& pnt) const
{
std::vector<MeshNodesOnPoint*>::const_iterator it(_mesh_nodes_on_points.begin());
for (; it != _mesh_nodes_on_points.end(); ++it) {
......@@ -110,7 +113,8 @@ MeshNodesOnPoint& MeshNodeSearcher::getMeshNodesOnPoint(GeoLib::Point const& pnt
return *_mesh_nodes_on_points.back();
}
MeshNodesAlongPolyline& MeshNodeSearcher::getMeshNodesAlongPolyline(GeoLib::Polyline const& ply)
MeshNodesAlongPolyline& MeshNodeSearcher::getMeshNodesAlongPolyline(
GeoLib::Polyline const& ply) const
{
std::vector<MeshNodesAlongPolyline*>::const_iterator it(_mesh_nodes_along_polylines.begin());
for (; it != _mesh_nodes_along_polylines.end(); ++it) {
......@@ -127,7 +131,8 @@ MeshNodesAlongPolyline& MeshNodeSearcher::getMeshNodesAlongPolyline(GeoLib::Poly
return *_mesh_nodes_along_polylines.back();
}
MeshNodesAlongSurface& MeshNodeSearcher::getMeshNodesAlongSurface(GeoLib::Surface const& sfc)
MeshNodesAlongSurface& MeshNodeSearcher::getMeshNodesAlongSurface(
GeoLib::Surface const& sfc) const
{
std::vector<MeshNodesAlongSurface*>::const_iterator it(_mesh_nodes_along_surfaces.begin());
for (; it != _mesh_nodes_along_surfaces.end(); ++it) {
......@@ -146,7 +151,7 @@ MeshNodesAlongSurface& MeshNodeSearcher::getMeshNodesAlongSurface(GeoLib::Surfac
return *_mesh_nodes_along_surfaces.back();
}
MeshNodeSearcher& MeshNodeSearcher::getMeshNodeSearcher(
MeshNodeSearcher const& MeshNodeSearcher::getMeshNodeSearcher(
MeshLib::Mesh const& mesh,
MeshGeoToolsLib::SearchLength&& search_length_algorithm)
{
......@@ -156,24 +161,19 @@ MeshNodeSearcher& MeshNodeSearcher::getMeshNodeSearcher(
if (_mesh_node_searchers[mesh_id])
{
auto const& m = *_mesh_node_searchers[mesh_id];
// recreate searcher if search length algorithm does not fit
if (typeid(_mesh_node_searchers[mesh_id]->_search_length_algorithm) !=
typeid(search_length_algorithm) ||
_mesh_node_searchers[mesh_id]
->_search_length_algorithm.getSearchLength() !=
if (typeid(m._search_length_algorithm) ==
typeid(search_length_algorithm) &&
m._search_length_algorithm.getSearchLength() ==
search_length_algorithm.getSearchLength())
{
_mesh_node_searchers[mesh_id].reset(
new MeshGeoToolsLib::MeshNodeSearcher(
mesh, std::move(search_length_algorithm)));
return m;
}
}
else
{
_mesh_node_searchers[mesh_id].reset(
new MeshGeoToolsLib::MeshNodeSearcher(
mesh, std::move(search_length_algorithm)));
}
_mesh_node_searchers[mesh_id].reset(new MeshGeoToolsLib::MeshNodeSearcher(
mesh, std::move(search_length_algorithm)));
return *_mesh_node_searchers[mesh_id];
}
......
......@@ -70,7 +70,8 @@ public:
* @param geoObj a GeoLib::GeoObject where the nearest mesh node is searched for
* @return a vector of mesh node ids
*/
std::vector<std::size_t> getMeshNodeIDs(GeoLib::GeoObject const& geoObj);
std::vector<std::size_t> getMeshNodeIDs(
GeoLib::GeoObject const& geoObj) const;
/**
* Searches for the node nearest by the given point. If there are two nodes
......@@ -80,7 +81,8 @@ public:
* @param pnt a GeoLib::Point the nearest mesh node is searched for
* @return a vector of mesh node ids
*/
std::vector<std::size_t> const& getMeshNodeIDsForPoint(GeoLib::Point const& pnt);
std::vector<std::size_t> const& getMeshNodeIDsForPoint(
GeoLib::Point const& pnt) const;
/**
* Searches for the nearest mesh nodes along a GeoLib::Polyline.
......@@ -90,7 +92,8 @@ public:
* @param ply the GeoLib::Polyline the nearest mesh nodes are searched for
* @return a vector of mesh node ids
*/
std::vector<std::size_t> const& getMeshNodeIDsAlongPolyline(GeoLib::Polyline const& ply);
std::vector<std::size_t> const& getMeshNodeIDsAlongPolyline(
GeoLib::Polyline const& ply) const;
/**
* Searches for the nearest mesh nodes along a GeoLib::Surface.
......@@ -100,28 +103,31 @@ public:
* @param sfc the GeoLib::Surface the nearest mesh nodes are searched for
* @return a vector of mesh node ids
*/
std::vector<std::size_t> const& getMeshNodeIDsAlongSurface(GeoLib::Surface const& sfc);
std::vector<std::size_t> const& getMeshNodeIDsAlongSurface(
GeoLib::Surface const& sfc) const;
/**
* Return a MeshNodesOnPoint object for the given GeoLib::Point object.
* @param pnt the GeoLib::Point the nearest mesh nodes are searched for
* @return a reference to a MeshNodesOnPoint object
*/
MeshNodesOnPoint& getMeshNodesOnPoint(GeoLib::Point const& pnt);
MeshNodesOnPoint& getMeshNodesOnPoint(GeoLib::Point const& pnt) const;
/**
* Return a MeshNodesAlongPolyline object for the given GeoLib::Polyline object.
* @param ply the GeoLib::Polyline the nearest mesh nodes are searched for
* @return a reference to a MeshNodesAlongPolyline object
*/
MeshNodesAlongPolyline& getMeshNodesAlongPolyline(GeoLib::Polyline const& ply);
MeshNodesAlongPolyline& getMeshNodesAlongPolyline(
GeoLib::Polyline const& ply) const;
/**
* Return a MeshNodesAlongSurface object for the given GeoLib::Surface object.
* @param sfc the GeoLib::Surface the nearest mesh nodes are searched for
* @return a reference to a MeshNodesAlongSurface object
*/
MeshNodesAlongSurface& getMeshNodesAlongSurface(GeoLib::Surface const& sfc);
MeshNodesAlongSurface& getMeshNodesAlongSurface(
GeoLib::Surface const& sfc) const;
/**
* Get the mesh this searcher operates on.
......@@ -132,7 +138,7 @@ public:
* Returns a (possibly new) mesh node searcher for the mesh.
* A new one will be created, if it does not already exists.
*/
static MeshNodeSearcher& getMeshNodeSearcher(
static MeshNodeSearcher const& getMeshNodeSearcher(
MeshLib::Mesh const& mesh,
MeshGeoToolsLib::SearchLength&& search_length_algorithm);
......@@ -142,9 +148,9 @@ private:
MeshGeoToolsLib::SearchLength _search_length_algorithm;
bool _search_all_nodes;
// with newer compiler we can omit to use a pointer here
std::vector<MeshNodesOnPoint*> _mesh_nodes_on_points;
std::vector<MeshNodesAlongPolyline*> _mesh_nodes_along_polylines;
std::vector<MeshNodesAlongSurface*> _mesh_nodes_along_surfaces;
mutable std::vector<MeshNodesOnPoint*> _mesh_nodes_on_points;
mutable std::vector<MeshNodesAlongPolyline*> _mesh_nodes_along_polylines;
mutable std::vector<MeshNodesAlongSurface*> _mesh_nodes_along_surfaces;
/// Mesh node searcher for the meshes indexed by the meshs' ids.
static std::vector<std::unique_ptr<MeshNodeSearcher>> _mesh_node_searchers;
......
......@@ -27,7 +27,7 @@ std::unique_ptr<BoundaryCondition> BoundaryConditionBuilder::createBoundaryCondi
{
MeshGeoToolsLib::SearchLength search_length_algorithm;
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher =
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher =
MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher(
mesh, std::move(search_length_algorithm));
......@@ -66,13 +66,13 @@ std::unique_ptr<BoundaryCondition> BoundaryConditionBuilder::createBoundaryCondi
std::unique_ptr<BoundaryCondition>
BoundaryConditionBuilder::createDirichletBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned /*integration_order*/,
const unsigned /*shapefunction_order*/,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& /*boundary_element_searcher*/)
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned /*integration_order*/,
const unsigned /*shapefunction_order*/,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& /*boundary_element_searcher*/)
{
// Find nodes' ids on the given mesh on which this boundary condition
// is defined.
......@@ -115,13 +115,13 @@ BoundaryConditionBuilder::createDirichletBoundaryCondition(
std::unique_ptr<BoundaryCondition>
BoundaryConditionBuilder::createNeumannBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher const& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
{
return ProcessLib::createNeumannBoundaryCondition(
config.config,
......@@ -133,13 +133,13 @@ BoundaryConditionBuilder::createNeumannBoundaryCondition(
std::unique_ptr<BoundaryCondition>
BoundaryConditionBuilder::createRobinBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher const& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
{
return ProcessLib::createRobinBoundaryCondition(
config.config,
......
......@@ -87,29 +87,27 @@ protected:
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>&
parameters,
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher,
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher);
virtual std::unique_ptr<BoundaryCondition> createNeumannBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table,
const MeshLib::Mesh& mesh, const int variable_id,
const unsigned integration_order,
const unsigned shapefunction_order,
const unsigned integration_order, const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>&
parameters,
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher,
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher);
virtual std::unique_ptr<BoundaryCondition> createRobinBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table,
const MeshLib::Mesh& mesh, const int variable_id,
const unsigned integration_order,
const unsigned shapefunction_order,
const unsigned integration_order, const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>&
parameters,
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher,
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher);
static std::vector<MeshLib::Element*> getClonedElements(
......
......@@ -17,16 +17,15 @@ namespace ProcessLib
{
namespace LIE
{
std::unique_ptr<BoundaryCondition>
BoundaryConditionBuilder::createNeumannBoundaryCondition(
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table, const MeshLib::Mesh& mesh,
const int variable_id, const unsigned integration_order,
const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters,
MeshGeoToolsLib::MeshNodeSearcher const& /*mesh_node_searcher*/,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
{
return ProcessLib::LIE::createNeumannBoundaryCondition(
config.config,
......
......@@ -43,12 +43,12 @@ private:
const BoundaryConditionConfig& config,
const NumLib::LocalToGlobalIndexMap& dof_table,
const MeshLib::Mesh& mesh, const int variable_id,
const unsigned integration_order,
const unsigned shapefunction_order,
const unsigned integration_order, const unsigned shapefunction_order,
const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>&
parameters,
MeshGeoToolsLib::MeshNodeSearcher& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher) override;
MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher,
MeshGeoToolsLib::BoundaryElementsSearcher& boundary_element_searcher)
override;
FractureProperty const& _fracture_prop;
};
......
......@@ -55,7 +55,10 @@ public:
geo_objs.addPolylineVec(std::move(plys), geometry_0, nullptr);
MGTL::MeshNodeSearcher& searcher_nodes = MGTL::MeshNodeSearcher::getMeshNodeSearcher(*mesh);
MGTL::SearchLength search_length;
MGTL::MeshNodeSearcher const& searcher_nodes =
MGTL::MeshNodeSearcher::getMeshNodeSearcher(
*mesh, std::move(search_length));
MGTL::BoundaryElementsSearcher searcher_elements(*mesh, searcher_nodes);
auto elems = searcher_elements.getBoundaryElements(*ply);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment