diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp index 63164b69c933769305bc673eb16d63ce18d3f1fd..d31d6c7353e9ab753b9c3a5d7a7283171d988ec8 100644 --- a/Applications/FileIO/GMSInterface.cpp +++ b/Applications/FileIO/GMSInterface.cpp @@ -140,10 +140,10 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio out << "name" << "\t" << std::fixed << "X" << "\t" << "Y" << "\t" << "Z" << "\t" << "soilID" << "\n"; - for (std::size_t j = 0; j < stations->size(); j++) + for (auto station_as_point : *stations) { GeoLib::StationBorehole* station = - static_cast<GeoLib::StationBorehole*>((*stations)[j]); + static_cast<GeoLib::StationBorehole*>(station_as_point); std::vector<GeoLib::Point*> profile = station->getProfile(); std::vector<std::string> soilNames = station->getSoilNames(); //std::size_t idx = 0; diff --git a/Applications/FileIO/PetrelInterface.cpp b/Applications/FileIO/PetrelInterface.cpp index 6bea9a22d79727ab13df58a62c2096d2444bd147..387b6cddcbae863bb80854c26fad533ee6f6461b 100644 --- a/Applications/FileIO/PetrelInterface.cpp +++ b/Applications/FileIO/PetrelInterface.cpp @@ -77,9 +77,6 @@ PetrelInterface::PetrelInterface(std::list<std::string> &sfc_fnames, _unique_name); } -PetrelInterface::~PetrelInterface() -{} - void PetrelInterface::readPetrelSurface(std::istream &in) { char buffer[MAX_COLS_PER_ROW]; diff --git a/Applications/FileIO/PetrelInterface.h b/Applications/FileIO/PetrelInterface.h index b7b357404f2e89d3a153a026d95a247a81378710..993a0a77c3c2a80a5bb3641e7391ef5638a6bb30 100644 --- a/Applications/FileIO/PetrelInterface.h +++ b/Applications/FileIO/PetrelInterface.h @@ -32,14 +32,13 @@ namespace GeoLib namespace FileIO { -class PetrelInterface +class PetrelInterface final { public: PetrelInterface(std::list<std::string> &sfc_fnames, std::list<std::string> &well_path_fnames, std::string &unique_model_name, GeoLib::GEOObjects* obj); - virtual ~PetrelInterface(); private: void readPetrelSurface (std::istream &in); diff --git a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp index 4c99a8fa8af07325f3ff1342bd893a8511ab5305..b845923089e16b6d621c7a693a9a70b4246c1ae9 100644 --- a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp +++ b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp @@ -127,7 +127,7 @@ int main (int argc, char* argv[]) ' ', "0.1"); TCLAP::ValueArg<bool> gml_arg("", "gml", - "if switched on write found nodes to file in gml format", false, 0, "bool"); + "if switched on write found nodes to file in gml format", false, false, "bool"); cmd.add(gml_arg); TCLAP::ValueArg<std::string> output_base_fname("o", "output-base-file-name", diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp index 72cb7ca9bcc55087a14fb84d04a22b3753f7dd4a..a801c0f3db2e47c109d14c72b4baf08bf037e7f9 100644 --- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp +++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp @@ -42,8 +42,8 @@ static std::vector<bool> markNodesOutSideOfPolygon( // *** rotate mesh nodes to xy-plane // 1 copy all mesh nodes to GeoLib::Points std::vector<GeoLib::Point*> rotated_nodes; - for (std::size_t j(0); j < nodes.size(); j++) - rotated_nodes.push_back(new GeoLib::Point(*nodes[j], nodes[j]->getID())); + for (auto node : nodes) + rotated_nodes.push_back(new GeoLib::Point(*node, node->getID())); // 2 rotate the Points MathLib::DenseMatrix<double> rot_mat(3,3); GeoLib::computeRotationMatrixToXY(normal, rot_mat); @@ -61,16 +61,16 @@ static std::vector<bool> markNodesOutSideOfPolygon( } } - for (std::size_t j(0); j < rotated_nodes.size(); j++) - delete rotated_nodes[j]; + for (auto & rotated_node : rotated_nodes) + delete rotated_node; std::vector<GeoLib::Point*> & rot_polygon_pnts( const_cast<std::vector<GeoLib::Point*> &>( rot_polygon.getPointsVec() ) ); - for (std::size_t k(0); k < rot_polygon_pnts.size(); k++) - delete rot_polygon_pnts[k]; + for (auto & rot_polygon_pnt : rot_polygon_pnts) + delete rot_polygon_pnt; return outside; } @@ -141,7 +141,7 @@ int main (int argc, char* argv[]) "new property value (data type int)", false, 0, "number"); cmd.add(int_property_arg); TCLAP::ValueArg<bool> bool_property_arg("b", "bool-property-value", - "new property value (data type bool)", false, 0, "boolean value"); + "new property value (data type bool)", false, false, "boolean value"); cmd.add(bool_property_arg); TCLAP::ValueArg<std::string> property_name_arg("n", "property-name", "name of property in the mesh", false, "MaterialIDs", "string"); @@ -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/checkMesh.cpp b/Applications/Utils/MeshEdit/checkMesh.cpp index 823bf5025d6dca160e274637eb3ae753b6809906..955e97aaaf0728ec829f5801f2e150429f098dab 100644 --- a/Applications/Utils/MeshEdit/checkMesh.cpp +++ b/Applications/Utils/MeshEdit/checkMesh.cpp @@ -83,18 +83,18 @@ int main(int argc, char *argv[]) std::vector<std::string> const& vec_names (mesh->getProperties().getPropertyVectorNames()); INFO("There are %d properties in the mesh:", vec_names.size()); - for (std::size_t i=0; i<vec_names.size(); ++i) + for (const auto & vec_name : vec_names) { - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_names[i])); + auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<int>::max()) - INFO("\t%s: [%d, %d]", vec_names[i].c_str(), vec_bounds.first, vec_bounds.second) + INFO("\t%s: [%d, %d]", vec_name.c_str(), vec_bounds.first, vec_bounds.second) else { - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(*mesh, vec_names[i])); + auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<double>::max()) - INFO("\t%s: [%g, %g]", vec_names[i].c_str(), vec_bounds.first, vec_bounds.second) + INFO("\t%s: [%g, %g]", vec_name.c_str(), vec_bounds.first, vec_bounds.second) else - INFO("\t%s: Unknown properties", vec_names[i].c_str()) + INFO("\t%s: Unknown properties", vec_name.c_str()) } } diff --git a/Applications/Utils/MeshEdit/moveMeshNodes.cpp b/Applications/Utils/MeshEdit/moveMeshNodes.cpp index 7e26e05f0c8d58da27a03b06b84b00c49c5fac4f..5eedb9ad389b8acbb261139191d35bc88c8f9920 100644 --- a/Applications/Utils/MeshEdit/moveMeshNodes.cpp +++ b/Applications/Utils/MeshEdit/moveMeshNodes.cpp @@ -98,8 +98,8 @@ int main (int argc, char* argv[]) } bool is_keyword(false); - for (std::size_t i=0; i<keywords.size(); i++) - if (current_key.compare(keywords[i])==0) + for (auto & keyword : keywords) + if (current_key.compare(keyword)==0) { is_keyword = true; break; @@ -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/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 6de1ddb7dd5144c42ce8e5a83fa9a029e606f876..a5e610d824ab1ce93ce6a4579d5bd2cc252b5058 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -92,9 +92,9 @@ int strDate2int(const std::string &s) std::string str(s); if (s.length() > 10) str = s.substr(0,10); - std::size_t sep ( str.find(".",0) ); + std::size_t sep ( str.find('.',0) ); int d ( atoi(str.substr(0, sep).c_str()) ); - std::size_t sep2 ( str.find(".", sep + 1) ); + std::size_t sep2 ( str.find('.', sep + 1) ); int m ( atoi(str.substr(sep + 1,sep2 - (sep + 1)).c_str()) ); int y ( atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str()) ); return date2int(y, m, d); diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index a21b7d8d457003499c8213a64729ed0bd2b61be4..6f60be1b85870b6057b9f3f98029a63958dafc87 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -76,7 +76,7 @@ std::string::size_type findLastPathSeparator(std::string const& path) static std::string::size_type findLastDot(std::string const& path) { - return path.find_last_of("."); + return path.find_last_of('.'); } } // end namespace @@ -141,7 +141,7 @@ std::string extractPath(std::string const& pathname) return ""; return pathname.substr(0, pos + 1); } -const char * pathSeparator = +static const char * pathSeparator = #ifdef _WIN32 "\\"; #else diff --git a/FileIO/TetGenInterface.cpp b/FileIO/TetGenInterface.cpp index f4f3e5ee829e8b12863ed76ae2e75a05aee9ed5b..df7e5fc6ab12554cb879c0934988f3d9b60328d7 100644 --- a/FileIO/TetGenInterface.cpp +++ b/FileIO/TetGenInterface.cpp @@ -38,10 +38,6 @@ TetGenInterface::TetGenInterface() : { } -TetGenInterface::~TetGenInterface() -{ -} - bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, GeoLib::GEOObjects &geo_objects) { @@ -63,8 +59,8 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, if (!readNodesFromStream (poly_stream, nodes)) { // remove nodes read until now - for (std::size_t k(0); k<nodes.size(); ++k) - delete nodes[k]; + for (auto & node : nodes) + delete node; return false; } const std::size_t nNodes (nodes.size()); @@ -184,8 +180,8 @@ bool TetGenInterface::parseSmeshFacets(std::ifstream &input, // here the poly-file potentially defines a number of region attributes, these are ignored for now std::size_t nTotalTriangles (0); - for (std::size_t i=0; i<surfaces.size(); ++i) - nTotalTriangles += surfaces[i]->getNumberOfTriangles(); + for (auto & surface : surfaces) + nTotalTriangles += surface->getNumberOfTriangles(); if (nTotalTriangles == nFacets) return true; @@ -211,8 +207,8 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname, std::vector<MeshLib::Node*> nodes; if (!readNodesFromStream (ins_nodes, nodes)) { // remove nodes read until now - for (std::size_t k(0); k<nodes.size(); k++) { - delete nodes[k]; + for (auto & node : nodes) { + delete node; } return nullptr; } @@ -221,12 +217,12 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname, std::vector<int> materials; if (!readElementsFromStream (ins_ele, elements, materials, nodes)) { // remove elements read until now - for (std::size_t k(0); k<elements.size(); k++) { - delete elements[k]; + for (auto & element : elements) { + delete element; } // remove nodes - for (std::size_t k(0); k<nodes.size(); k++) { - delete nodes[k]; + for (auto & node : nodes) { + delete node; } return nullptr; } @@ -326,7 +322,7 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, std::size_t id; std::size_t pos_end = 0; - std::size_t pos_beg = line.find_first_not_of(" ", pos_end); + std::size_t pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(" \n", pos_beg); if (line.empty() || pos_beg==pos_end || line.compare(pos_beg,1,"#") == 0) @@ -346,7 +342,7 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, // read coordinates const unsigned offset = (_zero_based_idx) ? 0 : 1; for (std::size_t i(0); i < dim; i++) { - pos_beg = line.find_first_not_of(" ", pos_end); + pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(" \n", pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); if (pos_beg != std::string::npos) @@ -406,8 +402,8 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, std::size_t pos_beg, pos_end; // number of tetrahedras - pos_beg = line.find_first_not_of (" "); - pos_end = line.find_first_of(" ", pos_beg); + pos_beg = line.find_first_not_of (' '); + pos_end = line.find_first_of(' ', pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) n_tets = BaseLib::str2number<std::size_t> (line.substr(pos_beg, pos_end - pos_beg)); else { @@ -455,7 +451,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, } std::size_t pos_end = 0; - std::size_t pos_beg = line.find_first_not_of(" ", pos_end); + std::size_t pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(" \n", pos_beg); if (line.empty() || pos_beg==pos_end || line.compare(pos_beg,1,"#") == 0) @@ -473,8 +469,8 @@ bool TetGenInterface::parseElements(std::ifstream& ins, // read node ids for (std::size_t i(0); i < n_nodes_per_tet; i++) { - pos_beg = line.find_first_not_of(" ", pos_end); - pos_end = line.find_first_of(" ", pos_beg); + pos_beg = line.find_first_not_of(' ', pos_end); + pos_end = line.find_first_of(' ', pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); if (pos_beg != std::string::npos && pos_end != std::string::npos) @@ -489,8 +485,8 @@ bool TetGenInterface::parseElements(std::ifstream& ins, // read region attribute - this is something like material group int region (0); if (region_attribute) { - pos_beg = line.find_first_not_of(" ", pos_end); - pos_end = line.find_first_of(" ", pos_beg); + pos_beg = line.find_first_not_of(' ', pos_end); + pos_end = line.find_first_of(' ', pos_beg); if (pos_end == std::string::npos) pos_end = line.size(); if (pos_beg != std::string::npos && pos_end != std::string::npos) region = BaseLib::str2number<int> (line.substr(pos_beg, pos_end - pos_beg)); diff --git a/FileIO/TetGenInterface.h b/FileIO/TetGenInterface.h index 7cb274f7f6dd0b4dedb0b2aa60d6a43cc78e46d0..d9ee8f6ae1db46bef85b5172de62c5f1dddf15cd 100644 --- a/FileIO/TetGenInterface.h +++ b/FileIO/TetGenInterface.h @@ -38,11 +38,10 @@ namespace FileIO * node - mesh node / geometric point definition * ele - mesh element definition */ -class TetGenInterface +class TetGenInterface final { public: TetGenInterface(); - virtual ~TetGenInterface(); /** * Method reads geometry from a TetGen poly or smesh file. diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 13c6e3fdf3570252395ddaf4fd10ca4d1ac13fa7..36dab8ea84cd88ac8f350f9a05f6b78a8ec5d94f 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -285,8 +285,8 @@ void rotatePointsToXZ(std::vector<GeoLib::Point*> &pnts) rotatePoints(rot_mat, pnts); } - for (std::size_t k(0); k<pnts.size(); k++) - (*(pnts[k]))[1] = 0.0; // should be -= d but there are numerical errors + for (auto & pnt : pnts) + (*pnt)[1] = 0.0; // should be -= d but there are numerical errors } std::unique_ptr<GeoLib::Point> triangleLineIntersection( diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 87ee8064478fe91105502ce66a926691ed4922d0..e64cc9698e853f648c96b8483b7ba56cbc907787 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -31,14 +31,14 @@ GEOObjects::GEOObjects() GEOObjects::~GEOObjects() { // delete surfaces - for (std::size_t k(0); k < _sfc_vecs.size(); k++) - delete _sfc_vecs[k]; + for (auto & _sfc_vec : _sfc_vecs) + delete _sfc_vec; // delete polylines - for (std::size_t k(0); k < _ply_vecs.size(); k++) - delete _ply_vecs[k]; + for (auto & _ply_vec : _ply_vecs) + delete _ply_vec; // delete points - for (std::size_t k(0); k < _pnt_vecs.size(); k++) - delete _pnt_vecs[k]; + for (auto & _pnt_vec : _pnt_vecs) + delete _pnt_vec; } void GEOObjects::addPointVec( @@ -239,8 +239,8 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, // ctor, which needs write access to the surface vector. auto sfc = std::unique_ptr<std::vector<GeoLib::Surface*>>{ new std::vector<GeoLib::Surface*>}; - for (std::size_t i = 0; i < surfaces.size(); i++) - sfc->push_back(surfaces[i]); + for (auto surface : surfaces) + sfc->push_back(surface); addSurfaceVec(std::move(sfc), name); return false; } @@ -299,8 +299,8 @@ bool GEOObjects::isUniquePointVecName(std::string &name) if (count > 1) cpName = cpName + "-" + std::to_string(count); - for (std::size_t i = 0; i < _pnt_vecs.size(); i++) - if ( cpName.compare(_pnt_vecs[i]->getName()) == 0 ) + for (auto & _pnt_vec : _pnt_vecs) + if ( cpName.compare(_pnt_vec->getName()) == 0 ) isUnique = false; } diff --git a/GeoLib/IO/AsciiRasterInterface.cpp b/GeoLib/IO/AsciiRasterInterface.cpp index 59f9e27eda3bf4dcd40e46a9689be07c799c51fd..d8eca1d222ad5d15e6f40171ff31e8e5f87798f0 100644 --- a/GeoLib/IO/AsciiRasterInterface.cpp +++ b/GeoLib/IO/AsciiRasterInterface.cpp @@ -181,7 +181,7 @@ bool AsciiRasterInterface::readSurferHeader( else { ERR("Error in readSurferHeader() - Anisotropic cellsize detected."); - return 0; + return false; } header.no_data = min-1; in >> min >> max; diff --git a/GeoLib/IO/Gmsh/GMSHLine.cpp b/GeoLib/IO/Gmsh/GMSHLine.cpp index d54864be2700802b863068e7c0d535c7d2f988bc..d3fda7cb580fc53fa71686d3ddd6c84fd5cfa7dd 100644 --- a/GeoLib/IO/Gmsh/GMSHLine.cpp +++ b/GeoLib/IO/Gmsh/GMSHLine.cpp @@ -22,9 +22,6 @@ GMSHLine::GMSHLine(std::size_t start_point_id, std::size_t end_point_id) : _start_pnt_id(start_point_id), _end_pnt_id(end_point_id) {} -GMSHLine::~GMSHLine() -{} - void GMSHLine::write(std::ostream &os, std::size_t id) const { os << "Line(" << id << ") = {" << _start_pnt_id << "," << _end_pnt_id << "};\n"; diff --git a/GeoLib/IO/Gmsh/GMSHLine.h b/GeoLib/IO/Gmsh/GMSHLine.h index f6ca31d91cce46f78d18927d96bd28631a6b1932..d67bfcbcb71c930d5abba386b7a554de33aa0f21 100644 --- a/GeoLib/IO/Gmsh/GMSHLine.h +++ b/GeoLib/IO/Gmsh/GMSHLine.h @@ -20,10 +20,9 @@ namespace IO namespace GMSH { -class GMSHLine { +class GMSHLine final { public: GMSHLine(std::size_t start_point_id, std::size_t end_point_id); - virtual ~GMSHLine(); void write(std::ostream &os, std::size_t id) const; void resetLineData(std::size_t start_point_id, std::size_t end_point_id); diff --git a/GeoLib/IO/Gmsh/GMSHPoint.cpp b/GeoLib/IO/Gmsh/GMSHPoint.cpp index ae9714f5f98618d5dd1ffe23384f945b03c463bc..3e5da53c8a25462087b496024372fb117fddf56f 100644 --- a/GeoLib/IO/Gmsh/GMSHPoint.cpp +++ b/GeoLib/IO/Gmsh/GMSHPoint.cpp @@ -34,9 +34,6 @@ void GMSHPoint::write(std::ostream &os) const } } -GMSHPoint::~GMSHPoint() -{} - std::ostream& operator<< (std::ostream &os, GMSHPoint const& p) { p.write (os); diff --git a/GeoLib/IO/Gmsh/GMSHPoint.h b/GeoLib/IO/Gmsh/GMSHPoint.h index 11b2885d1a9cda36c26d2c94246a2dbed8b857a9..41310a4ba912302d394d45909621353644a78c28 100644 --- a/GeoLib/IO/Gmsh/GMSHPoint.h +++ b/GeoLib/IO/Gmsh/GMSHPoint.h @@ -20,11 +20,10 @@ namespace IO { namespace GMSH { - -class GMSHPoint : public GeoLib::Point { +class GMSHPoint final : public GeoLib::Point +{ public: GMSHPoint(GeoLib::Point const& pnt, std::size_t id, double mesh_density); - virtual ~GMSHPoint(); void write(std::ostream &os) const; private: double _mesh_density; diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index 2d2d501c82f4765d76815dc36df151de5031cc15..068611d7be587c0020ffffb4e5527c0aeb61dc1d 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -59,7 +59,7 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, getline(in, line); // geometric key words start with the hash # // while not found a new key word do ... - while (line.find("#") == std::string::npos && !in.eof() && !in.fail()) + while (line.find('#') == std::string::npos && !in.eof() && !in.fail()) { // read id and point coordinates std::stringstream inss(line); @@ -81,7 +81,7 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, if (line.find("$MD") != std::string::npos) { double mesh_density; - std::size_t pos1(line.find_first_of("M")); + std::size_t pos1(line.find_first_of('M')); inss.str(line.substr(pos1 + 2, std::string::npos)); inss >> mesh_density; } @@ -90,7 +90,7 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, std::size_t pos (line.find("$NAME")); if (pos != std::string::npos) //OK { - std::size_t end_pos ((line.substr (pos + 6)).find(" ")); + std::size_t end_pos ((line.substr (pos + 6)).find(' ')); if (end_pos != std::string::npos) (*pnt_id_name_map)[line.substr (pos + 6, end_pos)] = id; else @@ -188,8 +188,8 @@ std::string readPolyline(std::istream &in, in >> line; if (type != 100) while (!in.eof() && !in.fail() && line.size() != 0 - && (line.find("#") == std::string::npos) - && (line.find("$") == std::string::npos)) + && (line.find('#') == std::string::npos) + && (line.find('$') == std::string::npos)) { std::size_t pnt_id(BaseLib::str2number<std::size_t> (line)); if (!zero_based_indexing) @@ -217,7 +217,7 @@ std::string readPolyline(std::istream &in, line = path + line; readPolylinePointVector(line, pnt_vec, ply, path, errors); } // subkeyword found - } while (line.find("#") == std::string::npos && line.size() != 0 && in); + } while (line.find('#') == std::string::npos && line.size() != 0 && in); if (type != 100) { @@ -321,8 +321,8 @@ std::string readSurface(std::istream &in, { // read the name of the polyline(s) in >> line; while (!in.eof() && !in.fail() && line.size() != 0 - && (line.find("#") == std::string::npos) - && (line.find("$") == std::string::npos)) + && (line.find('#') == std::string::npos) + && (line.find('$') == std::string::npos)) { // we did read the name of a polyline -> search the id for polyline std::map<std::string,std::size_t>::const_iterator it (ply_vec_names.find ( @@ -349,7 +349,7 @@ std::string readSurface(std::istream &in, } // empty line or a keyword is found } - } while (line.find("#") == std::string::npos && line.size() != 0 && in); + } while (line.find('#') == std::string::npos && line.size() != 0 && in); if (!name.empty()) sfc_names.insert(std::pair<std::string,std::size_t>(name,sfc_vec.size())); @@ -425,8 +425,8 @@ std::string readSurfaces(std::istream &in, sfc_vec.push_back(sfc); } } - for (std::size_t k(0); k < polygon_vec.size(); k++) - delete polygon_vec[k]; + for (auto & k : polygon_vec) + delete k; return tag; } @@ -526,7 +526,7 @@ bool readGLIFileV4(const std::string& fname, std::size_t writeTINSurfaces(std::ofstream &os, GeoLib::SurfaceVec const* sfcs_vec, std::size_t sfc_count, std::string const& path) { const std::vector<GeoLib::Surface*>* sfcs (sfcs_vec->getVector()); - for (std::size_t k(0); k < sfcs->size(); k++) + for (auto sfc : *sfcs) { os << "#SURFACE" << "\n"; std::string sfc_name; @@ -541,7 +541,7 @@ std::size_t writeTINSurfaces(std::ofstream &os, GeoLib::SurfaceVec const* sfcs_v os << "\t\t" << sfc_name << "\n"; // create tin file sfc_name = path + sfc_name; - GeoLib::IO::TINInterface::writeSurfaceAsTIN(*(*sfcs)[k], sfc_name.c_str()); + GeoLib::IO::TINInterface::writeSurfaceAsTIN(*sfc, sfc_name.c_str()); sfc_count++; } return sfc_count; @@ -575,15 +575,15 @@ void writeGLIFileV4 (const std::string& fname, const std::vector<GeoLib::Polyline*>* plys (plys_vec->getVector()); INFO("GeoLib::writeGLIFileV4(): %d polylines to file %s.", plys->size (), fname.c_str()); - for (std::size_t k(0); k < plys->size(); k++) + for (auto ply : *plys) { os << "#POLYLINE" << "\n"; std::string polyline_name; - plys_vec->getNameOfElement((*plys)[k], polyline_name); + plys_vec->getNameOfElement(ply, polyline_name); os << " $NAME " << "\n" << " " << polyline_name << "\n"; os << " $POINTS" << "\n"; - for (std::size_t j(0); j < (*plys)[k]->getNumberOfPoints(); j++) - os << " " << ((*plys)[k])->getPointID(j) << "\n"; + for (std::size_t j(0); j < ply->getNumberOfPoints(); j++) + os << " " << ply->getPointID(j) << "\n"; } } @@ -612,10 +612,10 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects // writing all points os << "#POINTS" << "\n"; - for (std::size_t j(0); j < geo_names.size(); j++) + for (auto & geo_name : geo_names) { os.precision(std::numeric_limits<double>::digits10); - GeoLib::PointVec const* const pnt_vec(geo.getPointVecObj(geo_names[j])); + GeoLib::PointVec const* const pnt_vec(geo.getPointVecObj(geo_name)); std::vector<GeoLib::Point*> const* const pnts (pnt_vec->getVector()); if (pnts) { std::string pnt_name; @@ -638,10 +638,10 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects // writing all stations std::vector<std::string> stn_names; geo.getStationVectorNames (stn_names); - for (std::size_t j(0); j < stn_names.size(); j++) + for (auto & stn_name : stn_names) { os.precision(std::numeric_limits<double>::digits10); - const std::vector<GeoLib::Point*>* pnts (geo.getStationVec(stn_names[j])); + const std::vector<GeoLib::Point*>* pnts (geo.getStationVec(stn_name)); if (pnts) { for (std::size_t k(0); k < pnts->size(); k++) @@ -660,7 +660,7 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects const GeoLib::PolylineVec* plys_vec (geo.getPolylineVecObj (geo_names[j])); if (plys_vec) { const std::vector<GeoLib::Polyline*>* plys (plys_vec->getVector()); - for (std::size_t k(0); k < plys->size(); k++) { + for (auto ply : *plys) { os << "#POLYLINE" << "\n"; std::string ply_name; os << " $NAME\n"; @@ -669,9 +669,9 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects else os << " " << geo_names[j] << "-" << plys_cnt << "\n"; os << " $POINTS" << "\n"; - for (std::size_t l(0); l < (*plys)[k]->getNumberOfPoints(); l++) + for (std::size_t l(0); l < ply->getNumberOfPoints(); l++) os << " " << pnts_id_offset[j] + - ((*plys)[k])->getPointID(l) << "\n"; + ply->getPointID(l) << "\n"; plys_cnt++; } } @@ -679,9 +679,9 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects // writing surfaces as TIN files std::size_t sfcs_cnt (0); - for (std::size_t j(0); j < geo_names.size(); j++) + for (auto & geo_name : geo_names) { - const GeoLib::SurfaceVec* sfcs_vec (geo.getSurfaceVecObj (geo_names[j])); + const GeoLib::SurfaceVec* sfcs_vec (geo.getSurfaceVecObj (geo_name)); if (sfcs_vec) sfcs_cnt += writeTINSurfaces(os, sfcs_vec, sfcs_cnt, path); } diff --git a/GeoLib/LineSegment.cpp b/GeoLib/LineSegment.cpp index e0d3adbd2d83a399859a1b776417d5b145b52675..4fced2ff6c4106847f204899d4849807c633efcb 100644 --- a/GeoLib/LineSegment.cpp +++ b/GeoLib/LineSegment.cpp @@ -26,8 +26,8 @@ LineSegment::LineSegment(LineSegment const& line_segment) {} LineSegment::LineSegment(LineSegment&& line_segment) - : _a(std::move(line_segment._a)), - _b(std::move(line_segment._b)), + : _a(line_segment._a), + _b(line_segment._b), _point_mem_management_by_line_segment( line_segment._point_mem_management_by_line_segment) { @@ -44,22 +44,14 @@ LineSegment::~LineSegment() } } -LineSegment& LineSegment::operator=(LineSegment const& other) -{ - _a = other._a; - _b = other._b; - _point_mem_management_by_line_segment = - other._point_mem_management_by_line_segment; - - return *this; -} +LineSegment& LineSegment::operator=(LineSegment const& other) = default; LineSegment& LineSegment::operator=(LineSegment&& line_segment) { - _a = std::move(line_segment._a); - _b = std::move(line_segment._b); + _a = line_segment._a; + _b = line_segment._b; _point_mem_management_by_line_segment = - std::move(line_segment._point_mem_management_by_line_segment); + line_segment._point_mem_management_by_line_segment; line_segment._a = nullptr; line_segment._b = nullptr; 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/PointVec.cpp b/GeoLib/PointVec.cpp index 22af4c9442a6e141f424e6054c56530dafadc49c..169a4eb713f8fe023c0b0d52d86dea46d078903c 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -121,10 +121,6 @@ PointVec::PointVec(const std::string& name, } } -PointVec::~PointVec() -{ -} - std::size_t PointVec::push_back(Point* pnt) { _pnt_id_map.push_back(uniqueInsert(pnt)); diff --git a/GeoLib/PointVec.h b/GeoLib/PointVec.h index 31dd0042104e51943b6c3d9405ca706b835c2575..fa359ebe3974e7263c61b90cb7f2e41c55fd4dbc 100644 --- a/GeoLib/PointVec.h +++ b/GeoLib/PointVec.h @@ -39,7 +39,7 @@ namespace GeoLib * a unique name from class GEOObject. For this reason PointVec should have * a name. * */ -class PointVec : public TemplateVec<Point> +class PointVec final : public TemplateVec<Point> { public: /// Signals if the vector contains object of type Point or Station @@ -73,9 +73,6 @@ public: std::map<std::string, std::size_t>* name_id_map = nullptr, PointType type = PointVec::PointType::POINT, double rel_eps = std::numeric_limits<double>::epsilon()); - /** Destructor deletes all Points of this PointVec. */ - virtual ~PointVec (); - /** * Method adds a Point to the (internal) standard vector and takes the ownership. * If the given point is already included in the vector, the point will be destroyed and diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 0dc41b4d7d931ef771b3e0a34c09e82b32182288..8bd0f84dd3f1df637538904d6e151f3a424e6278 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -125,9 +125,9 @@ std::vector<GeoLib::Point> Polygon::getAllIntersectionPoints( { std::vector<GeoLib::Point> intersections; GeoLib::Point s; - for (auto seg_it(begin()); seg_it != end(); ++seg_it) + for (auto&& seg_it : *this) { - if (GeoLib::lineSegmentIntersect(*seg_it, segment, s)) { + if (GeoLib::lineSegmentIntersect(seg_it, segment, s)) { intersections.push_back(s); } } @@ -308,8 +308,8 @@ void Polygon::ensureCWOrientation () // rotate copied points into x-y-plane GeoLib::rotatePointsToXY(tmp_polygon_pnts); - for (std::size_t k(0); k < tmp_polygon_pnts.size(); k++) - (*(tmp_polygon_pnts[k]))[2] = 0.0; // should be -= d but there are numerical errors + for (auto & tmp_polygon_pnt : tmp_polygon_pnts) + (*tmp_polygon_pnt)[2] = 0.0; // should be -= d but there are numerical errors // *** get the left most upper point std::size_t min_x_max_y_idx (0); // for orientation check @@ -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/GeoLib/Station.cpp b/GeoLib/Station.cpp index 47d8b84ded8a2384391c8519f848b7ef1f28205f..3f8097fea18624436ee53d340d77493625515c94 100644 --- a/GeoLib/Station.cpp +++ b/GeoLib/Station.cpp @@ -15,6 +15,7 @@ #include "Station.h" #include <cstdlib> +#include <utility> #include <logog/include/logog.hpp> @@ -22,12 +23,12 @@ namespace GeoLib { -Station::Station(double x, double y, double z, std::string name) : +Station::Station(double x, double y, double z, std::string const& name) : Point (x,y,z), _name(name), _type(Station::StationType::STATION), _station_value(0.0), _sensor_data(nullptr) {} -Station::Station(Point* coords, std::string name) : +Station::Station(Point* coords, std::string const& name) : Point (*coords), _name(name), _type(Station::StationType::STATION), _station_value(0.0), _sensor_data(nullptr) {} diff --git a/GeoLib/Station.h b/GeoLib/Station.h index 243c9ccea8d753fe51d16b2cdcd567da803aae2e..9305b5af59db255d47eeaaa1c904952e1a55e802 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -57,9 +57,9 @@ public: Station(double x = 0.0, double y = 0.0, double z = 0.0, - std::string name = ""); + std::string const& name = ""); - Station(Point* coords, std::string name = ""); + Station(Point* coords, std::string const& name = ""); /** * Constructor copies the source object diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index 2d448040d8db15bcea57d7a0e9f29158a954d3ac..8443f14a2a147ac7e706340321aeb654a9b05fc0 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -49,8 +49,8 @@ Surface::Surface(Surface const& src) Surface::~Surface() { - for (std::size_t k(0); k < _sfc_triangles.size(); k++) - delete _sfc_triangles[k]; + for (auto & _sfc_triangle : _sfc_triangles) + delete _sfc_triangle; } void Surface::addTriangle(std::size_t pnt_a, @@ -166,11 +166,11 @@ bool Surface::isPntInSfc(MathLib::Point3d const& pnt) const const Triangle* Surface::findTriangle(MathLib::Point3d const& pnt) const { - for (std::size_t k(0); k < _sfc_triangles.size(); k++) + for (auto _sfc_triangle : _sfc_triangles) { - if (_sfc_triangles[k]->containsPoint(pnt)) + if (_sfc_triangle->containsPoint(pnt)) { - return _sfc_triangles[k]; + return _sfc_triangle; } } return nullptr; diff --git a/MathLib/Integration/GaussLegendre.h b/MathLib/Integration/GaussLegendre.h index bfb9f85e9fdaeeca838a7134b4760e2c597cb7c7..4ca744e7a9bac06e0cdbc1e7ed585837a4c26264 100644 --- a/MathLib/Integration/GaussLegendre.h +++ b/MathLib/Integration/GaussLegendre.h @@ -29,7 +29,27 @@ struct GaussLegendre { static const double W[Order]; }; -} // namespace MathLib +#ifndef _MSC_VER // The following explicit instantatiation declaration does not + // compile on that particular compiler. +template <> +double const GaussLegendre<1>::X[1]; +template <> +double const GaussLegendre<1>::W[1]; +template <> +double const GaussLegendre<2>::X[2]; +template <> +double const GaussLegendre<2>::W[2]; +template <> +double const GaussLegendre<3>::X[3]; +template <> +double const GaussLegendre<3>::W[3]; +template <> +double const GaussLegendre<4>::X[4]; +template <> +double const GaussLegendre<4>::W[4]; +#endif + +} // namespace MathLib #endif // GAUSSLEGENDRE_H_ diff --git a/MathLib/Integration/GaussLegendrePyramid.h b/MathLib/Integration/GaussLegendrePyramid.h index c2dff83e270669e2a0a665bb2db299b3446adb3e..d79eb5ee07cbe06c4e40686e0a2da20986cf2f92 100644 --- a/MathLib/Integration/GaussLegendrePyramid.h +++ b/MathLib/Integration/GaussLegendrePyramid.h @@ -42,6 +42,14 @@ struct GaussLegendrePyramid<3> { static const double W[NPoints]; }; +#ifndef _MSC_VER // The following explicit instantatiation declaration does not + // compile on that particular compiler but is necessary. +template <> +const std::array<std::array<double, 3>, GaussLegendrePyramid<1>::NPoints> + GaussLegendrePyramid<1>::X; +template <> +double const GaussLegendrePyramid<1>::W[1]; +#endif } #endif //GAUSSLEGENDREPYRAMID_H_ diff --git a/MathLib/Integration/GaussLegendreTet.h b/MathLib/Integration/GaussLegendreTet.h index 57bbc315076f628fe3d3890f1ed4195febedd622..5781785fabc105508c765e06629c2af19ce0fba5 100644 --- a/MathLib/Integration/GaussLegendreTet.h +++ b/MathLib/Integration/GaussLegendreTet.h @@ -42,6 +42,14 @@ struct GaussLegendreTet<3> { static const double W[NPoints]; }; +#ifndef _MSC_VER // The following explicit instantatiation declaration does not + // compile on that particular compiler but is necessary. +template <> +const std::array<std::array<double, 3>, GaussLegendreTet<1>::NPoints> + GaussLegendreTet<1>::X; +template <> +double const GaussLegendreTet<1>::W[1]; +#endif } #endif //GAUSSLEGENDRETET_H_ diff --git a/MathLib/Integration/GaussLegendreTri.h b/MathLib/Integration/GaussLegendreTri.h index 2c7a0d178047f801e4f465386fdc5ea4f72f150a..f47de74bc0afda5690e734d9cfa92d1e0ee28309 100644 --- a/MathLib/Integration/GaussLegendreTri.h +++ b/MathLib/Integration/GaussLegendreTri.h @@ -47,6 +47,14 @@ struct GaussLegendreTri<3> { static const double W[NPoints]; }; +#ifndef _MSC_VER // The following explicit instantatiation declaration does not + // compile on that particular compiler but is necessary. +template <> +const std::array<std::array<double, 2>, GaussLegendreTri<1>::NPoints> + GaussLegendreTri<1>::X; +template <> +double const GaussLegendreTri<1>::W[1]; +#endif } #endif //GAUSSLEGENDRETRI_H_ 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/MathLib/LinAlg/Eigen/EigenOption.cpp b/MathLib/LinAlg/Eigen/EigenOption.cpp index 5e615e785166a979f959156f55dd69aad4c5d8cd..36bc4a671ff8fbfbba51a5a3f0d6088f21c2b3cf 100644 --- a/MathLib/LinAlg/Eigen/EigenOption.cpp +++ b/MathLib/LinAlg/Eigen/EigenOption.cpp @@ -23,7 +23,7 @@ EigenOption::EigenOption() EigenOption::SolverType EigenOption::getSolverType(const std::string &solver_name) { #define RETURN_SOLVER_ENUM_IF_SAME_STRING(str, TypeName) \ - if (#TypeName==str) return SolverType::TypeName; + if (#TypeName==(str)) return SolverType::TypeName; RETURN_SOLVER_ENUM_IF_SAME_STRING(solver_name, CG); RETURN_SOLVER_ENUM_IF_SAME_STRING(solver_name, BiCGSTAB); @@ -36,7 +36,7 @@ EigenOption::SolverType EigenOption::getSolverType(const std::string &solver_nam EigenOption::PreconType EigenOption::getPreconType(const std::string &precon_name) { #define RETURN_PRECOM_ENUM_IF_SAME_STRING(str, TypeName) \ - if (#TypeName==str) return PreconType::TypeName; + if (#TypeName==(str)) return PreconType::TypeName; RETURN_PRECOM_ENUM_IF_SAME_STRING(precon_name, NONE); RETURN_PRECOM_ENUM_IF_SAME_STRING(precon_name, DIAGONAL); 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/IO/VtkIO/VtuInterface.cpp b/MeshLib/IO/VtkIO/VtuInterface.cpp index f9ce4a60c6e19fa8fb2d1553b9eecd5471f13d26..776e94d6e8fbbf0553c344a0a2d21c67612178bb 100644 --- a/MeshLib/IO/VtkIO/VtuInterface.cpp +++ b/MeshLib/IO/VtkIO/VtuInterface.cpp @@ -49,9 +49,6 @@ VtuInterface::VtuInterface(const MeshLib::Mesh* mesh, int dataMode, bool compres WARN("Ascii data cannot be compressed, ignoring compression flag.") } -VtuInterface::~VtuInterface() -{} - MeshLib::Mesh* VtuInterface::readVTUFile(std::string const &file_name) { if (!BaseLib::IsFileExisting(file_name)) { diff --git a/MeshLib/IO/VtkIO/VtuInterface.h b/MeshLib/IO/VtkIO/VtuInterface.h index 8b28b7458325ed196bb9b516a3ce1cc17fb4b116..06d881ed2d37eb67d0643f8d52ee45d569fbac65 100644 --- a/MeshLib/IO/VtkIO/VtuInterface.h +++ b/MeshLib/IO/VtkIO/VtuInterface.h @@ -29,12 +29,11 @@ namespace IO * This class is currently not inherited from Writer because VTK will implement * writing to a string from 6.2 onwards. */ -class VtuInterface +class VtuInterface final { public: /// Provide the mesh to write and set if compression should be used. VtuInterface(const MeshLib::Mesh* mesh, int dataMode = vtkXMLWriter::Binary, bool compressed = false); - ~VtuInterface(); /// Read an unstructured grid from a VTU file /// \return The converted mesh or a nullptr if reading failed 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..38e387749eaccb9ea49b228d0cc704d6e958f58a 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -56,8 +56,8 @@ 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()); - return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh("FlippedElementMesh", new_nodes, new_elems, new_props)); + return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh( + "FlippedElementMesh", new_nodes, new_elems, mesh.getProperties())); } } // end namespace MeshLib diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp index 7d63b2700fdbda8cc6a67602a197004ebbb56935..d97f09abc47ea695322ba40588b3e560932fe0e6 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp @@ -33,9 +33,6 @@ Mesh2MeshPropertyInterpolation::Mesh2MeshPropertyInterpolation(Mesh const*const _src_mesh(src_mesh), _src_properties(src_properties) {} -Mesh2MeshPropertyInterpolation::~Mesh2MeshPropertyInterpolation() -{} - bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh *dest_mesh, std::vector<double>& dest_properties) const { if (_src_mesh->getDimension() != dest_mesh->getDimension()) { @@ -98,8 +95,7 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes std::size_t cnt(0); dest_properties[k] = 0.0; - for (std::size_t i(0); i<nodes.size(); ++i) { - std::vector<MeshLib::Node*> const* i_th_vec(nodes[i]); + for (auto i_th_vec : nodes) { const std::size_t n_nodes_in_vec(i_th_vec->size()); for (std::size_t j(0); j<n_nodes_in_vec; j++) { MeshLib::Node const*const j_th_node((*i_th_vec)[j]); @@ -132,8 +128,7 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes std::ofstream out_src(source_fname.c_str()); out_src << "#POINTS" << "\n"; std::size_t nodes_cnt(0); - for (std::size_t i(0); i<nodes.size(); ++i) { - std::vector<MeshLib::Node*> const* i_th_vec(nodes[i]); + for (auto i_th_vec : nodes) { const std::size_t n_nodes_in_vec(i_th_vec->size()); for (std::size_t j(0); j<n_nodes_in_vec; j++) { MeshLib::Node const*const j_th_node((*i_th_vec)[j]); diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h index cdaf987fc82454ed70bdaec0194d1a3025c2eb87..3d4a55257785d3f7fa85f5235535b9191d5e5773 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h @@ -24,7 +24,8 @@ class Mesh; * (destination) mesh deploying weighted interpolation. The two * meshes must have the same dimension. */ -class Mesh2MeshPropertyInterpolation { +class Mesh2MeshPropertyInterpolation final +{ public: /** * Constructor taking the source or input mesh and properties. @@ -37,7 +38,6 @@ public: * indices the vector of properties must have \f$\ge n\f$ entries. */ Mesh2MeshPropertyInterpolation(Mesh const*const source_mesh, std::vector<double> const*const source_properties); - virtual ~Mesh2MeshPropertyInterpolation(); /** * Calculates entries for the property vector and sets appropriate indices in the diff --git a/MeshLib/MeshEnums.cpp b/MeshLib/MeshEnums.cpp index 1321b09f1c16caf4cfab29e19c9fc67ebcfafd29..0f9a87bd18024fb12792660e8a542a8f2a4a6b48 100644 --- a/MeshLib/MeshEnums.cpp +++ b/MeshLib/MeshEnums.cpp @@ -104,7 +104,7 @@ std::vector<std::string> getMeshElemTypeStringsShort() const std::string CellType2String(const CellType t) { #define RETURN_CELL_TYPE_STR(t, type)\ - if (t == CellType::type)\ + if ((t) == CellType::type)\ return #type; RETURN_CELL_TYPE_STR(t, POINT1); diff --git a/MeshLib/MeshGenerators/MeshGenerator.cpp b/MeshLib/MeshGenerators/MeshGenerator.cpp index c9661b3e1ade09aae952e61e13cb1ea355bb350a..388775d83ef3faf79faf7e622e27bdcaf357ce25 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.cpp +++ b/MeshLib/MeshGenerators/MeshGenerator.cpp @@ -36,9 +36,9 @@ std::vector<MeshLib::Node*> MeshGenerator::generateRegularNodes( for (std::size_t j = 0; j < vec_xyz_coords[1]->size(); j++) { const double y ((*vec_xyz_coords[1])[j]+origin[1]); - for (std::size_t k = 0; k < vec_xyz_coords[0]->size(); k++) + for (double const x : *vec_xyz_coords[0]) { - nodes.push_back (new Node((*vec_xyz_coords[0])[k]+origin[0], y, z)); + nodes.push_back (new Node(x+origin[0], y, z)); } } } @@ -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/MeshLib/MeshQuality/AngleSkewMetric.cpp b/MeshLib/MeshQuality/AngleSkewMetric.cpp index 6e2c26dcc9fc5c36b505212e4e51adff59106ce4..81919894f210dfed964c8ebf380120761b727dd6 100644 --- a/MeshLib/MeshQuality/AngleSkewMetric.cpp +++ b/MeshLib/MeshQuality/AngleSkewMetric.cpp @@ -29,9 +29,6 @@ AngleSkewMetric::AngleSkewMetric(Mesh const& mesh) : ElementQualityMetric(mesh) {} -AngleSkewMetric::~AngleSkewMetric() -{} - void AngleSkewMetric::calculateQuality () { const std::vector<MeshLib::Element*>& elements(_mesh.getElements()); diff --git a/MeshLib/MeshQuality/AngleSkewMetric.h b/MeshLib/MeshQuality/AngleSkewMetric.h index c31938eecf80ef1fe0c1e807bbd5e7b1ebd6bed6..3b330df5c8a5eae37d95965b0bf8a9140826d3ec 100644 --- a/MeshLib/MeshQuality/AngleSkewMetric.h +++ b/MeshLib/MeshQuality/AngleSkewMetric.h @@ -23,13 +23,12 @@ namespace MeshLib /** * Calculates the quality of mesh elements based on the EquiAngleSkew measure */ -class AngleSkewMetric : public ElementQualityMetric +class AngleSkewMetric final : public ElementQualityMetric { public: AngleSkewMetric(Mesh const& mesh); - virtual ~AngleSkewMetric(); - virtual void calculateQuality (); + void calculateQuality(); private: double checkTriangle(Element const& elem) const; diff --git a/MeshLib/MeshQuality/MeshValidation.cpp b/MeshLib/MeshQuality/MeshValidation.cpp index 9dc94d61c30c4d176e9ab5db24dbd1d48e848ec8..a329f7ff10594b781b46e0097c7e041d1eabee63 100644 --- a/MeshLib/MeshQuality/MeshValidation.cpp +++ b/MeshLib/MeshQuality/MeshValidation.cpp @@ -43,8 +43,8 @@ MeshValidation::MeshValidation(MeshLib::Mesh &mesh) const std::vector<ElementErrorCode> codes (this->testElementGeometry(mesh)); std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output_str (this->ElementErrorCodeOutput(codes)); - for (std::size_t i = 0; i < output_str.size(); ++i) - INFO (output_str[i].c_str()); + for (auto & i : output_str) + INFO (i.c_str()); } std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib::Mesh &mesh, double min_volume) diff --git a/MeshLib/Node.cpp b/MeshLib/Node.cpp index d28d8a7bbeea53b26726d0569a2e94e27d64044a..c75ae987e282f260798a5f8b9c0acf2640e0e0f3 100644 --- a/MeshLib/Node.cpp +++ b/MeshLib/Node.cpp @@ -38,10 +38,6 @@ Node::Node(const Node &node) { } -Node::~Node() -{ -} - void Node::updateCoordinates(double x, double y, double z) { _x[0] = x; diff --git a/MeshLib/Node.h b/MeshLib/Node.h index 44d3820a2060d80914f5a0df183711cd2eef3ea5..ee7f8db349702cd25ef3cd95934d4bcbb0651da3 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -29,7 +29,7 @@ class Element; /** * A mesh node with coordinates in 3D space. */ -class Node : public MathLib::Point3dWithID +class Node final : public MathLib::Point3dWithID { /* friend classes: */ friend class Mesh; @@ -61,9 +61,6 @@ public: /// Get number of elements the node is part of. std::size_t getNumberOfElements() const { return _elements.size(); } - /// Destructor - virtual ~Node(); - /// Shift the node according to the displacement vector v. Node operator-(MathLib::Vector3 const& v) const { @@ -73,7 +70,7 @@ public: protected: /// Update coordinates of a node. /// This method automatically also updates the areas/volumes of all connected elements. - virtual void updateCoordinates(double x, double y, double z); + void updateCoordinates(double x, double y, double z); /** * Add an element the node is part of. diff --git a/MeshLib/Properties-impl.h b/MeshLib/Properties-impl.h index c760d39e78299a5c2e7203b7f569e0a0af1cd19f..c7ec37d1dc4dfa9a2f21c441af878cbd3277a19e 100644 --- a/MeshLib/Properties-impl.h +++ b/MeshLib/Properties-impl.h @@ -57,7 +57,7 @@ Properties::createNewPropertyVector(std::string const& name, return boost::optional<PropertyVector<T> &>(); } - // check entries of item2group_mapping of consistence + // check entries of item2group_mapping for consistence for (std::size_t k(0); k<item2group_mapping.size(); k++) { std::size_t const group_id (item2group_mapping[k]); if (group_id >= n_prop_groups) { diff --git a/MeshLib/Vtk/VtkMappedMeshSource.cpp b/MeshLib/Vtk/VtkMappedMeshSource.cpp index 6a3e1ec88bc64714d4154b62a3d55dc6c8dda900..a0d2c7ad743dadac10f31be4d96fc36e4a76a646 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.cpp +++ b/MeshLib/Vtk/VtkMappedMeshSource.cpp @@ -39,11 +39,6 @@ VtkMappedMeshSource::VtkMappedMeshSource() this->SetNumberOfInputPorts(0); } -VtkMappedMeshSource::~VtkMappedMeshSource() -{ - -} - int VtkMappedMeshSource::ProcessRequest( vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) diff --git a/MeshLib/Vtk/VtkMappedMeshSource.h b/MeshLib/Vtk/VtkMappedMeshSource.h index 4460d1bc58cb84719a804bf45fa0ad2b8893a435..a60306cd5e5c278b0808d0d1a9f6003ca01c8954 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.h +++ b/MeshLib/Vtk/VtkMappedMeshSource.h @@ -52,12 +52,12 @@ namespace MeshLib { /// Adapter which maps a MeshLib::Mesh to a vtkUnstructuredGridAlgorithm. /// Allows for zero-copy access of the mesh from the visualization side. -class VtkMappedMeshSource : public vtkUnstructuredGridAlgorithm +class VtkMappedMeshSource final : public vtkUnstructuredGridAlgorithm { public: static VtkMappedMeshSource *New(); vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm) - virtual void PrintSelf(std::ostream &os, vtkIndent indent); + void PrintSelf(std::ostream &os, vtkIndent indent); /// Sets the mesh. Calling is mandatory void SetMesh(const MeshLib::Mesh* mesh) { this->_mesh = mesh; this->Modified(); } @@ -67,7 +67,6 @@ public: protected: VtkMappedMeshSource(); - ~VtkMappedMeshSource(); int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector); diff --git a/NumLib/DOF/GlobalMatrixProviders.cpp b/NumLib/DOF/GlobalMatrixProviders.cpp index 4d42f1b5d5d69cea607e1461e2a5b7f95301ec79..fc4872257f6ab8a7407f9b2aedd3eb3370ab8c61 100644 --- a/NumLib/DOF/GlobalMatrixProviders.cpp +++ b/NumLib/DOF/GlobalMatrixProviders.cpp @@ -23,10 +23,10 @@ \ namespace MathLib { \ template<> \ - VectorProvider<VEC>& GlobalVectorProvider<VEC>::provider = *VARNAME; \ + VectorProvider<VEC>& GlobalVectorProvider<VEC>::provider = *(VARNAME); \ \ template<> \ - MatrixProvider<MAT>& GlobalMatrixProvider<MAT>::provider = *VARNAME; \ + MatrixProvider<MAT>& GlobalMatrixProvider<MAT>::provider = *(VARNAME); \ } 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/BaseLib/TestQuicksort.cpp b/Tests/BaseLib/TestQuicksort.cpp index 5afa8255b26ca50e8f71c1a7439eb0308dbece4d..bdf2057852d2b0b7ed30cb0ccd2fec10a9eaad66 100644 --- a/Tests/BaseLib/TestQuicksort.cpp +++ b/Tests/BaseLib/TestQuicksort.cpp @@ -127,8 +127,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsWithPointer) std::iota(perm.begin(), perm.end(), 0); std::vector<int*> p_xs; - for (std::size_t i=0; i<xs.size(); ++i) - p_xs.push_back(&xs[i]); + for (int & x : xs) + p_xs.push_back(&x); BaseLib::quicksort(p_xs, 0, p_xs.size(), perm); @@ -199,8 +199,8 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverseWithPointer) std::iota(perm.begin(), perm.end(), 0); std::vector<int*> p_xs; - for (std::size_t i=0; i<xs.size(); ++i) - p_xs.push_back(&xs[i]); + for (int & x : xs) + p_xs.push_back(&x); BaseLib::quicksort(p_xs, 0, p_xs.size(), perm); diff --git a/Tests/FileIO/TestCsvReader.cpp b/Tests/FileIO/TestCsvReader.cpp index f70fbe960715784eb0aa71ba43915f185cca735b..be85b8c58f64f0c0ee9fde04d7e8ad826533b6dc 100644 --- a/Tests/FileIO/TestCsvReader.cpp +++ b/Tests/FileIO/TestCsvReader.cpp @@ -114,8 +114,8 @@ TEST_F(CsvInterfaceTest, Points2D) _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y"); ASSERT_EQ(0, _result); ASSERT_EQ(10, points.size()); - for (std::size_t i=0; i<points.size(); ++i) - ASSERT_NEAR(0, (*points[i])[2], std::numeric_limits<double>::epsilon()); + for (auto & point : points) + ASSERT_NEAR(0, (*point)[2], std::numeric_limits<double>::epsilon()); for (auto p : points) delete p; } 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/TestPolygon.cpp b/Tests/GeoLib/TestPolygon.cpp index ce250a8135ce8cdcebb24e1803ac9519150f40f4..51281c82ba68b2cd40fd6502779a0af34ea79c36 100644 --- a/Tests/GeoLib/TestPolygon.cpp +++ b/Tests/GeoLib/TestPolygon.cpp @@ -67,8 +67,8 @@ public: ~PolygonTest() { delete _polygon; - for (std::size_t k(0); k<_pnts.size(); k++) - delete _pnts[k]; + for (auto & _pnt : _pnts) + delete _pnt; } protected: @@ -78,8 +78,8 @@ protected: TEST_F(PolygonTest, isPntInPolygonCheckCorners) { - for (std::size_t k(0); k<_pnts.size(); k++) - EXPECT_TRUE(_polygon->isPntInPolygon(*_pnts[k])); + for (auto & _pnt : _pnts) + EXPECT_TRUE(_polygon->isPntInPolygon(*_pnt)); } TEST_F(PolygonTest, isPntInPolygonCheckPointsRestOnPolygonEdges) @@ -146,10 +146,9 @@ TEST_F(PolygonTest, containsSegment) } // test all segments of polygon - for (auto segment_it(_polygon->begin()); segment_it != _polygon->end(); - ++segment_it) + for (auto && segment_it : *_polygon) { - EXPECT_TRUE(_polygon->containsSegment(*segment_it)); + EXPECT_TRUE(_polygon->containsSegment(segment_it)); } { // 70 @@ -191,8 +190,8 @@ TEST_F(PolygonTest, isPolylineInPolygon) outer_ply.addPoint(0); outer_ply.addPoint(1); ASSERT_FALSE(_polygon->isPolylineInPolygon(outer_ply)); - for (std::size_t k(0); k<pnts.size(); k++) - delete pnts[k]; + for (auto & pnt : pnts) + delete pnt; pnts.clear(); pnts.push_back(new GeoLib::Point(-1.0,2.0,0.0)); // 3 @@ -201,8 +200,8 @@ TEST_F(PolygonTest, isPolylineInPolygon) inner_ply.addPoint(0); inner_ply.addPoint(1); ASSERT_TRUE(_polygon->isPolylineInPolygon(inner_ply)); - for (std::size_t k(0); k<pnts.size(); k++) - delete pnts[k]; + for (auto & pnt : pnts) + delete pnt; } TEST_F(PolygonTest, CopyConstructor) diff --git a/Tests/GeoLib/TestPolyline.cpp b/Tests/GeoLib/TestPolyline.cpp index 6265c9a17f91581587df1b5cda75ba740235eee5..9768c93cfe29fc2ca3bea4c2622446ef33624a53 100644 --- a/Tests/GeoLib/TestPolyline.cpp +++ b/Tests/GeoLib/TestPolyline.cpp @@ -109,6 +109,6 @@ TEST(GeoLib, PolylineTest) } ASSERT_EQ(ply.getNumberOfSegments(), segment_cnt); - for (std::size_t k(0); k < ply_pnts.size(); ++k) - delete ply_pnts[k]; + for (auto & ply_pnt : ply_pnts) + delete ply_pnt; } diff --git a/Tests/GeoLib/TestSimplePolygonTree.cpp b/Tests/GeoLib/TestSimplePolygonTree.cpp index 73e2ac157a6f18bae2a8fc005d9467350d27d6be..06470a991f10042d67c2574b1639fcadbaef0b14 100644 --- a/Tests/GeoLib/TestSimplePolygonTree.cpp +++ b/Tests/GeoLib/TestSimplePolygonTree.cpp @@ -92,8 +92,8 @@ public: delete _p1; delete _p2; delete _p3; - for (std::size_t k(0); k<_pnts.size(); k++) - delete _pnts[k]; + for (auto & _pnt : _pnts) + delete _pnt; } protected: 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/TestNonlinearNewton.cpp b/Tests/MathLib/TestNonlinearNewton.cpp index fe853d08f05d0e9ec03bf53f982593febfe093c8..4a58dc722bcd7da18877b11bc5a571feea54ded5 100644 --- a/Tests/MathLib/TestNonlinearNewton.cpp +++ b/Tests/MathLib/TestNonlinearNewton.cpp @@ -29,7 +29,7 @@ template<class F_JACOBIAN> class ScalarDx { public: - ScalarDx(F_JACOBIAN &f_J) : _f_Jacobian(f_J) {} + explicit ScalarDx(F_JACOBIAN &f_J) : _f_Jacobian(f_J) {} // dx = - r/J void operator()(const double &x, const double &r, double &dx) { diff --git a/Tests/MathLib/TestNonlinearPicard.cpp b/Tests/MathLib/TestNonlinearPicard.cpp index 34f3a9b188f7b58f5a40f25fd917812c5d04a05d..dcfde74741a90a3e83cab411c30ce09b9fabbe61 100644 --- a/Tests/MathLib/TestNonlinearPicard.cpp +++ b/Tests/MathLib/TestNonlinearPicard.cpp @@ -51,7 +51,7 @@ public: class Example2 { public: - Example2(std::size_t n) : A(n, n), b(n) {} + explicit Example2(std::size_t n) : A(n, n), b(n) {} void operator()(VectorType &x, VectorType &x_new) { 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/TestAddLayerToMesh.cpp b/Tests/MeshLib/TestAddLayerToMesh.cpp index 47749ec987deaf43d676c874a369f25cd36daa74..f31624f6e579c235738a58eb21090a3e07ffd356 100644 --- a/Tests/MeshLib/TestAddLayerToMesh.cpp +++ b/Tests/MeshLib/TestAddLayerToMesh.cpp @@ -31,9 +31,9 @@ namespace AddLayerValidation ElementErrorFlag const flags[nErrorFlags] = {ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder}; std::vector<ElementErrorCode> const codes (MeshLib::MeshValidation::testElementGeometry(mesh)); - for (std::size_t i=0; i<codes.size(); ++i) + for (auto code : codes) for (std::size_t j=0; j<nErrorFlags-reduce_tests; ++j) - ASSERT_FALSE(codes[i][flags[j]]); + ASSERT_FALSE(code[flags[j]]); } void testZCoords2D(MeshLib::Mesh const& input, MeshLib::Mesh const& output, double height) diff --git a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp index aec1558bbd48a5cbba2d4cc516a9e6964c30be51..bc028b1a5a845954ecd2acf42a9f703419d85f52 100644 --- a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp +++ b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp @@ -142,10 +142,10 @@ void debugOutput(MeshLib::Element *ele, MeshLib::ElementCoordinatesMappingLocal // check if using the rotation matrix results in the original coordinates #define CHECK_COORDS(ele, mapping)\ - for (unsigned ii=0; ii<ele->getNumberOfNodes(); ii++) {\ - MathLib::Point3d global(matR*mapping.getMappedCoordinates(ii));\ + for (unsigned ii=0; ii<(ele)->getNumberOfNodes(); ii++) {\ + MathLib::Point3d global(matR*(mapping).getMappedCoordinates(ii));\ const double eps(std::numeric_limits<double>::epsilon());\ - ASSERT_ARRAY_NEAR(&(*ele->getNode(ii))[0], global.getCoords(), 3u, eps);\ + ASSERT_ARRAY_NEAR(&(*(ele)->getNode(ii))[0], global.getCoords(), 3u, eps);\ } } //namespace 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/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index 19137e73b21aa06b7b87fb58f6d64f62392158c1..ff55ff1078c2e55b8e87666bb875f3394ffb5208 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -26,7 +26,7 @@ public: using LinearSolver = MathLib::LinearSolver<Matrix, Vector>; using NLSolver = NumLib::NonlinearSolver<Matrix, Vector, NLTag>; - TestOutput(const char* name) + explicit TestOutput(const char* name) : _file_name_part(name) {} 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());