// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright (C) 2011-2013 by Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM 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 2 of the License, or
(at your option) any later version.
OPM 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 OPM. If not, see .
*/
/*!
* \file
*
* \brief This test makes sure that the programming interface is
* observed by all fluid systems
*/
#include "config.h"
#include
#include
#include
// include all fluid systems in opm-material
#include
#include
#include
#include
#include
#include
#include
#include
#include
// include all fluid states
#include
#include
#include
#include
#include
#include
#include
// include the tables for CO2 which are delivered with opm-material by default
#include
namespace Opm {
namespace FluidSystemsTest {
#include
} }
#include
// include dune's MPI helper header
#include
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2,3)
#include
#else
#include
#endif
#include
// check that the blackoil fluid system implements all non-standard functions
template
void ensureBlackoilApi()
{
// here we don't want to call these methods at runtime, we just want to make sure
// that they compile
while (false) {
#if HAVE_OPM_PARSER
Opm::DeckConstPtr deck;
Opm::EclipseStateConstPtr eclState;
FluidSystem::initFromDeck(deck, eclState);
#endif
typedef typename FluidSystem::Scalar Scalar;
typedef Opm::CompositionalFluidState FluidState;
FluidState fluidState;
Evaluation XoG = 0.0;
Evaluation XgO = 0.0;
Evaluation Rs = 0.0;
Evaluation Rv = 0.0;
Evaluation dummy;
// some additional typedefs
typedef typename FluidSystem::OilPvt OilPvt;
typedef typename FluidSystem::GasPvt GasPvt;
typedef typename FluidSystem::WaterPvt WaterPvt;
// check the black-oil specific enums
static_assert(FluidSystem::numPhases == 3, "");
static_assert(FluidSystem::numComponents == 3, "");
static_assert(0 <= FluidSystem::oilPhaseIdx && FluidSystem::oilPhaseIdx < 3, "");
static_assert(0 <= FluidSystem::gasPhaseIdx && FluidSystem::gasPhaseIdx < 3, "");
static_assert(0 <= FluidSystem::waterPhaseIdx && FluidSystem::waterPhaseIdx < 3, "");
static_assert(0 <= FluidSystem::oilCompIdx && FluidSystem::oilCompIdx < 3, "");
static_assert(0 <= FluidSystem::gasCompIdx && FluidSystem::gasCompIdx < 3, "");
static_assert(0 <= FluidSystem::waterCompIdx && FluidSystem::waterCompIdx < 3, "");
// check the non-parser initialization
std::shared_ptr oilPvt;
std::shared_ptr gasPvt;
std::shared_ptr waterPvt;
unsigned numPvtRegions = 2;
FluidSystem::initBegin(numPvtRegions);
FluidSystem::setEnableDissolvedGas(true);
FluidSystem::setEnableVaporizedOil(true);
FluidSystem::setGasPvt(gasPvt);
FluidSystem::setOilPvt(oilPvt);
FluidSystem::setWaterPvt(waterPvt);
FluidSystem::setReferenceDensities(/*oil=*/600.0,
/*water=*/1000.0,
/*gas=*/1.0,
/*regionIdx=*/0);
FluidSystem::initEnd();
// the molarMass() method has an optional argument for the PVT region
unsigned OPM_UNUSED numRegions = FluidSystem::numRegions();
Scalar OPM_UNUSED Mg = FluidSystem::molarMass(FluidSystem::gasCompIdx,
/*regionIdx=*/0);
bool OPM_UNUSED b1 = FluidSystem::enableDissolvedGas();
bool OPM_UNUSED b2 = FluidSystem::enableVaporizedOil();
Scalar OPM_UNUSED rhoRefOil = FluidSystem::referenceDensity(FluidSystem::oilPhaseIdx,
/*regionIdx=*/0);
dummy = FluidSystem::convertXoGToRs(XoG, /*regionIdx=*/0);
dummy = FluidSystem::convertXgOToRv(XgO, /*regionIdx=*/0);
dummy = FluidSystem::convertXoGToxoG(XoG, /*regionIdx=*/0);
dummy = FluidSystem::convertXgOToxgO(XgO, /*regionIdx=*/0);
dummy = FluidSystem::convertRsToXoG(Rs, /*regionIdx=*/0);
dummy = FluidSystem::convertRvToXgO(Rv, /*regionIdx=*/0);
for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++ phaseIdx) {
dummy = FluidSystem::density(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::saturatedDensity(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::formationVolumeFactor(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::saturatedFormationVolumeFactor(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::viscosity(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::saturatedDissolutionFactor(fluidState, phaseIdx, /*regionIdx=*/0);
dummy = FluidSystem::saturationPressure(fluidState, phaseIdx, /*regionIdx=*/0);
for (unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++ compIdx) {
dummy = FluidSystem::fugacityCoefficient(fluidState, phaseIdx, compIdx, /*regionIdx=*/0);
}
}
// prevent GCC from producing a "variable assigned but unused" warning
dummy = 2.0*dummy;
// the "not considered safe to use directly" API
const OPM_UNUSED OilPvt &oilPvt2 = FluidSystem::oilPvt();
const OPM_UNUSED GasPvt &gasPvt2 = FluidSystem::gasPvt();
const OPM_UNUSED WaterPvt &waterPvt2 = FluidSystem::waterPvt();
}
}
// check the API of all fluid states
template
void testAllFluidStates()
{
typedef Opm::FluidSystems::H2ON2 FluidSystem;
// SimpleModularFluidState
{ Opm::SimpleModularFluidState fs;
checkFluidState(fs); }
{ Opm::SimpleModularFluidState fs;
checkFluidState(fs); }
// CompositionalFluidState
{ Opm::CompositionalFluidState fs;
checkFluidState(fs); }
// NonEquilibriumFluidState
{ Opm::NonEquilibriumFluidState fs;
checkFluidState(fs); }
// ImmiscibleFluidState
{ Opm::ImmiscibleFluidState fs;
checkFluidState(fs); }
typedef Opm::CompositionalFluidState BaseFluidState;
BaseFluidState baseFs;
// TemperatureOverlayFluidState
{ Opm::TemperatureOverlayFluidState fs(baseFs);
checkFluidState(fs); }
// PressureOverlayFluidState
{ Opm::PressureOverlayFluidState fs(baseFs);
checkFluidState(fs); }
// SaturationOverlayFluidState
{ Opm::SaturationOverlayFluidState fs(baseFs);
checkFluidState(fs); }
}
template
void testAllFluidSystems()
{
typedef Opm::LiquidPhase> Liquid;
typedef Opm::GasPhase> Gas;
// black-oil
{
typedef Opm::FluidSystems::BlackOil FluidSystem;
if (false) checkFluidSystem();
struct BlackoilDummyEvalTag;
typedef Opm::LocalAd::Evaluation BlackoilDummyEval;
ensureBlackoilApi();
ensureBlackoilApi();
}
// Brine -- CO2
{ typedef Opm::FluidSystems::BrineCO2 FluidSystem;
checkFluidSystem(); }
// H2O -- N2
{ typedef Opm::FluidSystems::H2ON2 FluidSystem;
checkFluidSystem(); }
{ typedef Opm::FluidSystems::H2ON2 FluidSystem;
checkFluidSystem(); }
// H2O -- N2 -- liquid phase
{ typedef Opm::FluidSystems::H2ON2LiquidPhase FluidSystem;
checkFluidSystem(); }
{ typedef Opm::FluidSystems::H2ON2LiquidPhase FluidSystem;
checkFluidSystem(); }
// H2O -- Air
{ typedef Opm::SimpleH2O H2O;
const bool enableComplexRelations=false;
typedef Opm::FluidSystems::H2OAir FluidSystem;
checkFluidSystem(); }
{ typedef Opm::SimpleH2O H2O;
const bool enableComplexRelations=true;
typedef Opm::FluidSystems::H2OAir FluidSystem;
checkFluidSystem(); }
{ typedef Opm::H2O H2O;
const bool enableComplexRelations=false;
typedef Opm::FluidSystems::H2OAir FluidSystem;
checkFluidSystem(); }
{ typedef Opm::H2O H2O;
const bool enableComplexRelations=true;
typedef Opm::FluidSystems::H2OAir FluidSystem;
checkFluidSystem(); }
// H2O -- Air -- Mesitylene
{ typedef Opm::FluidSystems::H2OAirMesitylene FluidSystem;
checkFluidSystem(); }
// H2O -- Air -- Xylene
{ typedef Opm::FluidSystems::H2OAirXylene FluidSystem;
checkFluidSystem(); }
// 2p-immiscible
{ typedef Opm::FluidSystems::TwoPhaseImmiscible FluidSystem;
checkFluidSystem(); }
{ typedef Opm::FluidSystems::TwoPhaseImmiscible FluidSystem;
checkFluidSystem(); }
{ typedef Opm::FluidSystems::TwoPhaseImmiscible FluidSystem;
checkFluidSystem(); }
// 1p
{ typedef Opm::FluidSystems::SinglePhase FluidSystem;
checkFluidSystem(); }
{ typedef Opm::FluidSystems::SinglePhase FluidSystem;
checkFluidSystem(); }
}
class TestAdTag;
template
inline void testAll()
{
typedef Opm::LocalAd::Evaluation Evaluation;
// ensure that all fluid states are API-compliant
testAllFluidStates();
testAllFluidStates();
// ensure that all fluid systems are API-compliant: Each fluid system must be usable
// for both, scalars and function evaluations. The fluid systems for function
// evaluations must also be usable for scalars.
testAllFluidSystems();
testAllFluidSystems();
testAllFluidSystems();
}
int main(int argc, char **argv)
{
Dune::MPIHelper::instance(argc, argv);
testAll< double > ();
testAll< float > ();
return 0;
}