opm-simulators/flow/flow_ebos_oilwater.cpp

100 lines
3.6 KiB
C++
Raw Normal View History

/*
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 3 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 <http://www.gnu.org/licenses/>.
*/
#include "config.h"
make the build of flow fully parallelizable so far, the actual specializations of the simulator were compiled into the `libopmsimulators` library and the build of the glue code (`flow.cpp`) thus needed to be deferred until the library was fully built. Since the compilation of the glue code requires a full property hierarchy for handling command line parameters, this arrangement significantly increases the build time for systems with a sufficient number of parallel build processes. ("sufficient" here means 8 or more threads, i.e., a quadcore system with hyperthreading is sufficient provided that it has enough main memory.) the new approach is not to include these objects in `libopmsimulators`, but to directly deal with them in the `flow` binary. this allows all of them and the glue code to be compiled in parallel. compilation time on my machine before this change: ``` > touch ../opm/autodiff/BlackoilModelEbos.hpp; time make -j32 flow 2> /dev/null Scanning dependencies of target opmsimulators [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_gasoil.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_oilwater.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_blackoil.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_solvent.cpp.o [ 4%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_polymer.cpp.o [ 6%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_energy.cpp.o [ 6%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_oilwater_polymer.cpp.o [ 6%] Linking CXX static library lib/libopmsimulators.a [ 97%] Built target opmsimulators Scanning dependencies of target flow [100%] Building CXX object CMakeFiles/flow.dir/examples/flow.cpp.o [100%] Linking CXX executable bin/flow [100%] Built target flow real 1m45.692s user 8m47.195s sys 0m11.533s ``` after: ``` > touch ../opm/autodiff/BlackoilModelEbos.hpp; time make -j32 flow 2> /dev/null [ 91%] Built target opmsimulators Scanning dependencies of target flow [ 93%] Building CXX object CMakeFiles/flow.dir/flow/flow.cpp.o [ 95%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_gasoil.cpp.o [ 97%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_oilwater_polymer.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_polymer.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_oilwater.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_solvent.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_blackoil.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_energy.cpp.o [100%] Linking CXX executable bin/flow [100%] Built target flow real 1m21.597s user 8m49.476s sys 0m10.973s ``` (this corresponds to a ~20% reduction of the time spend on waiting for the compiler.)
2018-09-20 03:58:27 -05:00
#include <flow/flow_ebos_oilwater.hpp>
#include <opm/material/common/ResetLocale.hpp>
#include <opm/models/blackoil/blackoiltwophaseindices.hh>
2018-02-09 06:42:16 -06:00
#include <opm/grid/CpGrid.hpp>
#include <opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp>
#include <opm/simulators/flow/Main.hpp>
#include <opm/models/blackoil/blackoillocalresidualtpfa.hh>
#include <opm/models/discretization/common/tpfalinearizer.hh>
namespace Opm {
namespace Properties {
namespace TTag {
struct EclFlowOilWaterProblem {
using InheritsFrom = std::tuple<EclFlowProblem>;
};
}
template<class TypeTag>
struct Linearizer<TypeTag, TTag::EclFlowOilWaterProblem> { using type = TpfaLinearizer<TypeTag>; };
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::EclFlowOilWaterProblem> { using type = BlackOilLocalResidualTPFA<TypeTag>; };
template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::EclFlowOilWaterProblem> { static constexpr bool value = false; };
//! The indices required by the model
2020-08-27 04:38:38 -05:00
template<class TypeTag>
struct Indices<TypeTag, TTag::EclFlowOilWaterProblem>
{
private:
// it is unfortunately not possible to simply use 'TypeTag' here because this leads
// to cyclic definitions of some properties. if this happens the compiler error
// messages unfortunately are *really* confusing and not really helpful.
2020-08-21 06:59:53 -05:00
using BaseTypeTag = TTag::EclFlowProblem;
using FluidSystem = GetPropType<BaseTypeTag, Properties::FluidSystem>;
public:
typedef BlackOilTwoPhaseIndices<getPropValue<TypeTag, Properties::EnableSolvent>(),
getPropValue<TypeTag, Properties::EnableExtbo>(),
getPropValue<TypeTag, Properties::EnablePolymer>(),
getPropValue<TypeTag, Properties::EnableEnergy>(),
getPropValue<TypeTag, Properties::EnableFoam>(),
getPropValue<TypeTag, Properties::EnableBrine>(),
/*PVOffset=*/0,
/*disabledCompIdx=*/FluidSystem::gasCompIdx,
getPropValue<TypeTag, Properties::EnableMICP>()> type;
};
}}
namespace Opm {
// ----------------- Main program -----------------
int flowEbosOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles)
{
// we always want to use the default locale, and thus spare us the trouble
// with incorrect locale settings.
resetLocale();
FlowMainEbos<Properties::TTag::EclFlowOilWaterProblem>
mainfunc {argc, argv, outputCout, outputFiles};
return mainfunc.execute();
}
int flowEbosOilWaterMainStandalone(int argc, char** argv)
{
using TypeTag = Properties::TTag::EclFlowOilWaterProblem;
auto mainObject = std::make_unique<Opm::Main>(argc, argv);
auto ret = mainObject->runStatic<TypeTag>();
// Destruct mainObject as the destructor calls MPI_Finalize!
mainObject.reset();
return ret;
}
}