From 993f1133c84939449aa123fcd1c94a5cff40d67e Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 9 Aug 2019 11:04:45 +0200 Subject: [PATCH] enable the foam extension for ebos/mebos --- CMakeLists.txt | 15 ++++------ ebos/ebos_foam.cc | 63 ++++++++++++++++++++++++++++++++++++++++ ebos/ebos_foam.hh | 44 ++++++++++++++++++++++++++++ ebos/ebos_foam_main.cc | 37 +++++++++++++++++++++++ ebos/mebos_main.cc | 66 ++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 214 insertions(+), 11 deletions(-) create mode 100644 ebos/ebos_foam.cc create mode 100644 ebos/ebos_foam.hh create mode 100644 ebos/ebos_foam_main.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 998c4c8ed..6a1c96cce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,9 +185,11 @@ endif() # &black-&oil &simulator) get_target_property(ecl_INCLUDE_DIRS ecl INTERFACE_INCLUDE_DIRECTORIES) -foreach(OBJ blackoil solvent polymer gasoil oilwater thermal) +set(MEBOS_TARGETS "") +foreach(OBJ blackoil solvent polymer foam gasoil oilwater thermal) add_library(ebos_lib${OBJ} OBJECT EXCLUDE_FROM_ALL ebos/ebos_${OBJ}.cc) target_include_directories(ebos_lib${OBJ} PRIVATE ${ecl_INCLUDE_DIRS}) + list(APPEND MEBOS_TARGETS $) endforeach() opm_add_test(ebos @@ -209,7 +211,7 @@ else() set(EBOS_EXTENSIONS_DEFAULT_ENABLE_IF "TRUE") endif() -foreach(OBJ solvent polymer gasoil oilwater thermal) +foreach(OBJ solvent polymer foam gasoil oilwater thermal) opm_add_test(ebos_${OBJ} ONLY_COMPILE DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF} @@ -222,12 +224,7 @@ opm_add_test(mebos ONLY_COMPILE DEFAULT_ENABLE_IF ${EBOS_EXTENSIONS_DEFAULT_ENABLE_IF} SOURCES ebos/mebos_main.cc - $ - $ - $ - $ - $ - $ + ${MEBOS_TARGETS} EXE_NAME mebos LIBRARIES opmsimulators) @@ -254,7 +251,7 @@ opm_add_test(ebos_plain LIBRARIES opmsimulators) if (BUILD_EBOS_EXTENSIONS) - foreach(TGT ebos_solvent ebos_polymer ebos_gasoil ebos_oilwater ebos_thermal mebos) + foreach(TGT ebos_solvent ebos_polymer ebos_foam ebos_gasoil ebos_oilwater ebos_thermal mebos) install(TARGETS ${TGT} DESTINATION bin) opm_add_bash_completion(${TGT}) endforeach() diff --git a/ebos/ebos_foam.cc b/ebos/ebos_foam.cc new file mode 100644 index 000000000..1e1a90322 --- /dev/null +++ b/ebos/ebos_foam.cc @@ -0,0 +1,63 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + 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 . + + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + * + * \brief A general-purpose simulator for ECL decks using the black-oil model. + */ +#include "config.h" + +#include "ebos.hh" + +BEGIN_PROPERTIES + +NEW_TYPE_TAG(EbosFoamTypeTag, INHERITS_FROM(EbosTypeTag)); + +// enable the foam extension of the black oil model +SET_BOOL_PROP(EbosFoamTypeTag, EnableFoam, true); + +END_PROPERTIES + +namespace Ewoms { + +void ebosFoamSetDeck(Opm::Deck* deck, + Opm::ParseContext* parseContext, + Opm::ErrorGuard* errorGuard, + double externalSetupTime) +{ + typedef TTAG(EbosFoamTypeTag) ProblemTypeTag; + typedef GET_PROP_TYPE(ProblemTypeTag, Vanguard) Vanguard; + + Vanguard::setExternalSetupTime(externalSetupTime); + Vanguard::setExternalParseContext(parseContext); + Vanguard::setExternalErrorGuard(errorGuard); + Vanguard::setExternalDeck(deck); +} + +int ebosFoamMain(int argc, char **argv) +{ + typedef TTAG(EbosFoamTypeTag) ProblemTypeTag; + return Ewoms::start(argc, argv); +} + +} diff --git a/ebos/ebos_foam.hh b/ebos/ebos_foam.hh new file mode 100644 index 000000000..78eda05be --- /dev/null +++ b/ebos/ebos_foam.hh @@ -0,0 +1,44 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + 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 . + + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + * + * \brief The function prototypes required to start the foam variant of ebos + */ +#ifndef EBOS_FOAM_HH +#define EBOS_FOAM_HH + +#include +#include +#include + +namespace Ewoms { +void ebosFoamSetDeck(Opm::Deck* deck, + Opm::ParseContext* parseContext, + Opm::ErrorGuard* errorGuard, + double externalSetupTime); + +int ebosFoamMain(int argc, char** argv); +} + +#endif diff --git a/ebos/ebos_foam_main.cc b/ebos/ebos_foam_main.cc new file mode 100644 index 000000000..c9a53853a --- /dev/null +++ b/ebos/ebos_foam_main.cc @@ -0,0 +1,37 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + 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 . + + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + * + * \brief The main function for the stand alone foam variant of ebos. + * + * This only calls the ebosFoamMain() function. + */ +#include "config.h" + +#include "ebos_foam.hh" + +int main(int argc, char** argv) +{ + return Ewoms::ebosFoamMain(argc, argv); +} diff --git a/ebos/mebos_main.cc b/ebos/mebos_main.cc index cf8fcb21f..8615c0455 100644 --- a/ebos/mebos_main.cc +++ b/ebos/mebos_main.cc @@ -38,6 +38,7 @@ #include "ebos_thermal.hh" #include "ebos_solvent.hh" #include "ebos_polymer.hh" +#include "ebos_foam.hh" #include @@ -84,6 +85,7 @@ int main(int argc, char **argv) bool oilActive = deck->hasKeyword("OIL"); bool solventActive = deck->hasKeyword("SOLVENT"); bool polymerActive = deck->hasKeyword("POLYMER"); + bool foamActive = deck->hasKeyword("FOAM"); bool thermalActive = deck->hasKeyword("THERMAL") || deck->hasKeyword("TEMP"); std::stringstream notSupportedErrorStream; @@ -93,6 +95,7 @@ int main(int argc, char **argv) << " oil: " << oilActive << "\n" << " solvent: " << solventActive << "\n" << " polymer: " << polymerActive << "\n" + << " foam: " << foamActive << "\n" << " thermal/temperature: " << thermalActive << "\n"; int numBlackOilPhases = (waterActive?1:0) + (gasActive?1:0) + (oilActive?1:0); @@ -123,6 +126,13 @@ int main(int argc, char **argv) std::abort(); } + if (foamActive) { + notSupportedErrorStream << "\n" + << "combining twophase and foam is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + if (thermalActive) { notSupportedErrorStream << "\n" << "combining twophase and energy conservation is not supported by the multiplexed simulator\n"; @@ -156,6 +166,37 @@ int main(int argc, char **argv) std::abort(); } } + else if (foamActive) { + if (solventActive) { + notSupportedErrorStream << "\n" + << "combining foam and solvent is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + + if (polymerActive) { + notSupportedErrorStream << "\n" + << "combining foam and polymer is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + + if (thermalActive) { + notSupportedErrorStream << "\n" + << "combining foam and and energy conservation is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + + // run ebos_foam + if (myRank == 0) + std::cout << "Using foam mode" << std::endl; + Ewoms::ebosFoamSetDeck(deck.get(), + parseContext.get(), + errorGuard.get(), + externalSetupTimer.elapsed()); + return Ewoms::ebosFoamMain(argc, argv); + } else if (polymerActive) { if (solventActive) { notSupportedErrorStream << "\n" @@ -164,6 +205,13 @@ int main(int argc, char **argv) std::abort(); } + if (foamActive) { + notSupportedErrorStream << "\n" + << "combining polymer and foam is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + if (thermalActive) { notSupportedErrorStream << "\n" << "combining polymer and and energy conservation is not supported by the multiplexed simulator\n"; @@ -183,14 +231,21 @@ int main(int argc, char **argv) else if (solventActive) { if (polymerActive) { notSupportedErrorStream << "\n" - << "combining polymer and solvent is not supported\n"; + << "combining solvent and polymer is not supported\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + + if (foamActive) { + notSupportedErrorStream << "\n" + << "combining solvent and foam is not supported\n"; std::cerr << notSupportedErrorStream.str() << std::endl; std::abort(); } if (thermalActive) { notSupportedErrorStream << "\n" - << "combining polymer and and energy conservation is not supported\n"; + << "combining solvent and and energy conservation is not supported\n"; std::cerr << notSupportedErrorStream.str() << std::endl; std::abort(); } @@ -219,6 +274,13 @@ int main(int argc, char **argv) std::abort(); } + if (foamActive) { + notSupportedErrorStream << "\n" + << "combining thermal and foam is not supported by the multiplexed simulator\n"; + std::cerr << notSupportedErrorStream.str() << std::endl; + std::abort(); + } + // run ebos_thermal if (myRank == 0) std::cout << "Using thermal mode" << std::endl;