Commit a938ecbb authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

updated clang tidy to version 8

parent ddb3cc85
---
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
......
......@@ -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
......@@ -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 )
......
......@@ -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 )
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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;
//@}
//****************************************************************************************************************
......
......@@ -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;
......
......@@ -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>());
......
......@@ -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 << '/';
......
......@@ -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;
}
......
......@@ -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<>
......
......@@ -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 );
......
......@@ -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();
......
......@@ -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];
......
......@@ -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() )
......
......@@ -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;}
......
......@@ -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 ) {
......
......@@ -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();
......
......@@ -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];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment