diff --git a/.clang-tidy b/.clang-tidy index 162294555c718c3912376188b34fa1fe3287c9ad..d7fa5fd7cadaa03cb38af7585371428b96a655bf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,bugprone-*,-bugprone-exception-escape,misc-*,-misc-misplaced-const,modernize-*,-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,performance-*' +Checks: '-*,bugprone-*,-bugprone-exception-escape,misc-*,-misc-misplaced-const,modernize-*,-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,-modernize-avoid-c-arrays,-misc-non-private-member-variables-in-classes,performance-*,readability-container-size-empty,readability-misleading-indentation,readability-misplaced-array-index' WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e16e20a2378830a2a792c94db732fda93509120f..7c428c1dbf071d034dc1a633512d96ac529d19c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1399,7 +1399,7 @@ doc: ############################################################################### clang-tidy: - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:7.0 + image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0 script: - $CXX --version - clang-tidy -version @@ -1877,4 +1877,4 @@ benchmark_gcc8: benchmark_clang8: <<: *benchmark_definition - image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0 \ No newline at end of file + image: i10git.cs.fau.de:5005/walberla/buildenvs/clang:8.0 diff --git a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp index 9c7b016f0d059a1f471df256c884b04055fe9e16..ddd54546f7bc8451b3353c2e1a7cf76b40961142 100644 --- a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp +++ b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp @@ -198,11 +198,11 @@ BoundaryHandling_T * MyBoundaryHandling::operator()( IBlock * const block, const const auto fluid = flagField->flagExists( Fluid_Flag ) ? flagField->getFlag( Fluid_Flag ) : flagField->registerFlag( Fluid_Flag ); BoundaryHandling_T * handling = new BoundaryHandling_T( "moving obstacle boundary handling", flagField, fluid, - UBB_T( "UBB", UBB_Flag, pdfField, velocity_), - Outlet_T( "Outlet", Outlet_Flag, pdfField, real_t(1) ), - MEM_BB_T ( "MEM_BB", MEM_BB_Flag, pdfField, flagField, bodyField, fluid, *storage, *block ), - MEM_CLI_T( "MEM_CLI", MEM_CLI_Flag, pdfField, flagField, bodyField, fluid, *storage, *block ), - MEM_MR_T ( "MEM_MR", MEM_MR_Flag, pdfField, flagField, bodyField, fluid, *storage, *block, pdfFieldPreCol ) ); + UBB_T( "UBB", UBB_Flag, pdfField, velocity_), + Outlet_T( "Outlet", Outlet_Flag, pdfField, real_t(1) ), + MEM_BB_T ( "MEM_BB", MEM_BB_Flag, pdfField, flagField, bodyField, fluid, *storage, *block ), + MEM_CLI_T( "MEM_CLI", MEM_CLI_Flag, pdfField, flagField, bodyField, fluid, *storage, *block ), + MEM_MR_T ( "MEM_MR", MEM_MR_Flag, pdfField, flagField, bodyField, fluid, *storage, *block, pdfFieldPreCol ) ); const auto ubb = flagField->getFlag( UBB_Flag ); const auto outlet = flagField->getFlag( Outlet_Flag ); @@ -522,7 +522,7 @@ public: VTKInfoLogger( SweepTimeloop* timeloop, const shared_ptr< StructuredBlockStorage > & blocks, const ConstBlockDataID & bodyStorageID, const std::string & baseFolder, const Vector3<real_t>& u_infty ) : - timeloop_( timeloop ), blocks_( blocks ), bodyStorageID_( bodyStorageID ), baseFolder_( baseFolder ), u_infty_( u_infty ) + timeloop_( timeloop ), blocks_( blocks ), bodyStorageID_( bodyStorageID ), baseFolder_( baseFolder ), u_infty_( u_infty ) { } void operator()() @@ -677,16 +677,44 @@ int main( int argc, char **argv ) for( int i = 1; i < argc; ++i ) { - if( std::strcmp( argv[i], "--Galileo" ) == 0 ) Galileo = real_c( std::atof( argv[++i] ) ); // targeted Galileo number - else if( std::strcmp( argv[i], "--diameter" ) == 0 ) diameter = real_c( std::atof( argv[++i] ) ); // diameter of the spheres, in cells per diameter - else if( std::strcmp( argv[i], "--noViscosityIterations" ) == 0 ) noViscosityIterations = true; // keep viscosity unchanged in initial simulation - else if( std::strcmp( argv[i], "--vtkIOInit" ) == 0 ) vtkIOInit = true; // write vtk IO for initial simulation - else if( std::strcmp( argv[i], "--longDom" ) == 0 ) longDom = true; // use a domain that is extended by the original domain length in positive and negative streamwise direction - else if( std::strcmp( argv[i], "--useMEM" ) == 0 ) // use momentum exchange coupling and the given MEM variant (BB, CLI, or MR) - { useMEM = true; memVariant = to_MEMVariant( argv[++i] ); } - else if( std::strcmp( argv[i], "--usePSM" ) == 0 ) // use partially saturated cells method and the given PSM variant (SC1W1, SC1W2, SC2W1, SC2W2, SC3W1, or SC3W2) - { usePSM = true; psmVariant = to_PSMVariant( argv[++i] ); } - else WALBERLA_ABORT("command line argument unknown: " << argv[i] ); + if( std::strcmp( argv[i], "--Galileo" ) == 0 ) + { + Galileo = real_c( std::atof( argv[++i] ) ); // targeted Galileo number + continue; + } + if( std::strcmp( argv[i], "--diameter" ) == 0 ) + { + diameter = real_c( std::atof( argv[++i] ) ); // diameter of the spheres, in cells per diameter + continue; + } + if( std::strcmp( argv[i], "--noViscosityIterations" ) == 0 ) + { + noViscosityIterations = true; // keep viscosity unchanged in initial simulation + continue; + } + if( std::strcmp( argv[i], "--vtkIOInit" ) == 0 ) + { + vtkIOInit = true; // write vtk IO for initial simulation + continue; + } + if( std::strcmp( argv[i], "--longDom" ) == 0 ) + { + longDom = true; // use a domain that is extended by the original domain length in positive and negative streamwise direction + continue; + } + if( std::strcmp( argv[i], "--useMEM" ) == 0 ) // use momentum exchange coupling and the given MEM variant (BB, CLI, or MR) + { + useMEM = true; + memVariant = to_MEMVariant( argv[++i] ); + continue; + } + if( std::strcmp( argv[i], "--usePSM" ) == 0 ) // use partially saturated cells method and the given PSM variant (SC1W1, SC1W2, SC2W1, SC2W2, SC3W1, or SC3W2) + { + usePSM = true; + psmVariant = to_PSMVariant( argv[++i] ); + continue; + } + WALBERLA_ABORT("command line argument unknown: " << argv[i] ); } if( !useMEM && !usePSM ) WALBERLA_ABORT("No coupling method chosen via command line!\nChose either \"--useMEM MEMVARIANT\" or \"--usePSM PSMVARIANT\"!"); @@ -712,24 +740,24 @@ int main( int argc, char **argv ) // values are taken from the original simulation of Uhlmann, Dusek switch( int(Galileo) ) { - case 144: - Re_target = real_t(185.08); - timestepsNonDim = real_t(100); - break; - case 178: - Re_target = real_t(243.01); - timestepsNonDim = real_t(250); - break; - case 190: - Re_target = real_t(262.71); - timestepsNonDim = real_t(250); - break; - case 250: - Re_target = real_t(365.10); - timestepsNonDim = real_t(510); - break; - default: - WALBERLA_ABORT("Galileo number is different from the usual ones (144, 178, 190, or 250). No estimate of the Reynolds number available. Add this case manually!"); + case 144: + Re_target = real_t(185.08); + timestepsNonDim = real_t(100); + break; + case 178: + Re_target = real_t(243.01); + timestepsNonDim = real_t(250); + break; + case 190: + Re_target = real_t(262.71); + timestepsNonDim = real_t(250); + break; + case 250: + Re_target = real_t(365.10); + timestepsNonDim = real_t(510); + break; + default: + WALBERLA_ABORT("Galileo number is different from the usual ones (144, 178, 190, or 250). No estimate of the Reynolds number available. Add this case manually!"); } // estimate fitting inflow velocity (diffusive scaling, viscosity is fixed) @@ -890,7 +918,7 @@ int main( int argc, char **argv ) // add boundary handling & initialize outer domain boundaries BlockDataID boundaryHandlingID = blocks->addStructuredBlockData< BoundaryHandling_T >( - MyBoundaryHandling( flagFieldID, pdfFieldID, bodyFieldID, pdfFieldPreColID, uInfty ), "boundary handling" ); + MyBoundaryHandling( flagFieldID, pdfFieldID, bodyFieldID, pdfFieldPreColID, uInfty ), "boundary handling" ); if( usePSM ){ // mapping of sphere required by PSM methods @@ -969,8 +997,8 @@ int main( int argc, char **argv ) // add LBM communication function and boundary handling sweep timeloopInit.add() - << BeforeFunction( commFunction, "LBM Communication" ) - << Sweep( BoundaryHandling_T::getBlockSweep( boundaryHandlingID ), "Boundary Handling" ); + << BeforeFunction( commFunction, "LBM Communication" ) + << Sweep( BoundaryHandling_T::getBlockSweep( boundaryHandlingID ), "Boundary Handling" ); // LBM stream collide sweep if( psmVariant == PSMVariant::SC1W1 ) @@ -1079,8 +1107,8 @@ int main( int argc, char **argv ) } WALBERLA_LOG_INFO_ON_ROOT("Initial simulation has ended.") - //evaluate the gravitational force necessary to keep the sphere at a approximately fixed position - gravity = forceEval->getForce() / ( (densityRatio - real_t(1) ) * diameter * diameter * diameter * math::pi / real_t(6) ); + //evaluate the gravitational force necessary to keep the sphere at a approximately fixed position + gravity = forceEval->getForce() / ( (densityRatio - real_t(1) ) * diameter * diameter * diameter * math::pi / real_t(6) ); GalileoSim = std::sqrt( ( densityRatio - real_t(1) ) * gravity * diameter * diameter * diameter ) / viscosity; ReynoldsSim = uIn * diameter / viscosity; u_ref = std::sqrt( std::fabs(densityRatio - real_t(1)) * gravity * diameter ); @@ -1113,9 +1141,9 @@ int main( int argc, char **argv ) // iterate all blocks with an iterator 'block' and change the collision model for( auto block = blocks->begin(); block != blocks->end(); ++block ) { - // get the field data out of the block - auto pdf = block->getData< PdfField_T > ( pdfFieldID ); - pdf->latticeModel().collisionModel().resetWithMagicNumber( newOmega, magicNumberTRT ); + // get the field data out of the block + auto pdf = block->getData< PdfField_T > ( pdfFieldID ); + pdf->latticeModel().collisionModel().resetWithMagicNumber( newOmega, magicNumberTRT ); } WALBERLA_LOG_INFO_ON_ROOT("==> Adapting viscosity:"); @@ -1157,8 +1185,8 @@ int main( int argc, char **argv ) // add LBM communication function and boundary handling sweep (does the hydro force calculations and the no-slip treatment) timeloop.add() - << BeforeFunction( commFunction, "LBM Communication" ) - << Sweep( BoundaryHandling_T::getBlockSweep( boundaryHandlingID ), "Boundary Handling" ); + << BeforeFunction( commFunction, "LBM Communication" ) + << Sweep( BoundaryHandling_T::getBlockSweep( boundaryHandlingID ), "Boundary Handling" ); // LBM stream collide sweep if( psmVariant == PSMVariant::SC1W1 ) diff --git a/src/blockforest/SetupBlockForest.cpp b/src/blockforest/SetupBlockForest.cpp index a6c2e9a0a1e8ba22cae9c48d9b24bb8dfe442281..93281d111ead0972ff25c497e750a2f48d5f8a93 100644 --- a/src/blockforest/SetupBlockForest.cpp +++ b/src/blockforest/SetupBlockForest.cpp @@ -713,7 +713,7 @@ void SetupBlockForest::init( const AABB& domain, const uint_t xSize, const uint_ RootBlockAABB rootBlockAABB( domain, rootBlockSize_[0], rootBlockSize_[1], rootBlockSize_[2], xSize, ySize, zSize ); - if( rootBlockExclusionFunctions.size() > 0 ) + if( !rootBlockExclusionFunctions.empty() ) WALBERLA_LOG_PROGRESS( "Initializing SetupBlockForest: Calling root block exclusion callback functions ..." ); for( uint_t i = 0; i != rootBlockExclusionFunctions.size(); ++i ) diff --git a/src/blockforest/loadbalancing/DynamicParMetis.cpp b/src/blockforest/loadbalancing/DynamicParMetis.cpp index ddc0cbe4cb67a9fc5f252897e1fddc90e7164724..94142b23766556f90fa5545b9414c9410ec52cc1 100644 --- a/src/blockforest/loadbalancing/DynamicParMetis.cpp +++ b/src/blockforest/loadbalancing/DynamicParMetis.cpp @@ -113,7 +113,7 @@ bool DynamicParMetis::operator()( std::vector< std::pair< const PhantomBlock *, MPI_Group allGroup, subGroup; MPI_Comm_group( MPIManager::instance()->comm(), &allGroup ); std::vector<int> ranks; - if (targetProcess.size() > 0) + if (!targetProcess.empty()) ranks.push_back( MPIManager::instance()->rank() ); ranks = mpi::allGatherv( ranks, MPIManager::instance()->comm() ); auto numSubProcesses = ranks.size(); diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index d850e6c5a3b51c8f6db443cabbe67c6e88e88922..4c89d93c1b88839fa30f13bec4870336946deb02 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -657,7 +657,7 @@ void Config::Block::getWritableBlocks( const std::string & key, std::vector<Bloc // \param value The value of the new parameter. // \return \a true if a new parameter was added, \a false if duplicate key is present. */ -bool Config::Block::addParameter( std::string key, const std::string& value ) +bool Config::Block::addParameter( const std::string& key, const std::string& value ) { return params_.insert( std::pair<Key,Value>(key,value) ).second; } diff --git a/src/core/config/Config.h b/src/core/config/Config.h index 88ef3ae20d9b0761ebb9e87b10bd76cbd2305efe..9837b870c7f0151aad400f509958c69d5290f171 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -225,7 +225,7 @@ public: //**Utility functions********************************************************************************************* /*! \name Utility functions */ //@{ - bool addParameter( std::string key, const std::string& value ); + bool addParameter( const std::string& key, const std::string& value ); void listParameters() const; //@} //**************************************************************************************************************** diff --git a/src/core/config/Create.cpp b/src/core/config/Create.cpp index 6bc78a70209c9aedb69d825531677fa3c3f5bbc0..1d3c7296540931f88508712b6dc58abded97bea1 100644 --- a/src/core/config/Create.cpp +++ b/src/core/config/Create.cpp @@ -83,7 +83,7 @@ namespace config { void createFromTextFile( Config & config, const std::string & pathToTextFile ) { config.readParameterFile( pathToTextFile.c_str() ); - if (config.error() != "" ) + if ( !config.error().empty() ) throw std::runtime_error( "FileReader returned an error reading the parameter file: \n" + config.error() ); } @@ -111,7 +111,7 @@ namespace config { vector< string > equalitySignSplitResult = string_split( *param, "=" ); std::string value; - if ( equalitySignSplitResult.size() == 0 ) + if ( equalitySignSplitResult.empty() ) { WALBERLA_LOG_WARNING( "Ignoring empty parameter"); continue; diff --git a/src/core/math/Parser.cpp b/src/core/math/Parser.cpp index a2d48044392490a797629e47ade6a4fc32ccc760..b3a4575677d319efd1cd2d198cbcedd228bb561e 100644 --- a/src/core/math/Parser.cpp +++ b/src/core/math/Parser.cpp @@ -111,7 +111,7 @@ void FunctionParser::parse( const std::string & eq ) // check if this expression evaluates to constant zero std::vector< std::string > variables; symbolTable_->get_variable_list( variables ); - isConstant_ = (variables.size() == 0); + isConstant_ = (variables.empty()); if (isConstant_) { const double value = evaluate(std::map<std::string, double>()); diff --git a/src/core/math/PhysicalCheck.cpp b/src/core/math/PhysicalCheck.cpp index 4800f192929bbcd0d60aa353e8955fae0f38d7ad..e6a3c26e8cf8c75b2d182a1323cb6b9640d40bb6 100644 --- a/src/core/math/PhysicalCheck.cpp +++ b/src/core/math/PhysicalCheck.cpp @@ -194,7 +194,7 @@ namespace math { if( i->second < 0 ) { - if( denom.str().size() > 0 ) + if( !denom.str().empty() ) denom << " * "; denom << i->first; } @@ -209,16 +209,16 @@ namespace math { num << " ^ " << i->second; } - if( num.str().size() == 0 && denom.str().size() == 0 ) + if( num.str().empty() && denom.str().empty() ) return std::string(); - if( denom.str().size() == 0 ) + if( denom.str().empty() ) { num << " *"; return num.str(); } - if( num.str().size() == 0 ) + if( num.str().empty() ) num << " * 1"; num << " / ( "; @@ -321,7 +321,7 @@ namespace math { if( !isDefined(varName) ) { WALBERLA_ABORT( "Error in PhysicalCheck::getVarUnit(). Variable not found: " << varName ); - return nullptr; + return std::string(); } std::stringstream num, denom; @@ -341,13 +341,13 @@ namespace math { num << '^' << i->second; } - if( num.str().size() == 0 && denom.str().size() == 0 ) + if( num.str().empty() && denom.str().empty() ) return std::string(); - if( denom.str().size() == 0 ) + if( denom.str().empty() ) return num.str(); - if( num.str().size() == 0 ) + if( num.str().empty() ) num << 1; num << '/'; diff --git a/src/gather/MPIGatherScheme.cpp b/src/gather/MPIGatherScheme.cpp index c40a63c691255072678aa70c9621fc38583e08f9..1fc309303fbced68844561da221c1fd833f6a008 100644 --- a/src/gather/MPIGatherScheme.cpp +++ b/src/gather/MPIGatherScheme.cpp @@ -169,7 +169,7 @@ void MPIGatherScheme::communicate() auto mpiManager = MPIManager::instance(); - if ( packInfos_.size() == 0 ) { + if ( packInfos_.empty() ) { WALBERLA_LOG_WARNING( "Communicating MPIGatherScheme without registered PackInfos"); return; } diff --git a/src/geometry/bodies/Sphere.cpp b/src/geometry/bodies/Sphere.cpp index f7fc0dce0f1bc57ca1da2e0d686c832552ebb8dd..ffd62b51aa7799e18743b286b86eaf3e6acafe5d 100644 --- a/src/geometry/bodies/Sphere.cpp +++ b/src/geometry/bodies/Sphere.cpp @@ -57,9 +57,9 @@ namespace geometry { template<> FastOverlapResult fastOverlapCheck ( const Sphere & sphere, const AABB & box ) { - if ( ! sphere.boundingBox().intersects( box ) ) return COMPLETELY_OUTSIDE; - else if ( sphere.innerBox() .contains( box ) ) return CONTAINED_INSIDE_BODY; - else return DONT_KNOW; + if ( ! sphere.boundingBox().intersects( box ) ) return COMPLETELY_OUTSIDE; + if ( sphere.innerBox() .contains( box ) ) return CONTAINED_INSIDE_BODY; + return DONT_KNOW; } template<> diff --git a/src/geometry/mesh/TriangleMeshIO.cpp b/src/geometry/mesh/TriangleMeshIO.cpp index 3581637e30e278fa638b72a7cbbf0d466c2f229b..1161e086540dc8a195f03354f61ac2c22041cd65 100644 --- a/src/geometry/mesh/TriangleMeshIO.cpp +++ b/src/geometry/mesh/TriangleMeshIO.cpp @@ -493,16 +493,15 @@ namespace geometry { bool hasVertexNormals = mesh.hasVertexNormals(); size_t j; - TriangleMesh::index_t i; - for( i = 0u; i < mesh.getNumVertices(); ++i ){ + for( TriangleMesh::index_t i = 0; i < mesh.getNumVertices(); ++i ){ j = i / itemsPerMesh; meshVec[j].addVertex( mesh.getVertex(i) ); if( hasVertexNormals ) meshVec[j].addVertexNormal( mesh.getVertexNormal(i) ); } - for( i = 0u; i < mesh.getNumTriangles(); ++i ){ + for( size_t i = 0; i < mesh.getNumTriangles(); ++i ){ TriangleMesh::index_t ix = mesh.getVertexIndex( i, 0 ); TriangleMesh::index_t iy = mesh.getVertexIndex( i, 1 ); TriangleMesh::index_t iz = mesh.getVertexIndex( i, 2 ); diff --git a/src/mesa_pd/collision_detection/EPA.cpp b/src/mesa_pd/collision_detection/EPA.cpp index 304b4e6f16a3b2229ea0ff72648b0c9d1fcef838..3fb4ced431d587865cd0e5a454979823c2d31988 100644 --- a/src/mesa_pd/collision_detection/EPA.cpp +++ b/src/mesa_pd/collision_detection/EPA.cpp @@ -275,7 +275,7 @@ bool EPA::doEPA( Support &geom1, } } - if(entryHeap.size() == 0) { + if(entryHeap.empty()) { //unrecoverable error. return false; } @@ -473,7 +473,7 @@ bool EPA::doEPA( Support &geom1, firstTriangle->link(2, lastTriangle, 1); } - } while (entryHeap.size() > 0 && entryHeap[0]->getSqrDist() <= upperBoundSqr); + } while (!entryHeap.empty() && entryHeap[0]->getSqrDist() <= upperBoundSqr); //Normal must be inverted retNormal = -current->getClosest().getNormalizedOrZero(); diff --git a/src/mesa_pd/collision_detection/GJK.cpp b/src/mesa_pd/collision_detection/GJK.cpp index edd2a963ff1cf5678e2363af7aa28e3e202c23e7..4732d365ae93754537d62051a596267c2c234a75 100644 --- a/src/mesa_pd/collision_detection/GJK.cpp +++ b/src/mesa_pd/collision_detection/GJK.cpp @@ -313,7 +313,7 @@ inline real_t GJK::calcDistance( Vec3& normal, Vec3& contactPoint ) //its distance to the origin is the distance of the two objects real_t dist= 0.0; - real_t barCoords[3] = { 0.0, 0.0, 0.0}; + std::array<real_t, 3> barCoords = {{ 0.0, 0.0, 0.0 }}; real_t& u = barCoords[0]; real_t& v = barCoords[1]; real_t& w = barCoords[2]; diff --git a/src/mesa_pd/vtk/ParticleVtkOutput.cpp b/src/mesa_pd/vtk/ParticleVtkOutput.cpp index b63295893ed9827127aabcbe3ae26eb44e48e539..018670be9dd72965049fd3c0006fbe41a3cecd0f 100644 --- a/src/mesa_pd/vtk/ParticleVtkOutput.cpp +++ b/src/mesa_pd/vtk/ParticleVtkOutput.cpp @@ -72,7 +72,7 @@ void ParticleVtkOutput::push( walberla::vtk::Base64Writer& b64, const uint_t dat selectors_[data].second->push(b64, (*ps_)[particleIndices_[point]], component); } -void ParticleVtkOutput::addOutput(const std::string& name, std::shared_ptr<IOutputSelector> selector) +void ParticleVtkOutput::addOutput(const std::string& name, const std::shared_ptr<IOutputSelector>& selector) { if ( std::find_if(selectors_.begin(), selectors_.end(), [&name](const auto& item){return item.first==name;} ) != selectors_.end() ) diff --git a/src/mesa_pd/vtk/ParticleVtkOutput.h b/src/mesa_pd/vtk/ParticleVtkOutput.h index 651403cea4cc750620486306a6debb4290dc8eb1..5cbe88a6d546009b550aac368d836c56aa79f68e 100644 --- a/src/mesa_pd/vtk/ParticleVtkOutput.h +++ b/src/mesa_pd/vtk/ParticleVtkOutput.h @@ -55,7 +55,7 @@ public: template <typename T> void addOutput(const std::string& name) { addOutput(name, std::make_shared<OutputSelector<T>>(T())); } - void addOutput(const std::string& name, std::shared_ptr<IOutputSelector> selector); + void addOutput(const std::string& name, const std::shared_ptr<IOutputSelector>& selector); ///sets a function which decides which particles should be written to file void setParticleSelector( const ParticleSelectorFunc& func) {particleSelector_ = func;} diff --git a/src/pe/ccd/HashGrids.cpp b/src/pe/ccd/HashGrids.cpp index b73a25548efae620d69f6310df736e3900d922e0..0f9d4908dc4ad4c2dea8dab6c95534ebbab13dc3 100644 --- a/src/pe/ccd/HashGrids.cpp +++ b/src/pe/ccd/HashGrids.cpp @@ -788,7 +788,7 @@ void HashGrids::update(WcTimingTree* tt) if (tt != nullptr) tt->start("AddNewBodies"); // Finally add all bodies that were temporarily stored in 'bodiesToAdd_' to the data structure. - if( bodiesToAdd_.size() > 0 ) + if( !bodiesToAdd_.empty() ) { for( auto bodyIt = bodiesToAdd_.begin(); bodyIt < bodiesToAdd_.end(); ++bodyIt ) { diff --git a/src/pe/collision/EPA.cpp b/src/pe/collision/EPA.cpp index 85775e5a89893aa2638ac7ae0cb58d64c750d7a6..6e7eb97551070580c1686139876341868d5923d7 100644 --- a/src/pe/collision/EPA.cpp +++ b/src/pe/collision/EPA.cpp @@ -263,7 +263,7 @@ bool EPA::doEPA( GeomPrimitive &geom1, GeomPrimitive &geom2, const GJK& gjk, Vec } } - if(entryHeap.size() == 0) { + if(entryHeap.empty()) { //unrecoverable error. return false; } @@ -461,7 +461,7 @@ bool EPA::doEPA( GeomPrimitive &geom1, GeomPrimitive &geom2, const GJK& gjk, Vec firstTriangle->link(2, lastTriangle, 1); } - } while (entryHeap.size() > 0 && entryHeap[0]->getSqrDist() <= upperBoundSqr); + } while (!entryHeap.empty() && entryHeap[0]->getSqrDist() <= upperBoundSqr); //Normal must be inverted retNormal = -current->getClosest().getNormalized(); diff --git a/src/pe/collision/GJK.cpp b/src/pe/collision/GJK.cpp index e25c62b5e5114fbde39d5e8ee127b12af18f21da..d2320f9ec63d8c9c68b919e149e8a21d360a695f 100644 --- a/src/pe/collision/GJK.cpp +++ b/src/pe/collision/GJK.cpp @@ -286,7 +286,7 @@ inline real_t GJK::calcDistance( Vec3& normal, Vec3& contactPoint ) //its distance to the origin is the distance of the two objects real_t dist= 0.0; - real_t barCoords[3] = { 0.0, 0.0, 0.0}; + std::array<real_t, 3> barCoords = {{ 0.0, 0.0, 0.0 }}; real_t& u = barCoords[0]; real_t& v = barCoords[1]; real_t& w = barCoords[2]; diff --git a/src/timeloop/PerformanceMeter.cpp b/src/timeloop/PerformanceMeter.cpp index 6efb92d969bb67da70230c1453a7c0a4cb62db9b..d7986320312cac1969331a2a8678821d09960873 100644 --- a/src/timeloop/PerformanceMeter.cpp +++ b/src/timeloop/PerformanceMeter.cpp @@ -82,7 +82,7 @@ namespace timeloop { * Behaves like addMeasurement() function above, with n= total number of cells * *******************************************************************************************************************/ - void PerformanceMeter::addMeasurement ( const std::string & name, CountFunction countFunction, + void PerformanceMeter::addMeasurement ( const std::string & name, const CountFunction& countFunction, uint_t countFreq, real_t scaling ) { measurements_.emplace_back( countFunction, name, scaling, countFreq ); @@ -126,7 +126,7 @@ namespace timeloop { *******************************************************************************************************************/ void PerformanceMeter::logResultOnRoot( ) { - if( measurements_.size() == 0) + if( measurements_.empty()) return; std::stringstream ss; @@ -148,7 +148,7 @@ namespace timeloop { *******************************************************************************************************************/ void PerformanceMeter::print( std::ostream & os, int targetRank ) { - if( measurements_.size() == 0) + if( measurements_.empty()) return; std::vector<real_t> totalNrCells; @@ -294,7 +294,7 @@ namespace timeloop { *******************************************************************************************************************/ void PerformanceMeter::reduce ( std::vector<real_t> & reduced, int targetRank ) { - if ( measurements_.size() == 0 ) + if ( measurements_.empty() ) return; reduced.clear(); diff --git a/src/timeloop/PerformanceMeter.h b/src/timeloop/PerformanceMeter.h index 731f968fe7046e95e03f7ac2e7953119fce48f57..0efac6514774670b2efae9f08274be25a3e4ebb0 100644 --- a/src/timeloop/PerformanceMeter.h +++ b/src/timeloop/PerformanceMeter.h @@ -95,7 +95,7 @@ namespace timeloop { //** Measurement Definitions ************************************************************************************* /*! \name Measurement Definitions */ //@{ - void addMeasurement( const std::string & name, CountFunction countFunction, + void addMeasurement( const std::string & name, const CountFunction& countFunction, uint_t countFreq = 0, real_t scaling = 1 ); void addMeasurement( const std::string & name, real_t scaling = 1 ); diff --git a/utilities/filterCompileCommands.py b/utilities/filterCompileCommands.py index 3b0a08e7f932c224ce36d3845425937fadc08057..cb4813231736c7e40eb6c0f7eb2f664e0ebba522 100755 --- a/utilities/filterCompileCommands.py +++ b/utilities/filterCompileCommands.py @@ -6,6 +6,13 @@ import sys def compileCommandSelector(x): return not (("extern" in x["file"]) or ("tests" in x["file"])) +def removePrecompiler(x): + pos = x.find("clang++") + if (pos != -1): + return x[pos:] + else: + return x + if __name__ == "__main__": if (len(sys.argv) != 2): print("usage: ./filterCompileCommands.py compile_commands.json") @@ -21,6 +28,8 @@ if __name__ == "__main__": print("compile commands read: {}".format(len(cc))) cc_filtered = list( filter(compileCommandSelector, cc) ) + for x in cc_filtered: + x["command"] = removePrecompiler(x["command"]) print("compile commands filtered: {}".format(len(cc_filtered)))