From 831ce194a4034a53795ea97d61085cd1c72a550c Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Wed, 5 Nov 2014 22:41:57 +0000 Subject: [PATCH] removed some warnings and minor errors in the code --- AMDiS/src/AbstractFunction.h | 56 ++++++++++++++----- AMDiS/src/Expressions.h | 8 +-- AMDiS/src/Expressions.hh | 1 - AMDiS/src/Global.h | 3 + AMDiS/src/io/detail/Arh2Reader.cc | 8 +-- AMDiS/src/solver/BlockMTLMatrix.h | 8 +-- AMDiS/src/solver/Mapper.h | 6 +- AMDiS/src/solver/PetscTypes.hh | 2 +- AMDiS/src/solver/itl/block_diagonal.hpp | 2 +- AMDiS/src/time/RosenbrockAdaptInstationary.cc | 4 +- AMDiS/src/time/RosenbrockStationary.cc | 4 +- AMDiS/src/time/RosenbrockStationary.h | 4 +- extensions/base_problems/PolarizationField.hh | 6 +- extensions/base_problems/QuasiCrystal.h | 2 +- extensions/base_problems/QuasiCrystal.hh | 3 +- extensions/preconditioner/PetscPreconPfc.cc | 7 +-- .../preconditioner/PetscPreconPfcDiag.cc | 7 +-- 17 files changed, 77 insertions(+), 54 deletions(-) diff --git a/AMDiS/src/AbstractFunction.h b/AMDiS/src/AbstractFunction.h index e9902c46..35ec921d 100644 --- a/AMDiS/src/AbstractFunction.h +++ b/AMDiS/src/AbstractFunction.h @@ -44,6 +44,7 @@ namespace AMDiS { * To create your own function you have to derive AbstractFunction and * overload operator(). */ +// #ifndef HAS_VARIADIC_TEMPLATES template<typename ReturnType, typename ArgumentType> class AbstractFunction { @@ -67,7 +68,8 @@ namespace AMDiS { protected: int degree_; }; - +// #endif + /** * \ingroup Common * @@ -173,6 +175,7 @@ namespace AMDiS { int degree_; }; +// #ifndef HAS_VARIADIC_TEMPLATES /////////////////////////////////////////////////////////////// // test of AbstractFunction with arbitrary number of arguments @@ -195,17 +198,46 @@ namespace AMDiS { int degree_; \ }; \ -// template< typename ReturnType, -// BOOST_PP_ENUM_PARAMS(N, typename T) // expands to typename T0, typename T1, typename T2... -// > -// class CONCAT_STR(AbstractFunction,N) + +#if 0 // description of the macro + template< typename ReturnType, BOOST_PP_ENUM_PARAMS(N, typename T) >// expands to typename T0, typename T1, typename T2... + class CONCAT_STR(AbstractFunction,N) + { + public: + CONCAT_STR(AbstractFunction,N)(int degree = 0) : + degree_(degree) + {} + + virtual ~CONCAT_STR(AbstractFunction,N)() {} + + /// Returns \ref degree_. + inline int getDegree() const + { + return degree_; + } + + /// function evaluation. + virtual ReturnType operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, const T, &t)) const = 0; + + protected: + int degree_; + }; +#endif + + BOOST_PP_REPEAT_FROM_TO(1, 11, ABSTRACT_FUNCTION_MACRO, nil) + +// #else +// +// /// C++11 implementation of abstract functions with arbitrary nr of arguments using variadic templates +// template< typename ReturnType, typename... Ts > +// class AbstractFunction // { // public: -// CONCAT_STR(AbstractFunction,N)(int degree = 0) : -// degree_(degree) +// AbstractFunction(int degree = 0) +// : degree_(degree) // {} // -// virtual ~CONCAT_STR(AbstractFunction,N)() {} +// virtual ~AbstractFunction() {} // // /// Returns \ref degree_. // inline int getDegree() const @@ -214,15 +246,13 @@ namespace AMDiS { // } // // /// function evaluation. -// virtual ReturnType operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, const T, &t)) const = 0; +// virtual ReturnType operator()(Ts const&... args) const = 0; // // protected: // int degree_; // }; - - BOOST_PP_REPEAT_FROM_TO(1, 11, ABSTRACT_FUNCTION_MACRO, nil) - - +// +// #endif } #endif // AMDIS_ABSTRACTFUNCTION_H diff --git a/AMDiS/src/Expressions.h b/AMDiS/src/Expressions.h index c966a894..3d45287d 100644 --- a/AMDiS/src/Expressions.h +++ b/AMDiS/src/Expressions.h @@ -77,17 +77,17 @@ * * * with F a functor that implements - * typedef (...) value_type; + * typedef (...) result_type; * int getDegree(int d0); - * value_type operator()(const T0& v0) const; + * result_type operator()(const T0& v0) const; * * respective * int getDegree(int d0, int d1); - * value_type operator()(const T0& v0, const T1& v1) const; + * result_type operator()(const T0& v0, const T1& v1) const; * * respective * int getDegree(int d0, int d1, int d2); - * value_type operator()(const T0& v0, const T1& v1, const T2& v2) const; + * result_type operator()(const T0& v0, const T1& v1, const T2& v2) const; * * where the d0, d1, d2 give the polynomial degrees of the v0, v1, v2 terms. * */ diff --git a/AMDiS/src/Expressions.hh b/AMDiS/src/Expressions.hh index c2fdb888..19ed7463 100644 --- a/AMDiS/src/Expressions.hh +++ b/AMDiS/src/Expressions.hh @@ -96,7 +96,6 @@ template<typename Term, typename Functor> inline typename boost::enable_if<typename traits::is_expr<Term>::type, typename Term::value_type>::type accumulate(Term term, Functor f, typename Term::value_type value0) { - typedef typename Term::value_type TOut; typename GenericOperatorTerm<Term>::type ot(term); std::set<const FiniteElemSpace*> feSpaces = ot.getAuxFeSpaces(); diff --git a/AMDiS/src/Global.h b/AMDiS/src/Global.h index a15e0e91..42405845 100644 --- a/AMDiS/src/Global.h +++ b/AMDiS/src/Global.h @@ -46,6 +46,9 @@ #if !((defined BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_DECLTYPE)) #define HAS_CPP11_DECLTYPE #endif +#if !((defined BOOST_NO_CXX11_VARIADIC_TEMPLATES) || (defined BOOST_NO_VARIADIC_TEMPLATES)) || (defined BOOST_HAS_VARIADIC_TMPL) + #define HAS_VARIADIC_TEMPLATES +#endif /** \brief current AMDiS version */ #ifndef AMDIS_VERSION diff --git a/AMDiS/src/io/detail/Arh2Reader.cc b/AMDiS/src/io/detail/Arh2Reader.cc index d13a9d39..7a3e620f 100644 --- a/AMDiS/src/io/detail/Arh2Reader.cc +++ b/AMDiS/src/io/detail/Arh2Reader.cc @@ -567,7 +567,7 @@ namespace AMDiS { namespace io { vector<vector<int> > sortedFeSpaces(nFeSpaces); // Read macro table - for(int i = 0; i < nMacroElements; i++) { + for(uint32_t i = 0; i < nMacroElements; i++) { file.read(reinterpret_cast<char*>(¯oElIndex[i]), 4); file.read(reinterpret_cast<char*>(¯oElSize[i]), 4); } @@ -576,7 +576,7 @@ namespace AMDiS { namespace io { file.seekg(nFeSpaces * 4 * 4, ios_base::cur); // Read value table - for(int i = 0; i < nValueVectors; i++) { + for(uint32_t i = 0; i < nValueVectors; i++) { string tmpString(""); uint32_t tmpInt = 0; file.read(reinterpret_cast<char*>(&tmpInt), 4); @@ -586,7 +586,7 @@ namespace AMDiS { namespace io { sortedFeSpaces[tmpInt].push_back(i); } - for (unsigned int i = 0; i < nMacroElements; i++) { + for (uint32_t i = 0; i < nMacroElements; i++) { stringstream dataStream(ios::out | ios::in | ios::binary); int size = 0; @@ -623,7 +623,7 @@ namespace AMDiS { namespace io { if (nValueVectors > 0) { - for(unsigned int j = 0; j < nFeSpaces; j++) { + for(uint32_t j = 0; j < nFeSpaces; j++) { uint32_t nValuesPerVector = 0; dataStream.read(reinterpret_cast<char*>(&nValuesPerVector), 4); dataStream.seekg(sortedFeSpaces[j].size() * 8 * nValuesPerVector, ios_base::cur); diff --git a/AMDiS/src/solver/BlockMTLMatrix.h b/AMDiS/src/solver/BlockMTLMatrix.h index e615ce41..c25f5866 100644 --- a/AMDiS/src/solver/BlockMTLMatrix.h +++ b/AMDiS/src/solver/BlockMTLMatrix.h @@ -33,7 +33,7 @@ namespace AMDiS { /// A wrapper for AMDiS::SolverMatrix to be used in MTL/ITL solvers struct BlockMTLMatrix { - typedef typename mtl::Collection<MTLTypes::MTLMatrix>::size_type size_type; + typedef mtl::Collection<MTLTypes::MTLMatrix>::size_type size_type; size_type n; // overall number of rows size_type m; // overall number of columns @@ -42,11 +42,11 @@ namespace AMDiS { size_t n_cols; // number of column blocks BlockMTLMatrix() - : A(NULL), initialized(false) + : initialized(false), A(NULL) { } BlockMTLMatrix(const SolverMatrix<Matrix<DOFMatrix*> >& A_) - : A(&A_), initialized(false) + : initialized(false), A(&A_) { init(); } @@ -163,7 +163,7 @@ namespace mtl struct Collection<AMDiS::BlockMTLMatrix> { typedef double value_type; - typedef int size_type; + typedef AMDiS::BlockMTLMatrix::size_type size_type; }; namespace ashape diff --git a/AMDiS/src/solver/Mapper.h b/AMDiS/src/solver/Mapper.h index 960f6b78..b2deab96 100644 --- a/AMDiS/src/solver/Mapper.h +++ b/AMDiS/src/solver/Mapper.h @@ -193,8 +193,8 @@ namespace AMDiS { { const Matrix<DOFMatrix* >& orMat(*sm.getOriginalMat()); - for (int i= 0; i < nRowComp; i++) { - for (int j = 0; j < nColComp; j++) { + for (unsigned int i = 0; i < nRowComp; i++) { + for (unsigned int j = 0; j < nColComp; j++) { if (orMat[i][j]) { sizes_rows[i] = orMat[i][j]->getRowFeSpace()->getAdmin()->getUsedSize(); sizes_cols[j] = orMat[i][j]->getColFeSpace()->getAdmin()->getUsedSize(); @@ -202,7 +202,7 @@ namespace AMDiS { } nrow += sizes_rows[i]; } - for (int j = 0; j < nColComp; j++) + for (unsigned int j = 0; j < nColComp; j++) ncol += sizes_cols[j]; } diff --git a/AMDiS/src/solver/PetscTypes.hh b/AMDiS/src/solver/PetscTypes.hh index 77465090..0e104760 100644 --- a/AMDiS/src/solver/PetscTypes.hh +++ b/AMDiS/src/solver/PetscTypes.hh @@ -42,7 +42,7 @@ namespace AMDiS { bool initMatrix = false; unsigned nRows(0); - unsigned nEntries(0); +// unsigned nEntries(0); std::vector< int > nRowsBlock(A.getNumRows()); for(int i(0); i < A.getNumRows(); ++i) { int j(0); diff --git a/AMDiS/src/solver/itl/block_diagonal.hpp b/AMDiS/src/solver/itl/block_diagonal.hpp index 71d8b928..f92feb1f 100644 --- a/AMDiS/src/solver/itl/block_diagonal.hpp +++ b/AMDiS/src/solver/itl/block_diagonal.hpp @@ -26,7 +26,7 @@ class diagonal<AMDiS::BlockMTLMatrix, mtl::Collection<AMDiS::BlockMTLMatrix>::va for (size_t i = 0; i < A.n_rows; i++) inv_diag[A.getRowRange(i)] = mtl::matrix::diagonal(A.getSubMatrix(i,i)); - for (size_type i= 0; i < num_rows(A); ++i) + for (size_type i = 0; i < num_rows(A); ++i) inv_diag[i]= reciprocal(inv_diag[i]); } diff --git a/AMDiS/src/time/RosenbrockAdaptInstationary.cc b/AMDiS/src/time/RosenbrockAdaptInstationary.cc index 7825c6e8..0101a52b 100644 --- a/AMDiS/src/time/RosenbrockAdaptInstationary.cc +++ b/AMDiS/src/time/RosenbrockAdaptInstationary.cc @@ -36,13 +36,13 @@ namespace AMDiS { firstTimestep(true), lastTimestepRejected(false), succRejection(false), + maxRejectedSolverError(3), fixFirstTimesteps(0), tau(1.0), tauGamma(1.0), minusTauGamma(-1.0), invTauGamma(1.0), minusInvTauGamma(-1.0), - maxRejectedSolverError(3), dbgTimestepStudy(false) { initConstructor(problemStat); @@ -61,13 +61,13 @@ namespace AMDiS { firstTimestep(true), lastTimestepRejected(false), succRejection(false), + maxRejectedSolverError(3), fixFirstTimesteps(0), tau(1.0), tauGamma(1.0), minusTauGamma(-1.0), invTauGamma(1.0), minusInvTauGamma(-1.0), - maxRejectedSolverError(3), dbgTimestepStudy(false) { initConstructor(&problemStat); diff --git a/AMDiS/src/time/RosenbrockStationary.cc b/AMDiS/src/time/RosenbrockStationary.cc index 4ffda79c..820e7e0f 100644 --- a/AMDiS/src/time/RosenbrockStationary.cc +++ b/AMDiS/src/time/RosenbrockStationary.cc @@ -160,12 +160,12 @@ namespace AMDiS { } - double RosenbrockStationary::estimateTimeError(AdaptInfo* adaptInfo) + void RosenbrockStationary::estimateTimeError(AdaptInfo* adaptInfo) { for (int i = 0; i < nComponents; i++) { (*(lowSol->getDOFVector(i))) -= (*(newUn->getDOFVector(i))); adaptInfo->setTimeEstSum(lowSol->getDOFVector(i)->L2Norm(), i+componentShift); - } + } } diff --git a/AMDiS/src/time/RosenbrockStationary.h b/AMDiS/src/time/RosenbrockStationary.h index c7121971..10612a61 100644 --- a/AMDiS/src/time/RosenbrockStationary.h +++ b/AMDiS/src/time/RosenbrockStationary.h @@ -70,8 +70,8 @@ namespace AMDiS { public: RosenbrockStationary(std::string name, int componentShift_ = 0) : ProblemStat(name), - componentShift(componentShift_), first(true), + componentShift(componentShift_), minusOne(-1.0), stageTime(0.0), oldTime(0.0), @@ -88,7 +88,7 @@ namespace AMDiS { virtual Flag stageIteration(AdaptInfo *adaptInfo, Flag flag, bool asmMatrix, bool asmVector); - virtual double estimateTimeError(AdaptInfo* adaptInfo); + virtual void estimateTimeError(AdaptInfo* adaptInfo); /// update solution vector and oldTime value void acceptTimestep(AdaptInfo* adaptInfo); diff --git a/extensions/base_problems/PolarizationField.hh b/extensions/base_problems/PolarizationField.hh index 513968a4..4c61cad2 100644 --- a/extensions/base_problems/PolarizationField.hh +++ b/extensions/base_problems/PolarizationField.hh @@ -193,8 +193,7 @@ void PolarizationField<P>::fillLaplacian() template<typename P> void PolarizationField<P>::closeTimestep(AdaptInfo *adaptInfo) -{ FUNCNAME("PolarizationField::closeTimestep()"); - +{ calcVectorField(); for (size_t i = 0; i < self::dow; i++) oldSolution[i]->copy(*self::prob->getSolution()->getDOFVector(i)); @@ -205,8 +204,7 @@ void PolarizationField<P>::closeTimestep(AdaptInfo *adaptInfo) template<typename P> void PolarizationField<P>::writeFiles(AdaptInfo *adaptInfo, bool force) -{ FUNCNAME("PolarizationField::closeTimestep()"); - +{ super::writeFiles(adaptInfo, force); self::fileWriter->writeFiles(adaptInfo, false); } diff --git a/extensions/base_problems/QuasiCrystal.h b/extensions/base_problems/QuasiCrystal.h index 57264b9e..cf80ab13 100644 --- a/extensions/base_problems/QuasiCrystal.h +++ b/extensions/base_problems/QuasiCrystal.h @@ -27,7 +27,7 @@ namespace detail { ~QuasiCrystal() {}; void fillOperators() override; - void fillBoundaryConditions() {} override; + void fillBoundaryConditions() override {}; void finalizeData() override; diff --git a/extensions/base_problems/QuasiCrystal.hh b/extensions/base_problems/QuasiCrystal.hh index ad186eac..c1078a68 100644 --- a/extensions/base_problems/QuasiCrystal.hh +++ b/extensions/base_problems/QuasiCrystal.hh @@ -30,8 +30,7 @@ namespace AMDiS { namespace base_problems { template<typename P> void QuasiCrystal<P>::fillOperators() - { FUNCNAME("QuasiCrystal::fillOperators()"); - + { const FiniteElemSpace* feSpace = self::getFeSpace(0); DOFVector<double>* rho = self::prob->getSolution()->getDOFVector(0); diff --git a/extensions/preconditioner/PetscPreconPfc.cc b/extensions/preconditioner/PetscPreconPfc.cc index aa950490..91a56e9c 100644 --- a/extensions/preconditioner/PetscPreconPfc.cc +++ b/extensions/preconditioner/PetscPreconPfc.cc @@ -23,8 +23,7 @@ namespace AMDiS { /// solve Pfc Preconditioner PetscErrorCode pcPfcShell(PC pc, Vec b, Vec x) // solve Px=b - { FUNCNAME("pcPfcShell()"); - + { void *ctx; PCShellGetContext(pc, &ctx); PfcData* data = static_cast<PfcData*>(ctx); @@ -130,9 +129,7 @@ namespace AMDiS { void PetscPreconPfc::exit() - { - FUNCNAME("PetscPreconPfc::exit()"); - + { MatDestroy(&MpK); MatDestroy(&MpK2); diff --git a/extensions/preconditioner/PetscPreconPfcDiag.cc b/extensions/preconditioner/PetscPreconPfcDiag.cc index a16167fb..36632edd 100644 --- a/extensions/preconditioner/PetscPreconPfcDiag.cc +++ b/extensions/preconditioner/PetscPreconPfcDiag.cc @@ -23,8 +23,7 @@ namespace AMDiS { /// solve Pfc Preconditioner PetscErrorCode pcPfcDiagShell(PC pc, Vec b, Vec x) // solve Px=b - { FUNCNAME("pcPfcShell()"); - + { void *ctx; PCShellGetContext(pc, &ctx); PfcDiagData* data = static_cast<PfcDiagData*>(ctx); @@ -143,9 +142,7 @@ namespace AMDiS { void PetscPreconPfcDiag::exit() - { - FUNCNAME("PetscPreconPfcDiag::exit()"); - + { MatDestroy(&MpK); MatDestroy(&matS); -- GitLab