diff --git a/CMakeLists.txt b/CMakeLists.txt index 09791376e4b9ded572363feda27a751503c84589..204fe41897029aba3ad8ac60ad782c4b8062042f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -593,11 +593,16 @@ if( WALBERLA_CXX_COMPILER_IS_IBM ) endif() if ( WALBERLA_BUILD_WITH_BOOST_THREAD ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system thread regex ) + list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system thread ) else () - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system regex ) + list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system ) endif () +if ( WALBERLA_BUILD_WITH_BOOST AND WALBERLA_CXX_COMPILER_IS_IBM ) + list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS regex) +endif() + + if ( WALBERLA_BUILD_WITH_PYTHON AND WALBERLA_CXX_COMPILER_IS_MSVC ) list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS python3 ) endif() diff --git a/apps/tools/povrayFileCompressor/main.cpp b/apps/tools/povrayFileCompressor/main.cpp index b1364297fb9d27e533a2658ac759d833263225ea..86f1f9ee41b95a0a4eff496f6f53484eca7e71c3 100644 --- a/apps/tools/povrayFileCompressor/main.cpp +++ b/apps/tools/povrayFileCompressor/main.cpp @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -20,6 +20,7 @@ #include "geometry/mesh/TriangleMesh.h" #include "geometry/mesh/TriangleMeshIO.h" +#include "core/Regex.h" #include <fstream> #include <iomanip> @@ -28,10 +29,8 @@ #define BOOST_FILESYSTEM_NO_DEPRECATED #include <boost/filesystem.hpp> -#include <boost/regex.hpp> #include <boost/algorithm/string.hpp> - namespace fs = boost::filesystem; bool verbose; @@ -115,8 +114,8 @@ int main(int argc, char** argv) std::vector<fs::path> pfiles; for(auto tit = fs::directory_iterator(pit->path()); tit != fs::directory_iterator(); ++tit) { - static const boost::regex extensionExpression("\\.dat"); - if( boost::regex_match( tit->path().extension().string(), extensionExpression ) ) + static const walberla::regex extensionExpression("\\.dat"); + if( walberla::regex_match( tit->path().extension().string(), extensionExpression ) ) pfiles.push_back(tit->path()); } if( !pfiles.empty() ) diff --git a/src/core/Regex.h b/src/core/Regex.h new file mode 100644 index 0000000000000000000000000000000000000000..0acb44a282b3232b88687212fb148be4b65311a6 --- /dev/null +++ b/src/core/Regex.h @@ -0,0 +1,46 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Regex.h +//! \ingroup core +//! \author Dominik Thoennes <dominik.thoennes@fau.de> +// +//====================================================================================================================== + +#pragma once + + +#ifdef __IBMCPP__ +#include <boost/regex.hpp> +#else +#include <regex> +#endif + + +namespace walberla { + +#ifdef __IBMCPP__ +using boost::regex; +using boost::regex_match; +using boost::regex_error; +using boost::regex_search; +#else +using std::regex; +using std::regex_match; +using std::regex_error; +using std::regex_search; +#endif + +} \ No newline at end of file diff --git a/src/core/all.h b/src/core/all.h index c962afb69cbde42e8ce7b1dde6705e0426a7a5aa..bc7ca12dd4a7f6d4dc1683888bd978805ce600e3 100644 --- a/src/core/all.h +++ b/src/core/all.h @@ -35,6 +35,7 @@ #include "NonCopyable.h" #include "NonCreateable.h" #include "OpenMP.h" +#include "Regex.h" #include "Set.h" #include "SharedFunctor.h" #include "Sleep.h" diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index 74a7f40d59b98131c821e0fb8ed403c1b94dbb67..8660f50522529a23e278096380f1beb25b442390 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -127,7 +127,7 @@ void Config::readParameterFile( const char* const filename ) //std::cout<<"Sending contents of parameter file to other processes... ("<<size<<" bytes)"<<std::endl; } MPI_Bcast(&size,1,MPITrait<int>::type(),0,MPI_COMM_WORLD); - char* buffer = new char[size]; + char* buffer = new char[uint_c(size)]; WALBERLA_ROOT_SECTION() { fileContent.copy(buffer,uint_c(size)); } diff --git a/src/core/logging/Initialization.cpp b/src/core/logging/Initialization.cpp index 420cbbb1ecbe9fdddbe08f8037b34bccf97843f0..b802081780a1b29f84be83267fe48a86cf69c4b0 100644 --- a/src/core/logging/Initialization.cpp +++ b/src/core/logging/Initialization.cpp @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -34,7 +34,7 @@ namespace logging { -static void parseIgnoreBlocks( const Config::Blocks & ignoreBlocks, std::vector< boost::regex > & regexes ) +static void parseIgnoreBlocks( const Config::Blocks & ignoreBlocks, std::vector< walberla::regex > & regexes ) { for( auto ignoreBlock = ignoreBlocks.begin(); ignoreBlock != ignoreBlocks.end(); ++ignoreBlock ) { @@ -45,14 +45,14 @@ static void parseIgnoreBlocks( const Config::Blocks & ignoreBlocks, std::vector< boost::algorithm::replace_all( regexString, "/", "(\\\\|/)" ); try { - boost::regex regex( regexString ); + walberla::regex regex( regexString ); regexes.push_back( regex ); } - catch( const boost::bad_expression & e ) + catch( const walberla::regex_error & e ) { std::ostringstream oss; oss << __FILE__ << ":" << __LINE__ << " - Error parsing regular Expression \"" << regexString - << "\" from ignore block at position " << e.position() << "."; + << "\" from ignore block at position " << e.code() << "."; throw std::runtime_error( oss.str() ); } } @@ -213,7 +213,7 @@ void configureLogging( const Config::BlockHandle & loggingBlock ) Config::Blocks ignoreBlocks, ignoreWarningBlocks; loggingBlock.getBlocks( "ignore", ignoreBlocks ); - std::vector< boost::regex > regexes; + std::vector< walberla::regex > regexes; parseIgnoreBlocks( ignoreBlocks, regexes ); for( auto regex = regexes.begin(); regex != regexes.end(); ++regex ) logging::Logging::instance()->addIgnoreRegex( *regex ); diff --git a/src/core/logging/Logging.h b/src/core/logging/Logging.h index a01eaff9bab7ab0e84f69693648f6819f4e8bc5e..0f7a88319dfa29625b18ee6faa59a3179538a7bf 100644 --- a/src/core/logging/Logging.h +++ b/src/core/logging/Logging.h @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -28,10 +28,10 @@ #include "core/mpi/MPIManager.h" #include "core/singleton/Singleton.h" #include "core/timing/WcPolicy.h" +#include "core/Regex.h" #include <boost/algorithm/string/replace.hpp> #include <boost/function.hpp> -#include <boost/regex.hpp> #include <cmath> #include <fstream> @@ -113,12 +113,12 @@ public: void logCallerPath( bool log ) { logCallerPath_ = log; } bool logCallerPath() const { return logCallerPath_; } - void addIgnoreRegex( const boost::regex & regex ) { ignoreRegexes_.push_back( regex ); } - const std::vector< boost::regex > & getIgnoreRegexes() const { return ignoreRegexes_; } + void addIgnoreRegex( const walberla::regex & regex ) { ignoreRegexes_.push_back( regex ); } + const std::vector< walberla::regex > & getIgnoreRegexes() const { return ignoreRegexes_; } void clearIgnoreRegexes() { ignoreRegexes_.clear(); } - void addIgnoreWarningRegex( const boost::regex & regex ) { ignoreWarningRegexes_.push_back( regex ); } - const std::vector< boost::regex > & getIgnoreWarningRegexes() const { return ignoreWarningRegexes_; } + void addIgnoreWarningRegex( const walberla::regex & regex ) { ignoreWarningRegexes_.push_back( regex ); } + const std::vector< walberla::regex > & getIgnoreWarningRegexes() const { return ignoreWarningRegexes_; } void clearIgnoreWarningRegexes() { ignoreWarningRegexes_.clear(); } @@ -140,7 +140,7 @@ private: inline Logging(); - inline bool isInIgnoreCallerPaths( const std::vector< boost::regex > & regexes, + inline bool isInIgnoreCallerPaths( const std::vector< walberla::regex > & regexes, const std::string & callerPath, const int line ) const; inline void logError ( const std::string & message, const std::string & callerPath, const int line ); @@ -179,8 +179,8 @@ private: bool logCallerPath_; - std::vector< boost::regex > ignoreRegexes_; - std::vector< boost::regex > ignoreWarningRegexes_; + std::vector< walberla::regex > ignoreRegexes_; + std::vector< walberla::regex > ignoreWarningRegexes_; }; @@ -306,7 +306,7 @@ inline bool Logging::logTracing( const std::string & /*callerPath*/, const int / -inline bool Logging::isInIgnoreCallerPaths( const std::vector< boost::regex > & regexes, +inline bool Logging::isInIgnoreCallerPaths( const std::vector< walberla::regex > & regexes, const std::string & callerPath, const int line ) const { if( !regexes.empty() ) @@ -315,7 +315,7 @@ inline bool Logging::isInIgnoreCallerPaths( const std::vector< boost::regex > & callerPathAndLine << callerPath << ":" << line; for( auto regex = regexes.begin(); regex != regexes.end(); ++regex ) - if( boost::regex_search( callerPathAndLine.str(), *regex ) ) + if( walberla::regex_search( callerPathAndLine.str(), *regex ) ) return true; } diff --git a/src/core/math/ParserOMP.cpp b/src/core/math/ParserOMP.cpp index f9d277c9e07968d3b9ffb93e9b817715e80e7f54..b849c5bcac561c4426922a21d653bde197e6f6bc 100644 --- a/src/core/math/ParserOMP.cpp +++ b/src/core/math/ParserOMP.cpp @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -36,8 +36,8 @@ namespace math { -FunctionParserOMP::FunctionParserOMP() -: parser_(new FunctionParser[omp_get_max_threads()]) +FunctionParserOMP::FunctionParserOMP() +: parser_(new FunctionParser[uint_c(omp_get_max_threads())]) #ifndef NDEBUG , num_parsers_(omp_get_max_threads()) #endif @@ -47,7 +47,7 @@ FunctionParserOMP::FunctionParserOMP() void FunctionParserOMP::parse(const std::string & eq) { WALBERLA_ASSERT_EQUAL(omp_get_max_threads(), num_parsers_); - + #ifdef _OPENMP #pragma omp parallel for schedule(static) #endif @@ -60,7 +60,7 @@ void FunctionParserOMP::parse(const std::string & eq) double FunctionParserOMP::evaluate(const std::map<std::string,double> & symbolTable) const { WALBERLA_ASSERT_EQUAL(omp_get_max_threads(), num_parsers_); - + return parser_[omp_get_thread_num()].evaluate(symbolTable); }