diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp index 536db8ada0fab5e75fe47a6d722f5ced712148fa..a801c0f3db2e47c109d14c72b4baf08bf037e7f9 100644 --- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp +++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp @@ -197,7 +197,7 @@ int main (int argc, char* argv[]) std::vector<std::string> property_names( mesh->getProperties().getPropertyVectorNames()); INFO("Mesh contains %d property vectors:", property_names.size()); - for (auto name : property_names) { + for (const auto& name : property_names) { INFO("- %s", name.c_str()); } std::string const& property_name(property_name_arg.getValue()); diff --git a/Applications/Utils/MeshEdit/moveMeshNodes.cpp b/Applications/Utils/MeshEdit/moveMeshNodes.cpp index f2795dc720d67145b328ad6e506dc96f3fbaa241..5eedb9ad389b8acbb261139191d35bc88c8f9920 100644 --- a/Applications/Utils/MeshEdit/moveMeshNodes.cpp +++ b/Applications/Utils/MeshEdit/moveMeshNodes.cpp @@ -155,7 +155,7 @@ int main (int argc, char* argv[]) //double max_dist (25.0); // squared maximum distance at which reference points are used double offset (0.0); // additional offset for elevation (should be 0) MeshLib::Mesh* ground_truth (MeshLib::IO::readMeshFromFile(value)); - const std::vector<MeshLib::Node*> ground_truth_nodes (ground_truth->getNodes()); + const std::vector<MeshLib::Node*>& ground_truth_nodes (ground_truth->getNodes()); GeoLib::AABB bounding_box(ground_truth_nodes.begin(), ground_truth_nodes.end()); MathLib::Point3d const& min(bounding_box.getMinPoint()); MathLib::Point3d const& max(bounding_box.getMaxPoint()); diff --git a/Applications/Utils/MeshEdit/removeMeshElements.cpp b/Applications/Utils/MeshEdit/removeMeshElements.cpp index d83277e46e66a43605740fb2997ee7d8088a9045..60e427f975b31694671155250591d7662e5f967c 100644 --- a/Applications/Utils/MeshEdit/removeMeshElements.cpp +++ b/Applications/Utils/MeshEdit/removeMeshElements.cpp @@ -109,7 +109,7 @@ int main (int argc, char* argv[]) } if (eleTypeArg.isSet()) { const std::vector<std::string> eleTypeNames = eleTypeArg.getValue(); - for (auto typeName : eleTypeNames) { + for (const auto& typeName : eleTypeNames) { const MeshLib::MeshElemType type = MeshLib::String2MeshElemType(typeName); if (type == MeshLib::MeshElemType::INVALID) continue; const std::size_t n_removed_elements = searcher.searchByElementType(type); diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index 2482792c8ad045d90d367b3623f1913e58b64818..e670e21c784326364fc211891a9843a41aae1acd 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -128,7 +128,7 @@ MinimalBoundingSphere::MinimalBoundingSphere( std::vector<MathLib::Point3d*> const& points) : _radius(-1), _center(0,0,0) { - std::vector<MathLib::Point3d*> sphere_points(points); + const std::vector<MathLib::Point3d*>& sphere_points(points); MinimalBoundingSphere const bounding_sphere = recurseCalculation(sphere_points, 0, sphere_points.size(), 0); _center = bounding_sphere.getCenter(); _radius = bounding_sphere.getRadius(); diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 53abbc860d8118c4aa8d66a1daa8bbf22393377c..8bd0f84dd3f1df637538904d6e151f3a424e6278 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -359,10 +359,10 @@ void Polygon::ensureCWOrientation () #if __GNUC__ <= 4 && (__GNUC_MINOR__ < 9) void Polygon::splitPolygonAtIntersection( - std::list<Polygon*>::iterator polygon_it) + const std::list<Polygon*>::iterator& polygon_it) #else void Polygon::splitPolygonAtIntersection( - std::list<Polygon*>::const_iterator polygon_it) + const std::list<Polygon*>::const_iterator& polygon_it) #endif { GeoLib::Polyline::SegmentIterator seg_it0((*polygon_it)->begin()); @@ -409,7 +409,7 @@ void Polygon::splitPolygonAtIntersection( splitPolygonAtIntersection(polygon1_it); } -void Polygon::splitPolygonAtPoint (std::list<GeoLib::Polygon*>::iterator polygon_it) +void Polygon::splitPolygonAtPoint (const std::list<GeoLib::Polygon*>::iterator& polygon_it) { std::size_t n((*polygon_it)->getNumberOfPoints() - 1), idx0(0), idx1(0); std::vector<std::size_t> id_vec(n); diff --git a/GeoLib/Polygon.h b/GeoLib/Polygon.h index 8ffdb024128c2159add526a35ad9421deaa85bef..3f3f49ba3336be9bab09a8acd3e5b44c19b51cf0 100644 --- a/GeoLib/Polygon.h +++ b/GeoLib/Polygon.h @@ -134,12 +134,13 @@ private: void ensureCWOrientation (); #if __GNUC__ <= 4 && (__GNUC_MINOR__ < 9) - void splitPolygonAtIntersection(std::list<Polygon*>::iterator polygon_it); + void splitPolygonAtIntersection( + const std::list<Polygon*>::iterator& polygon_it); #else void splitPolygonAtIntersection( - std::list<Polygon*>::const_iterator polygon_it); + const std::list<Polygon*>::const_iterator& polygon_it); #endif - void splitPolygonAtPoint (std::list<Polygon*>::iterator polygon_it); + void splitPolygonAtPoint (const std::list<Polygon*>::iterator& polygon_it); std::list<Polygon*> _simple_polygon_list; AABB _aabb; }; diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp index 05e5206689db873319f2c76aced9d39325fe69b6..3d05dfbdbb1eeed15657e26939d31d1c0b9b89cd 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp @@ -105,7 +105,7 @@ private: } // details EigenLinearSolver::EigenLinearSolver( - const std::string /*solver_name*/, + const std::string& /*solver_name*/, const BaseLib::ConfigTree* const option) { using Matrix = EigenMatrix::RawMatrixType; diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.h b/MathLib/LinAlg/Eigen/EigenLinearSolver.h index 011a8d7a854aba99377e183271680da383380234..affab4c694d44adcb21c4b9f12ec6cf785dac128 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.h +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.h @@ -36,7 +36,7 @@ public: * this argument, default settings follow those of * LisOption struct. */ - EigenLinearSolver(const std::string solver_name, + EigenLinearSolver(const std::string& solver_name, BaseLib::ConfigTree const*const option); ~EigenLinearSolver(); diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index e02d68ff08edc29877483f6ee85f12d437c085f0..7d20f1e0dfa609c1fb84052f1f9c69f3a503bf9c 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -313,7 +313,7 @@ void GeoMapper::advancedMapOnMesh( const GeoLib::Point* geo_point (ply->getPoint(node_index_in_ply)); // check if line segments connected to closest geo point intersect connected elements of current node - const std::vector<MeshLib::Element*> elements (node->getElements()); + const std::vector<MeshLib::Element*>& elements (node->getElements()); const std::size_t nElems = elements.size(); for (std::size_t e=0; e<nElems; ++e) { diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index 0fc3476513caf54b69f6a19fd0cd68e0cdd39e55..f1308e6e3a20a1cddf8db6bb6895a2c353e38126 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -59,12 +59,12 @@ Mesh::Mesh(const Mesh &mesh) _n_base_nodes(mesh.getNumberOfBaseNodes()), _properties(mesh._properties) { - const std::vector<Node*> nodes (mesh.getNodes()); + const std::vector<Node*>& nodes (mesh.getNodes()); const std::size_t nNodes (nodes.size()); for (unsigned i=0; i<nNodes; ++i) _nodes[i] = new Node(*nodes[i]); - const std::vector<Element*> elements (mesh.getElements()); + const std::vector<Element*>& elements (mesh.getElements()); const std::size_t nElements (elements.size()); for (unsigned i=0; i<nElements; ++i) { diff --git a/MeshLib/MeshEditing/FlipElements.cpp b/MeshLib/MeshEditing/FlipElements.cpp index 0d3cc50ef1f6f19a1dd383b5c9a8ec11310e9247..828e5183849888b2538581bbddc8dec58545dc00 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -56,7 +56,7 @@ std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh) for (std::size_t i=0; i<n_elems; ++i) new_elems.push_back(createFlippedElement(*elems[i], new_nodes).release()); - MeshLib::Properties new_props (mesh.getProperties()); + const MeshLib::Properties& new_props (mesh.getProperties()); return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh("FlippedElementMesh", new_nodes, new_elems, new_props)); } diff --git a/MeshLib/MeshGenerators/MeshGenerator.cpp b/MeshLib/MeshGenerators/MeshGenerator.cpp index 4843e1f6bf587f69360eb5cab4b5544d0cc8817c..388775d83ef3faf79faf7e622e27bdcaf357ce25 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.cpp +++ b/MeshLib/MeshGenerators/MeshGenerator.cpp @@ -464,7 +464,7 @@ MeshLib::Mesh* MeshGenerator::createSurfaceMesh(std::string const& mesh_name, MathLib::Point3d const& ll, MathLib::Point3d const& ur, std::array<std::size_t, 2> const& n_steps, - std::function<double(double,double)> f) + const std::function<double(double,double)>& f) { std::array<double, 2> step_size{{ (ur[0]-ll[0])/(n_steps[0]-1), (ur[1]-ll[1])/(n_steps[1]-1)}}; diff --git a/MeshLib/MeshGenerators/MeshGenerator.h b/MeshLib/MeshGenerators/MeshGenerator.h index ef14651aee35059f818518110d4caac7d529583b..a08a747e427a0f47f0ff8c5dac728ede5fc00ba8 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.h +++ b/MeshLib/MeshGenerators/MeshGenerator.h @@ -429,7 +429,7 @@ MeshLib::Mesh* createSurfaceMesh(std::string const& mesh_name, MathLib::Point3d const& ll, MathLib::Point3d const& ur, std::array<std::size_t, 2> const& n_steps, - std::function<double(double,double)> f); + const std::function<double(double,double)>& f); } //MeshGenerator } //MeshLib diff --git a/ProcessLib/Output.cpp b/ProcessLib/Output.cpp index 65d1a30a2c81f1e81223233f2d97af48f439c995..0870c68eb56436784a02ac6216f672eeff61c068 100644 --- a/ProcessLib/Output.cpp +++ b/ProcessLib/Output.cpp @@ -81,7 +81,7 @@ newInstance(const BaseLib::ConfigTree &config, std::string const& output_directo } void Output:: -initialize(Output::ProcessIter first, Output::ProcessIter last) +initialize(Output::ProcessIter first, const Output::ProcessIter& last) { for (unsigned pcs_idx = 0; first != last; ++first, ++pcs_idx) { diff --git a/ProcessLib/Output.h b/ProcessLib/Output.h index cda6c91c133a3027565ebabf9c36da9ea7692093..711c8f0c4a242b9505815bdb28cf87c84cb08bfb 100644 --- a/ProcessLib/Output.h +++ b/ProcessLib/Output.h @@ -33,7 +33,7 @@ public: ::const_iterator; //! Opens a PVD file for each process. - void initialize(ProcessIter first, ProcessIter last); + void initialize(ProcessIter first, const ProcessIter& last); //! Writes output for the given \c process if it should be written in the //! given \c timestep. diff --git a/Tests/GeoLib/TestOctTree.cpp b/Tests/GeoLib/TestOctTree.cpp index b6608d3df597698a132759f573ce3f26e52c6d39..e65d998688d33c22ce3c8644b70a589524509745 100644 --- a/Tests/GeoLib/TestOctTree.cpp +++ b/Tests/GeoLib/TestOctTree.cpp @@ -258,8 +258,8 @@ TEST_F(GeoLibOctTree, TestWithAlternatingPoints3d) ps_ptr.push_back(new GeoLib::Point(5*small_displacement,1,0,6)); GeoLib::AABB const aabb(ps_ptr.cbegin(), ps_ptr.cend()); - MathLib::Point3d min(aabb.getMinPoint()); - MathLib::Point3d max(aabb.getMaxPoint()); + const MathLib::Point3d& min(aabb.getMinPoint()); + const MathLib::Point3d& max(aabb.getMaxPoint()); std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 8>> oct_tree( GeoLib::OctTree<GeoLib::Point, 8>::createOctTree(min, max, eps)); @@ -309,8 +309,8 @@ TEST_F(GeoLibOctTree, TestSmallDistanceDifferentLeaves) // create OctTree GeoLib::AABB const aabb(ps_ptr.cbegin(), ps_ptr.cend()); - MathLib::Point3d min(aabb.getMinPoint()); - MathLib::Point3d max(aabb.getMaxPoint()); + const MathLib::Point3d& min(aabb.getMinPoint()); + const MathLib::Point3d& max(aabb.getMaxPoint()); std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 2>> oct_tree( GeoLib::OctTree<GeoLib::Point, 2>::createOctTree(min, max, eps)); diff --git a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp index 81f32b6afc8aef94e3b782663efe762152f4acc2..37b548923edace6241b9641dd942713fc267212f 100644 --- a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp +++ b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp @@ -80,7 +80,7 @@ TEST(GeoLib, SurfaceIsPointInSurface) surface_functions.push_back(constant); surface_functions.push_back(coscos); - for (auto f : surface_functions) { + for (const auto& f : surface_functions) { std::random_device rd; std::string name("Surface"); diff --git a/Tests/MathLib/TestPoint3d.cpp b/Tests/MathLib/TestPoint3d.cpp index 6706c65a2fa5878230edc8dee28e1b7bf106aaaa..b2428ae4c1ac8b4d830ca6d8f8b878212655ef41 100644 --- a/Tests/MathLib/TestPoint3d.cpp +++ b/Tests/MathLib/TestPoint3d.cpp @@ -37,7 +37,7 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessEqSamePoint) // A point is always less or equal to itself and its copy. auto samePointLessEqualCompare = [](MathLib::Point3d const& p) { - auto q = p; + const auto& q = p; return lessEq(p, p) && lessEq(p, q) && lessEq(q, p); }; @@ -104,7 +104,7 @@ TEST_F(MathLibPoint3d, ComparisonOperatorEqualSamePoint) // A point is always equal to itself and its copy. auto samePointEqualCompare = [](MathLib::Point3d const& p) { - auto q = p; + const auto& q = p; return (p == p) && (p == q) && (q == p); }; @@ -170,7 +170,7 @@ TEST_F(MathLibPoint3d, ComparisonOperatorLessSamePoint) // A point is never less than itself or its copy. auto samePointLessCompare = [](MathLib::Point3d const& p) { - auto q = p; + const auto& q = p; return !(p < p) && !(p < q) && !(q < p); }; diff --git a/Tests/MathLib/TestPoint3dWithID.cpp b/Tests/MathLib/TestPoint3dWithID.cpp index 6f1533d6c09917421d67f58eca3b3f7411e7e5d4..b9af8f0a813f384c3e2ff1f1b557070695c4a710 100644 --- a/Tests/MathLib/TestPoint3dWithID.cpp +++ b/Tests/MathLib/TestPoint3dWithID.cpp @@ -20,7 +20,7 @@ using namespace MathLib; TEST(MathLib, Point3dWithID) { Point3dWithID p0(0,0,0,1); - Point3dWithID p1(p0); // copy constructor + const Point3dWithID& p1(p0); // copy constructor Point3dWithID p2(p0, 2); // constructor for resetting the id EXPECT_EQ(p0.getID(), p1.getID()); diff --git a/Tests/MeshLib/TestUniqueMeshId.cpp b/Tests/MeshLib/TestUniqueMeshId.cpp index 96fd77bde6be073f24e3d1b63e772dce89255450..73666e37bd4aeee6cef85227f27e8420f41473e8 100644 --- a/Tests/MeshLib/TestUniqueMeshId.cpp +++ b/Tests/MeshLib/TestUniqueMeshId.cpp @@ -36,7 +36,7 @@ TEST(MeshLib, UniqueMeshId) ASSERT_EQ(counter_value + std::size_t(3), m3.getID()); // Copy mesh keeps also increments the counter. - Mesh m4(m0); + Mesh m4 = m0; ASSERT_EQ(counter_value + std::size_t(4), m4.getID()); } diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 09a4b10946b4a4a289d81818ff8ecf70e789dfe4..aa4fdc15b21e7bc6aab829e85ccacc0a488dfa49 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -103,7 +103,7 @@ public: template <AL::ComponentOrder order> void test(const unsigned num_components, const unsigned selected_component, - std::function<std::size_t(std::size_t, std::size_t)> const + std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index); std::unique_ptr<const MeshLib::Mesh> mesh; @@ -146,7 +146,7 @@ template <AL::ComponentOrder ComponentOrder> void NumLibLocalToGlobalIndexMapMultiDOFTest::test( const unsigned num_components, const unsigned selected_component, - std::function<std::size_t(std::size_t, std::size_t)> const + std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index) { initComponents(num_components, selected_component, ComponentOrder); diff --git a/Tests/NumLib/TestTimeStep.cpp b/Tests/NumLib/TestTimeStep.cpp index 447e3db4d2a387396bda97bfec03e12658887230..acb6d179af5dc3cbac7b95a1a958cbbfa0c53c7a 100644 --- a/Tests/NumLib/TestTimeStep.cpp +++ b/Tests/NumLib/TestTimeStep.cpp @@ -29,13 +29,13 @@ TEST(NumLib, TimeStep) ASSERT_EQ(1u, t2.steps()); // copy - NumLib::TimeStep t3(t2); + const NumLib::TimeStep& t3(t2); ASSERT_EQ(1., t3.current()); ASSERT_EQ(0., t3.previous()); ASSERT_EQ(1., t3.dt()); ASSERT_EQ(1u, t3.steps()); - NumLib::TimeStep t4 = t2; + const NumLib::TimeStep& t4 = t2; ASSERT_EQ(1., t4.current()); ASSERT_EQ(0., t4.previous()); ASSERT_EQ(1., t4.dt());