fix most pedantic compiler warnings in the basic infrastructure

i.e., using clang 3.8 to compile the test suite with the following
flags:

```
-Weverything
-Wno-documentation
-Wno-documentation-unknown-command
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-undef
-Wno-padded
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-weak-vtables
-Wno-float-equal
```

should not produce any warnings anymore. In my opinion the only flag
which would produce beneficial warnings is -Wdocumentation. This has
not been fixed in this patch because writing documentation is left for
another day (or, more likely, year).

note that this patch consists of a heavy dose of the OPM_UNUSED macro
and plenty of static_casts (to fix signedness issues). Fixing the
singedness issues were quite a nightmare and the fact that the Dune
API is quite inconsistent in that regard was not exactly helpful. :/

Finally this patch includes quite a few formatting changes (e.g., all
occurences of 'T &t' should be changed to `T& t`) and some fixes for
minor issues which I've found during the excercise.

I've made sure that all unit tests the test suite still pass
successfully and I've made sure that flow_ebos still works for Norne
and that it did not regress w.r.t. performance.

(Note that this patch does not fix compiler warnings triggered `ebos`
and `flow_ebos` but only those caused by the basic infrastructure or
the unit tests.)

v2: fix the warnings that occur if the dune-localfunctions module is
    not available. thanks to [at]atgeirr for testing.
v3: fix dune 2.3 build issue
This commit is contained in:
Andreas Lauser
2016-11-07 15:14:07 +01:00
parent 9b53930557
commit ec4b6c82dd
20 changed files with 610 additions and 435 deletions

View File

@@ -167,7 +167,7 @@ class Tutorial1Problem
public:
//! The constructor of the problem. This only _allocates_ the memory required by the
//! problem. The constructor is supposed to _never ever_ throw an exception.
Tutorial1Problem(Simulator &simulator)
Tutorial1Problem(Simulator& simulator)
: ParentType(simulator)
, eps_(3e-6)
{ }
@@ -200,36 +200,37 @@ public:
//! Returns the temperature at a given position.
template <class Context>
Scalar temperature(const Context &context, int spaceIdx, int timeIdx) const
Scalar temperature(const Context& /*context*/,
unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
{ return 283.15; }
//! Returns the intrinsic permeability tensor [m^2] at a position.
template <class Context>
const DimMatrix &intrinsicPermeability(const Context &context, /*@\label{tutorial1:permeability}@*/
int spaceIdx, int timeIdx) const
const DimMatrix& intrinsicPermeability(const Context& /*context*/, /*@\label{tutorial1:permeability}@*/
unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
{ return K_; }
//! Defines the porosity [-] of the medium at a given position
template <class Context>
Scalar porosity(const Context &context,
int spaceIdx, int timeIdx) const /*@\label{tutorial1:porosity}@*/
Scalar porosity(const Context& /*context*/,
unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const /*@\label{tutorial1:porosity}@*/
{ return 0.2; }
//! Returns the parameter object for the material law at a given position
template <class Context>
const MaterialLawParams &materialLawParams(const Context &context, /*@\label{tutorial1:matLawParams}@*/
int spaceIdx, int timeIdx) const
const MaterialLawParams& materialLawParams(const Context& /*context*/, /*@\label{tutorial1:matLawParams}@*/
unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
{ return materialParams_; }
//! Evaluates the boundary conditions.
template <class Context>
void boundary(BoundaryRateVector &values, const Context &context,
int spaceIdx, int timeIdx) const
void boundary(BoundaryRateVector& values, const Context& context,
unsigned spaceIdx, unsigned timeIdx) const
{
const auto &pos = context.pos(spaceIdx, timeIdx);
const auto& pos = context.pos(spaceIdx, timeIdx);
if (pos[0] < eps_) {
// Free-flow conditions on left boundary
const auto &materialParams = this->materialLawParams(context, spaceIdx, timeIdx);
const auto& materialParams = this->materialLawParams(context, spaceIdx, timeIdx);
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
Scalar Sw = 1.0;
@@ -261,8 +262,8 @@ public:
//! position of the domain [kg/(m^3 * s)]. Positive values mean that
//! mass is created.
template <class Context>
void source(RateVector &source, const Context &context, int spaceIdx,
int timeIdx) const
void source(RateVector& source, const Context& /*context*/,
unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const
{
source[contiWettingEqIdx] = 0.0;
source[contiNonWettingEqIdx] = 0.0;
@@ -270,8 +271,8 @@ public:
//! Evaluates the initial value at a given position in the domain.
template <class Context>
void initial(PrimaryVariables &values, const Context &context, int spaceIdx,
int timeIdx) const
void initial(PrimaryVariables& values, const Context& context,
unsigned spaceIdx, unsigned timeIdx) const
{
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
@@ -285,8 +286,7 @@ public:
// set pressure of the wetting phase to 200 kPa = 2 bar
Scalar pC[numPhases];
MaterialLaw::capillaryPressures(pC, materialLawParams(context, spaceIdx,
timeIdx),
MaterialLaw::capillaryPressures(pC, materialLawParams(context, spaceIdx, timeIdx),
fs);
fs.setPressure(wettingPhaseIdx, 200e3);
fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);