diff --git a/.clang-tidy b/.clang-tidy index f56e5b4e940d0fa01699b748bbe5a1b055a02f9c..09c0280dfcf1bfce609919b44ce13a3f92420c76 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,bugprone-*,misc-string-compare,modernize-*,performance-faster-string-find,-modernize-use-auto,-modernize-loop-convert,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-using,-modernize-avoid-bind,-modernize-return-braced-init-list,-modernize-use-transparent-functors,-modernize-redundant-void-arg' +Checks: '-*,bugprone-*,misc-string-compare,modernize-*,performance-faster-string-find,performance-unnecessary-copy-initialization,-modernize-use-auto,-modernize-loop-convert,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-using,-modernize-avoid-bind,-modernize-return-braced-init-list,-modernize-use-transparent-functors,-modernize-redundant-void-arg' WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/apps/benchmarks/PeriodicGranularGas/PeriodicGranularGas.cpp b/apps/benchmarks/PeriodicGranularGas/PeriodicGranularGas.cpp index db8edbea79740be6c6a033ffd74d880778f815ad..1866ca5c59984bbf053fa65cf729059733ec402d 100644 --- a/apps/benchmarks/PeriodicGranularGas/PeriodicGranularGas.cpp +++ b/apps/benchmarks/PeriodicGranularGas/PeriodicGranularGas.cpp @@ -182,7 +182,7 @@ int main( int argc, char ** argv ) MaterialID material = createMaterial( "granular", real_t( 1.0 ), 0, static_cof, dynamic_cof, real_t( 0.5 ), 1, 1, 0, 0 ); auto simulationDomain = forest->getDomain(); - auto generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); + const auto& generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); const real_t spacing(1.0); const real_t radius(0.5); diff --git a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp index 6dfb5a2a8020117e40edd7e984147776d58732ec..09d3a5a518162af644f25206f5fa814705bafa13 100644 --- a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp +++ b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp @@ -1125,12 +1125,12 @@ void VorticityRefinement< VectorField_T, Filter_T, Pseudo2D >::operator()( std:: if( filter_(x,y,z) && filter_(x+one,y,z) && filter_(x-one,y,z) && filter_(x,y+one,z) && filter_(x,y-one,z) && ( Pseudo2D || (filter_(x,y,z+one) && filter_(x,y,z-one)) ) ) { - const Vector3< real_t > xa = u->get(x+one,y,z); - const Vector3< real_t > xb = u->get(x-one,y,z); - const Vector3< real_t > ya = u->get(x,y+one,z); - const Vector3< real_t > yb = u->get(x,y-one,z); - const Vector3< real_t > za = Pseudo2D ? Vector3< real_t >(0) : u->get(x,y,z+one); - const Vector3< real_t > zb = Pseudo2D ? Vector3< real_t >(0) : u->get(x,y,z-one); + const Vector3< real_t >& xa = u->get(x+one,y,z); + const Vector3< real_t >& xb = u->get(x-one,y,z); + const Vector3< real_t >& ya = u->get(x,y+one,z); + const Vector3< real_t >& yb = u->get(x,y-one,z); + const Vector3< real_t > za = Pseudo2D ? Vector3< real_t >(0) : u->get(x,y,z+one); + const Vector3< real_t > zb = Pseudo2D ? Vector3< real_t >(0) : u->get(x,y,z-one); // ATTENTION: dx/y/z is assumed to be equal to '1'! const real_t duzdy = half * ( ya[2] - yb[2] ); diff --git a/apps/tutorials/pe/01_ConfinedGas.cpp b/apps/tutorials/pe/01_ConfinedGas.cpp index ad29563e67beff23a7b46d116aaec650a7a9e8f9..e674e83a6b1f0d70dc5e9f5f2f19b612b4591721 100644 --- a/apps/tutorials/pe/01_ConfinedGas.cpp +++ b/apps/tutorials/pe/01_ConfinedGas.cpp @@ -101,7 +101,7 @@ int main( int argc, char ** argv ) //! [Material] auto simulationDomain = forest->getDomain(); - auto generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); + const auto& generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); //! [Planes] createPlane(*globalBodyStorage, 0, Vec3(1,0,0), simulationDomain.minCorner(), material ); createPlane(*globalBodyStorage, 0, Vec3(-1,0,0), simulationDomain.maxCorner(), material ); diff --git a/apps/tutorials/pe/02_ConfinedGasExtended.cpp b/apps/tutorials/pe/02_ConfinedGasExtended.cpp index 014bda1a8714523c5a5c03d74aa3acd59470e7b5..7e0e027a779f32f052d47407155f82d12a9ada16 100644 --- a/apps/tutorials/pe/02_ConfinedGasExtended.cpp +++ b/apps/tutorials/pe/02_ConfinedGasExtended.cpp @@ -199,7 +199,7 @@ int main( int argc, char ** argv ) MaterialID material = createMaterial( "granular", real_t( 1.0 ), 0, static_cof, dynamic_cof, real_t( 0.5 ), 1, 1, 0, 0 ); auto simulationDomain = forest->getDomain(); - auto generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); + const auto& generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); createPlane(*globalBodyStorage, 0, Vec3(1,0,0), simulationDomain.minCorner(), material ); createPlane(*globalBodyStorage, 0, Vec3(-1,0,0), simulationDomain.maxCorner(), material ); createPlane(*globalBodyStorage, 0, Vec3(0,1,0), simulationDomain.minCorner(), material ); diff --git a/src/blockforest/loadbalancing/DynamicParMetis.cpp b/src/blockforest/loadbalancing/DynamicParMetis.cpp index 369339eee4c0fc726e8da72a6e0335157ae76fc8..59d43a364ef725d985c97c96ea021a69a4124280 100644 --- a/src/blockforest/loadbalancing/DynamicParMetis.cpp +++ b/src/blockforest/loadbalancing/DynamicParMetis.cpp @@ -70,7 +70,7 @@ std::map< blockforest::BlockID, uint_t > getBlockIdToSequenceMapping( const Phan mapping.insert( std::make_pair( it->first->getId(), sequenceId++ ) ); WALBERLA_ASSERT_EQUAL( sequenceId, blockSequenceRange.second ); - const std::vector<uint_t> neighborProcesses = phantomForest.getNeighboringProcesses(); + const std::vector<uint_t>& neighborProcesses = phantomForest.getNeighboringProcesses(); mpi::BufferSystem bs( comm ); diff --git a/src/pe/collision/EPA.cpp b/src/pe/collision/EPA.cpp index e8a2000482e1d73b92445bd01bfec613ed956c45..b2738d903fd6ca00d33047fbb9603c065fbadec5 100644 --- a/src/pe/collision/EPA.cpp +++ b/src/pe/collision/EPA.cpp @@ -715,7 +715,7 @@ inline bool EPA::originInTetrahedron( const Vec3& p0, const Vec3& p1, const Vec3 inline bool EPA::originInTetrahedronVolumeMethod( const Vec3& A, const Vec3& B, const Vec3& C, const Vec3& D ) { - Vec3 aoT = A; + const Vec3& aoT = A; if((aoT * (B % C)) <= real_t(0.0)) { //if volume of ABC and Origin <0.0 than the origin is on the wrong side of ABC //http://mathworld.wolfram.com/Tetrahedron.html volume formula diff --git a/src/pe/collision/GJK.cpp b/src/pe/collision/GJK.cpp index b681b780507d51e1b72bd684f6805b07f122bd62..e25c62b5e5114fbde39d5e8ee127b12af18f21da 100644 --- a/src/pe/collision/GJK.cpp +++ b/src/pe/collision/GJK.cpp @@ -341,7 +341,7 @@ inline real_t GJK::calcDistance( Vec3& normal, Vec3& contactPoint ) //Vec3 ac= C - A; //Vec3 bc= C - B; Vec3& n = d_; //we already know the normal - Vec3 nT = n; + const Vec3& nT = n; real_t vc = nT * (A % B); real_t va = nT * (B % C); @@ -395,7 +395,7 @@ bool GJK::simplex2(Vec3& d) const Vec3& A = simplex_[1]; //The Point last added to the simplex const Vec3& B = simplex_[0]; //The Point that was already in the simplex const Vec3 AO = -A; //The vector A->O with 0 the origin - const Vec3 AOt = AO; //The transposed vector A->O with O the origin + const Vec3& AOt = AO; //The transposed vector A->O with O the origin const Vec3 AB = B-A; //The vector A->B if( sameDirection(AOt, AB) ) { @@ -437,7 +437,7 @@ bool GJK::simplex3(Vec3& d) //ABC is a conterclockwise triangle const Vec3 AO = -A; //The vector A->O with 0 the origin - const Vec3 AOt = AO; //The transposed vector A->O with O the origin + const Vec3& AOt = AO; //The transposed vector A->O with O the origin const Vec3 AB = B-A; //The vector A->B const Vec3 AC = C-A; //The vector A->C const Vec3 ABC = AB%AC; //The the normal pointing towards the viewer if he sees a CCW triangle ABC @@ -566,7 +566,7 @@ bool GJK::simplex4(Vec3& d) //BCD is a clockwise triangle wenn seen from A const Vec3 AO = -A; //The vector A->O with 0 the origin - const Vec3 AOt = AO; //The transposed vector A->O with O the origin + const Vec3& AOt = AO; //The transposed vector A->O with O the origin const Vec3 AB = B-A; //The vector A->B const Vec3 AC = C-A; //The vector A->C const Vec3 AD = D-A; //The vector A-D diff --git a/src/pe_coupling/geometry/PeIntersectionRatio.cpp b/src/pe_coupling/geometry/PeIntersectionRatio.cpp index bd5518724940238b95c0971395e0e81c61d94e71..8d9fde471086ae01aed4fd554f44d1feca496031 100644 --- a/src/pe_coupling/geometry/PeIntersectionRatio.cpp +++ b/src/pe_coupling/geometry/PeIntersectionRatio.cpp @@ -35,7 +35,7 @@ real_t intersectionRatioSpherePe( const pe::Sphere & sphere, WALBERLA_ASSERT( walberla::geometry::contains( sphere, fluidPoint + direction ), "fluidPoint + direction: " << fluidPoint + direction ); // get the physical sphere center - Vector3< real_t > sphereCenter( sphere.getPosition() ); + const Vector3< real_t >& sphereCenter( sphere.getPosition() ); real_t dirLength = direction.length(); Vector3< real_t > l = sphereCenter - fluidPoint; @@ -62,8 +62,8 @@ real_t intersectionRatioPlanePe( const pe::Plane & plane, WALBERLA_ASSERT( walberla::geometry::contains<pe::RigidBody>( plane, fluidPoint + direction ), "fluidPoint + direction: " << fluidPoint + direction ); - Vector3<real_t> planeCenter( plane.getPosition() ); - Vector3<real_t> planeNormal( plane.getNormal() ); + const Vector3<real_t>& planeCenter( plane.getPosition() ); + const Vector3<real_t>& planeNormal( plane.getNormal() ); real_t denom = planeNormal * direction; diff --git a/tests/core/math/GenericAABBTest.cpp b/tests/core/math/GenericAABBTest.cpp index e27731aaeabeb336af33e0a45e493941f990d921..e78e6890dc94aea520e0aeaa9722ad43ec750a89 100644 --- a/tests/core/math/GenericAABBTest.cpp +++ b/tests/core/math/GenericAABBTest.cpp @@ -364,7 +364,7 @@ void testConstructors( const T x0, const T y0, const T z0, const T x1, const T y { GenericAABB< T > toBeCopied( x0, y0, z0, x1, y1, z1 ); - GenericAABB< T > refAABB( toBeCopied ); + const GenericAABB< T > refAABB( toBeCopied ); WALBERLA_CHECK_IDENTICAL( refAABB.minCorner()[0], std::min( x0, x1 ) ); WALBERLA_CHECK_IDENTICAL( refAABB.minCorner()[1], std::min( y0, y1 ) ); WALBERLA_CHECK_IDENTICAL( refAABB.minCorner()[2], std::min( z0, z1 ) ); @@ -645,7 +645,10 @@ int main(int argc, char**argv) GenericAABB< double > doubleAABB( 1.0, 1.0, 1.0, 2.0, 2.0 ,2.0 ); GenericAABB< double > copiedAABB0( floatAABB ); - GenericAABB< double > copiedAABB1( doubleAABB ); + const GenericAABB< double > copiedAABB1( doubleAABB ); + + WALBERLA_UNUSED(copiedAABB0); + WALBERLA_UNUSED(copiedAABB1); randomTest<float>(); randomTest<double>(); diff --git a/tests/field/FieldTiming.cpp b/tests/field/FieldTiming.cpp index 4eea53a3362c15761edbac70315910488280c820..283f0dc5fbf623ec1dd315ea3088f1e73cfcb4cb 100644 --- a/tests/field/FieldTiming.cpp +++ b/tests/field/FieldTiming.cpp @@ -111,7 +111,7 @@ double sumIteratorCachedEnd(const DoubleField & field) //WALBERLA_CHECK_EQUAL(field.layout() == fzyx ); double sum = 0; - const DoubleField::const_iterator myEnd = field.end(); + const DoubleField::const_iterator& myEnd = field.end(); for(DoubleField::const_iterator i = field.begin(); i != myEnd; ++i) sum += *i; @@ -173,7 +173,7 @@ double xyzfTest ( const DoubleField & field ) { double sum = 0; double sum2 = 0; - const DoubleField::const_iterator myEnd = field.end(); + const DoubleField::const_iterator& myEnd = field.end(); for(DoubleField::const_iterator i = field.begin(); i != myEnd; ++i) { sum += *i; diff --git a/tests/mesh/PeVTKMeshWriterTest.cpp b/tests/mesh/PeVTKMeshWriterTest.cpp index 0c56132e3e2a3adeeb400ad44f1f878676c922a8..147b3d456a143cbbd0ae85e6c48cf391549d14c6 100644 --- a/tests/mesh/PeVTKMeshWriterTest.cpp +++ b/tests/mesh/PeVTKMeshWriterTest.cpp @@ -166,7 +166,7 @@ int main( int argc, char ** argv ) MaterialID material = createMaterial( "granular", real_t( 1.0 ), 0, static_cof, dynamic_cof, real_t( 0.5 ), 1, 1, 0, 0 ); auto simulationDomain = forest->getDomain(); - auto generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); + const auto& generationDomain = simulationDomain; // simulationDomain.getExtended(-real_c(0.5) * spacing); createPlane(*globalBodyStorage, 0, Vec3(1,0,0), simulationDomain.minCorner(), material ); createPlane(*globalBodyStorage, 0, Vec3(-1,0,0), simulationDomain.maxCorner(), material ); createPlane(*globalBodyStorage, 0, Vec3(0,1,0), simulationDomain.minCorner(), material ); diff --git a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp index 3104a3c881cace72fe9694b92b9ab25b8078228b..4357e587d0def215b22725ae4c4c44d8e4dc9d9d 100644 --- a/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SettlingSphereMEMDynamicRefinement.cpp @@ -175,7 +175,7 @@ private: // add bodies of all neighboring blocks for(uint_t i = 0; i < block->getNeighborhoodSize(); ++i) { - BlockID neighborBlockID = block->getNeighborId(i); + const BlockID& neighborBlockID = block->getNeighborId(i); const auto infoItNeighbor = infoCollection_->find(neighborBlockID); numBodies += infoItNeighbor->second.numberOfLocalBodies; numBodies += infoItNeighbor->second.numberOfShadowBodies; diff --git a/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp b/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp index ecc2e6642f8ce1a404b35714a03a2a20a0892ecd..adca4508693a8a5802c3ea3a5fa883ad00bef304 100644 --- a/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp +++ b/tests/pe_coupling/momentum_exchange_method/SquirmerTest.cpp @@ -420,7 +420,7 @@ int main(int argc, char **argv) { auto b2 = beta * b1; auto e = q.rotate(up).getNormalized(); auto radius = R; - auto squirmer_pos = position; + const auto& squirmer_pos = position; real_t abs_tolerance = real_c(0.0026); real_t rel_tolerance = real_c(0.10); diff --git a/tests/pe_coupling/utility/PeSubCyclingTest.cpp b/tests/pe_coupling/utility/PeSubCyclingTest.cpp index fb869661f14bbcec5c24396947183181bc481329..54268c11156242574e34042fa850566fa465c78a 100644 --- a/tests/pe_coupling/utility/PeSubCyclingTest.cpp +++ b/tests/pe_coupling/utility/PeSubCyclingTest.cpp @@ -124,7 +124,7 @@ int main( int argc, char **argv ) Vector3<real_t> expectedAngularVel(real_t(0)); { - Vector3<real_t> startPos = positionInsideBlock; + const Vector3<real_t>& startPos = positionInsideBlock; pe::createSphere(*globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, startPos, radius, sphereMaterialID, false, true, false); @@ -185,7 +185,7 @@ int main( int argc, char **argv ) std::string testIdentifier("Test: sphere inside block"); WALBERLA_LOG_DEVEL_ON_ROOT(testIdentifier << " - started"); - Vector3<real_t> startPos = positionInsideBlock; + const Vector3<real_t>& startPos = positionInsideBlock; pe::createSphere(*globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, startPos, radius, sphereMaterialID, false, true, false); @@ -252,7 +252,7 @@ int main( int argc, char **argv ) std::string testIdentifier("Test: sphere at block border 1"); WALBERLA_LOG_DEVEL_ON_ROOT(testIdentifier << " - started"); - Vector3<real_t> startPos = positionAtBlockBorder; + const Vector3<real_t>& startPos = positionAtBlockBorder; pe::createSphere(*globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, startPos, radius, sphereMaterialID, false, true, false); @@ -318,7 +318,7 @@ int main( int argc, char **argv ) std::string testIdentifier("Test: sphere at block border 1 mod"); WALBERLA_LOG_DEVEL_ON_ROOT(testIdentifier << " - started"); - Vector3<real_t> startPos = positionAtBlockBorder; + const Vector3<real_t>& startPos = positionAtBlockBorder; pe::createSphere(*globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, startPos, radius, sphereMaterialID, false, true, false); @@ -385,7 +385,7 @@ int main( int argc, char **argv ) std::string testIdentifier("Test: sphere at block border 2"); WALBERLA_LOG_DEVEL_ON_ROOT(testIdentifier << " - started"); - Vector3<real_t> startPos = positionAtBlockBorder2; + const Vector3<real_t>& startPos = positionAtBlockBorder2; pe::createSphere(*globalBodyStorage, blocks->getBlockStorage(), bodyStorageID, 0, startPos, radius, sphereMaterialID, false, true, false);