23 #ifndef OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
24 #define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
27 #include <sys/utsname.h>
30 #include <opm/simulators/ParallelFileMerger.hpp>
31 #include <opm/simulators/ensureDirectoryExists.hpp>
33 #include <opm/autodiff/BlackoilModelEbos.hpp>
34 #include <opm/autodiff/NewtonIterationBlackoilSimple.hpp>
35 #include <opm/autodiff/NewtonIterationBlackoilCPR.hpp>
36 #include <opm/autodiff/NewtonIterationBlackoilInterleaved.hpp>
37 #include <opm/autodiff/MissingFeatures.hpp>
38 #include <opm/autodiff/moduleVersion.hpp>
39 #include <opm/autodiff/ExtractParallelGridInformationToISTL.hpp>
40 #include <opm/autodiff/RedistributeDataHandles.hpp>
41 #include <opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp>
43 #include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
45 #include <opm/common/OpmLog/OpmLog.hpp>
46 #include <opm/common/OpmLog/EclipsePRTLog.hpp>
47 #include <opm/common/OpmLog/LogUtil.hpp>
49 #include <opm/parser/eclipse/Deck/Deck.hpp>
50 #include <opm/parser/eclipse/Parser/Parser.hpp>
51 #include <opm/parser/eclipse/Parser/ParseContext.hpp>
52 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
53 #include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
54 #include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
55 #include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
58 #include <dune/fem/misc/mpimanager.hh>
60 #include <dune/common/parallel/mpihelper.hh>
66 template <
class TypeTag>
79 typedef typename GET_PROP(TypeTag, MaterialLaw)::EclMaterialLawManager MaterialLawManager;
80 typedef typename GET_PROP_TYPE(TypeTag,
Simulator) EbosSimulator;
81 typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
82 typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
83 typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
84 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
85 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
88 typedef typename Simulator::ReservoirState ReservoirState;
100 printStartupMessage();
101 const bool ok = setupParameters(argc, argv);
106 setupEbosSimulator();
119 auto ret = runSimulator();
121 mergeParallelLogFiles();
125 catch (
const std::exception &e) {
126 std::ostringstream message;
127 message <<
"Program threw an exception: " << e.what();
133 if (OpmLog::hasBackend(
"STREAMLOG")) {
134 OpmLog::error(message.str());
137 std::cout << message.str() <<
"\n";
146 void setupParallelism()
151 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank_);
153 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
156 const int mpi_size = 1;
158 output_cout_ = ( mpi_rank_ == 0 );
159 must_distribute_ = ( mpi_size > 1 );
163 if (!getenv(
"OMP_NUM_THREADS")) {
166 int num_cores = omp_get_num_procs();
167 int num_threads = std::min(4, num_cores);
168 omp_set_num_threads(num_threads);
171 if (omp_get_thread_num() == 0) {
173 const int num_omp_threads = omp_get_num_threads();
175 std::cout <<
"OpenMP using " << num_omp_threads <<
" threads." << std::endl;
177 std::cout <<
"OpenMP using " << num_omp_threads <<
" threads on MPI rank " << mpi_rank_ <<
"." << std::endl;
184 void printStartupMessage()
188 const int lineLen = 70;
190 const std::string banner =
"This is flow "+version;
191 const int bannerPreLen = (lineLen - 2 - banner.size())/2;
192 const int bannerPostLen = bannerPreLen + (lineLen - 2 - banner.size())%2;
193 std::cout <<
"**********************************************************************\n";
194 std::cout <<
"* *\n";
195 std::cout <<
"*" << std::string(bannerPreLen,
' ') << banner << std::string(bannerPostLen,
' ') <<
"*\n";
196 std::cout <<
"* *\n";
197 std::cout <<
"* Flow is a simulator for fully implicit three-phase black-oil flow, *\n";
198 std::cout <<
"* including solvent and polymer capabilities. *\n";
199 std::cout <<
"* For more information, see http://opm-project.org *\n";
200 std::cout <<
"* *\n";
201 std::cout <<
"**********************************************************************\n\n";
210 bool setupParameters(
int argc,
char** argv)
212 param_ = ParameterGroup(argc, argv,
false, output_cout_);
215 if (!param_.unhandledArguments().empty()) {
216 if (param_.unhandledArguments().size() != 1) {
217 std::cerr <<
"You can only specify a single input deck on the command line.\n";
220 const auto casename = this->simulationCaseName( param_.unhandledArguments()[ 0 ] );
221 param_.insertParameter(
"deck_filename", casename.string() );
226 if (!param_.has(
"deck_filename")) {
227 std::cerr <<
"This program must be run with an input deck.\n"
228 "Specify the deck filename either\n"
229 " a) as a command line argument by itself\n"
230 " b) as a command line parameter with the syntax deck_filename=<path to your deck>, or\n"
231 " c) as a parameter in a parameter file (.param or .xml) passed to the program.\n";
244 const std::string output = param_.getDefault(
"output", std::string(
"all"));
245 static std::map<std::string, FileOutputValue> string2OutputEnum =
246 { {
"none", OUTPUT_NONE },
247 {
"false", OUTPUT_LOG_ONLY },
248 {
"log", OUTPUT_LOG_ONLY },
249 {
"all" , OUTPUT_ALL },
250 {
"true" , OUTPUT_ALL }};
251 auto converted = string2OutputEnum.find(output);
252 if ( converted != string2OutputEnum.end() )
254 output_ = string2OutputEnum[output];
258 std::cerr <<
"Value " << output <<
259 " passed to option output was invalid. Using \"all\" instead."
263 output_to_files_ = output_cout_ && output_ > OUTPUT_NONE;
266 auto& ioConfig = eclState().getIOConfig();
268 const std::string default_output_dir = ioConfig.getOutputDir();
269 output_dir_ = param_.getDefault(
"output_dir", default_output_dir);
271 ioConfig.setOutputDir(output_dir_);
274 if (output_to_files_) {
278 param_.writeParam(output_dir_ +
"/simulation.param");
285 std::string deck_filename = param_.get<std::string>(
"deck_filename");
287 using boost::filesystem::path;
288 path fpath(deck_filename);
289 std::string baseName;
290 std::ostringstream debugFileStream;
291 std::ostringstream logFileStream;
293 if (boost::to_upper_copy(path(fpath.extension()).
string()) ==
".DATA") {
294 baseName = path(fpath.stem()).
string();
296 baseName = path(fpath.filename()).
string();
299 logFileStream << output_dir_ <<
"/" << baseName;
300 debugFileStream << output_dir_ <<
"/" <<
"." << baseName;
302 if ( must_distribute_ && mpi_rank_ != 0 )
306 debugFileStream <<
"."<< mpi_rank_;
308 logFileStream <<
"." << mpi_rank_;
310 logFileStream <<
".PRT";
311 debugFileStream <<
".DEBUG";
313 logFile_ = logFileStream.str();
315 if( output_ > OUTPUT_NONE)
317 std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::NoDebugMessageTypes,
false, output_cout_);
318 OpmLog::addBackend(
"ECLIPSEPRTLOG" , prtLog );
319 prtLog->setMessageLimiter(std::make_shared<MessageLimiter>());
320 prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(
false));
323 if( output_ >= OUTPUT_LOG_ONLY && !param_.getDefault(
"no_debug_log",
false) )
325 std::string debugFile = debugFileStream.str();
326 std::shared_ptr<StreamLog> debugLog = std::make_shared<EclipsePRTLog>(debugFile, Log::DefaultMessageTypes,
false, output_cout_);
327 OpmLog::addBackend(
"DEBUGLOG" , debugLog);
330 std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::StdoutMessageTypes);
331 OpmLog::addBackend(
"STREAMLOG", streamLog);
332 const auto& msgLimits = eclState().getSchedule().getMessageLimits();
333 const std::map<int64_t, int> limits = {{Log::MessageType::Note, msgLimits.getCommentPrintLimit(0)},
334 {Log::MessageType::Info, msgLimits.getMessagePrintLimit(0)},
335 {Log::MessageType::Warning, msgLimits.getWarningPrintLimit(0)},
336 {Log::MessageType::Error, msgLimits.getErrorPrintLimit(0)},
337 {Log::MessageType::Problem, msgLimits.getProblemPrintLimit(0)},
338 {Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}};
339 streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10, limits));
340 streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(
true));
345 OpmLog::debug(
"\n--------------- Reading parameters ---------------\n");
349 void printPRTHeader()
352 if ( output_cout_ ) {
354 const double megabyte = 1024 * 1024;
355 unsigned num_cpu = std::thread::hardware_concurrency();
357 const char* user = getlogin();
358 time_t now = std::time(0);
361 tstruct = *localtime(&now);
362 strftime(tmstr,
sizeof(tmstr),
"%d-%m-%Y at %X", &tstruct);
363 const double mem_size = getTotalSystemMemory() / megabyte;
364 std::ostringstream ss;
365 ss <<
"\n\n\n ######## # ###### # #\n";
366 ss <<
" # # # # # # \n";
367 ss <<
" ##### # # # # # # \n";
368 ss <<
" # # # # # # # # \n";
369 ss <<
" # ####### ###### # # \n\n";
370 ss <<
"Flow is a simulator for fully implicit three-phase black-oil flow,";
371 ss <<
" and is part of OPM.\nFor more information visit: http://opm-project.org \n\n";
372 ss <<
"Flow Version = " + version +
"\n";
373 if (uname(&arch) == 0) {
374 ss <<
"System = " << arch.nodename <<
" (Number of cores: " << num_cpu;
375 ss <<
", RAM: " << std::fixed << std::setprecision (2) << mem_size <<
" MB) \n";
376 ss <<
"Architecture = " << arch.sysname <<
" " << arch.machine <<
" (Release: " << arch.release;
377 ss <<
", Version: " << arch.version <<
" )\n";
380 ss <<
"User = " << user << std::endl;
382 ss <<
"Simulation started on " << tmstr <<
" hrs\n";
383 OpmLog::note(ss.str());
387 void mergeParallelLogFiles()
390 OpmLog::removeAllBackends();
392 if( mpi_rank_ != 0 || !must_distribute_ || !output_to_files_ )
397 namespace fs = boost::filesystem;
398 fs::path output_path(
".");
399 if ( param_.has(
"output_dir") )
401 output_path = fs::path(output_dir_);
404 fs::path deck_filename(param_.get<std::string>(
"deck_filename"));
406 std::for_each(fs::directory_iterator(output_path),
407 fs::directory_iterator(),
408 detail::ParallelFileMerger(output_path, deck_filename.stem().string()));
411 void setupEbosSimulator()
413 std::string progName(
"flow_ebos");
414 std::string deckFile(
"--ecl-deck-file-name=");
415 deckFile += param_.get<std::string>(
"deck_filename");
417 ptr[ 0 ] =
const_cast< char *
> (progName.c_str());
418 ptr[ 1 ] =
const_cast< char *
> (deckFile.c_str());
419 EbosSimulator::registerParameters();
420 Ewoms::setupParameters_< TypeTag > ( 2, ptr );
421 ebosSimulator_.reset(
new EbosSimulator(
false));
422 ebosSimulator_->model().applyInitialSolution();
425 globalGrid_.reset(
new Grid(grid()));
426 globalGrid_->switchToGlobalView();
430 MissingFeatures::checkKeywords(deck());
434 if (param_.has(
"nosim")) {
435 const bool nosim = param_.get<
bool>(
"nosim");
436 auto& ioConfig = eclState().getIOConfig();
437 ioConfig.overrideNOSIM( nosim );
440 catch (
const std::invalid_argument& e) {
441 std::cerr <<
"Failed to create valid EclipseState object. See logfile: " << logFile_ << std::endl;
442 std::cerr <<
"Exception caught: " << e.what() << std::endl;
447 if (param_.has(
"output_interval")) {
448 const int output_interval = param_.get<
int>(
"output_interval");
449 eclState().getRestartConfig().overrideRestartWriteInterval(
size_t( output_interval ) );
453 const Deck& deck()
const
454 {
return ebosSimulator_->gridManager().deck(); }
457 {
return ebosSimulator_->gridManager().deck(); }
459 const EclipseState& eclState()
const
460 {
return ebosSimulator_->gridManager().eclState(); }
462 EclipseState& eclState()
463 {
return ebosSimulator_->gridManager().eclState(); }
471 const PhaseUsage pu = Opm::phaseUsageFromDeck(deck());
472 const Grid& grid = this->grid();
475 BlackoilPropertiesFromDeck props(deck(),
477 materialLawManager(),
479 grid.globalCell().data(),
480 grid.logicalCartesianSize().data(),
485 if (param_.has(
"init_saturation")) {
486 state_.reset(
new ReservoirState(grid.size(0),
490 initStateBasic(grid.size(0),
491 grid.globalCell().data(),
492 grid.logicalCartesianSize().data(),
494 Opm::UgGridHelpers::faceCells(grid),
495 Opm::UgGridHelpers::beginFaceCentroids(grid),
496 Opm::UgGridHelpers::beginCellCentroids(grid),
498 props, param_, gravity(), *state_);
500 initBlackoilSurfvol(Opm::UgGridHelpers::numCells(grid), props, *state_);
502 enum { Oil = BlackoilPhases::Liquid, Gas = BlackoilPhases::Vapour };
503 if (pu.phase_used[Oil] && pu.phase_used[Gas]) {
504 const int numPhases = props.numPhases();
505 const int numCells = Opm::UgGridHelpers::numCells(grid);
508 auto& gor = state_->getCellData( BlackoilState::GASOILRATIO );
509 const auto& surface_vol = state_->getCellData( BlackoilState::SURFACEVOL );
510 for (
int c = 0; c < numCells; ++c) {
512 gor[c] = surface_vol[ c * numPhases + pu.phase_pos[Gas]] / surface_vol[ c * numPhases + pu.phase_pos[Oil]];
515 }
else if (deck().hasKeyword(
"EQUIL")) {
517 state_.reset(
new ReservoirState( Opm::UgGridHelpers::numCells(grid),
518 Opm::UgGridHelpers::numFaces(grid),
521 initStateEquil(grid, props, deck(), eclState(), gravity(), *state_);
524 state_.reset(
new ReservoirState( Opm::UgGridHelpers::numCells(grid),
525 Opm::UgGridHelpers::numFaces(grid),
527 initBlackoilStateFromDeck(Opm::UgGridHelpers::numCells(grid),
528 Opm::UgGridHelpers::globalCell(grid),
529 Opm::UgGridHelpers::numFaces(grid),
530 Opm::UgGridHelpers::faceCells(grid),
531 Opm::UgGridHelpers::beginFaceCentroids(grid),
532 Opm::UgGridHelpers::beginCellCentroids(grid),
533 Opm::UgGridHelpers::dimensions(grid),
534 props, deck(), gravity(), *state_);
537 initHydroCarbonState(*state_, pu, Opm::UgGridHelpers::numCells(grid), deck().hasKeyword(
"DISGAS"), deck().hasKeyword(
"VAPOIL"));
540 if (GET_PROP_VALUE(TypeTag, EnablePolymer)) {
541 auto& cpolymer = state_->getCellData( state_->POLYMER );
542 const int numCells = Opm::UgGridHelpers::numCells(grid);
543 for (
int c = 0; c < numCells; ++c) {
544 cpolymer[c] = ebosProblem().polymerConcentration(c);
548 if (GET_PROP_VALUE(TypeTag, EnableSolvent)) {
549 auto& solvent = state_->getCellData( state_->SSOL );
550 auto& sat = state_->saturation();
551 const int np = props.numPhases();
552 const int numCells = Opm::UgGridHelpers::numCells(grid);
553 for (
int c = 0; c < numCells; ++c) {
554 solvent[c] = ebosProblem().solventSaturation(c);
555 sat[c * np + pu.phase_pos[Water]];
564 void extractMessages()
571 auto extractMessage = [
this](
const Message& msg) {
572 auto log_type = this->convertMessageType(msg.mtype);
573 const auto& location = msg.location;
575 OpmLog::addMessage(log_type, Log::fileMessage(location.filename, location.lineno, msg.message));
577 OpmLog::addMessage(log_type, msg.message);
582 for(
const auto& msg : deck().getMessageContainer()) {
587 for (
const auto& msg : eclState().getMessageContainer()) {
595 void runDiagnostics()
603 RelpermDiagnostics diagnostic;
604 diagnostic.diagnosis(eclState(), deck(), this->grid());
609 bool output = ( output_ > OUTPUT_LOG_ONLY );
610 bool output_ecl = param_.getDefault(
"output_ecl",
true);
611 if( output && output_ecl && grid().comm().rank() == 0 )
613 exportNncStructure_();
615 const EclipseGrid& inputGrid = eclState().getInputGrid();
616 eclIO_.reset(
new EclipseIO(eclState(), UgGridHelpers::createEclipseGrid( this->globalGrid() , inputGrid )));
617 eclIO_->writeInitial(computeLegacySimProps_(), nnc_);
624 void setupOutputWriter()
629 output_writer_.reset(
new OutputWriter(grid(),
633 Opm::phaseUsageFromDeck(deck())) );
640 const auto& schedule = eclState().getSchedule();
641 const auto& timeMap = schedule.getTimeMap();
642 auto& ioConfig = eclState().getIOConfig();
643 SimulatorTimer simtimer;
646 const auto& initConfig = eclState().getInitConfig();
647 simtimer.init(timeMap, (
size_t)initConfig.getRestartStep());
649 if (!ioConfig.initOnly()) {
652 msg =
"\n\n================ Starting main simulation loop ===============\n";
656 SimulatorReport successReport = simulator_->run(simtimer, *state_);
657 SimulatorReport failureReport = simulator_->failureReport();
660 std::ostringstream ss;
661 ss <<
"\n\n================ End of simulation ===============\n\n";
662 successReport.reportFullyImplicit(ss, &failureReport);
663 OpmLog::info(ss.str());
664 if (param_.anyUnused()) {
667 std::cout <<
"-------------------- Unused parameters: --------------------\n";
668 param_.displayUsage();
669 std::cout <<
"----------------------------------------------------------------" << std::endl;
673 if (output_to_files_) {
674 std::string filename = output_dir_ +
"/walltime.txt";
675 std::fstream tot_os(filename.c_str(), std::fstream::trunc | std::fstream::out);
676 successReport.reportParam(tot_os);
680 std::cout <<
"\n\n================ Simulation turned off ===============\n" << std::flush;
690 void setupLinearSolver()
692 typedef typename BlackoilModelEbos<TypeTag> :: ISTLSolverType ISTLSolverType;
694 extractParallelGridInformationToISTL(grid(), parallel_information_);
695 fis_solver_.reset(
new ISTLSolverType( param_, parallel_information_ ) );
705 simulator_.reset(
new Simulator(*ebosSimulator_,
708 FluidSystem::enableDissolvedGas(),
709 FluidSystem::enableVaporizedOil(),
712 defunctWellNames()));
716 boost::filesystem::path simulationCaseName(
const std::string& casename ) {
717 namespace fs = boost::filesystem;
719 const auto exists = [](
const fs::path& f ) ->
bool {
720 if( !fs::exists( f ) )
return false;
722 if( fs::is_regular_file( f ) )
return true;
724 return fs::is_symlink( f )
725 && fs::is_regular_file( fs::read_symlink( f ) );
728 auto simcase = fs::path( casename );
730 if( exists( simcase ) ) {
734 for(
const auto& ext : { std::string(
"data"), std::string(
"DATA") } ) {
735 if( exists( simcase.replace_extension( ext ) ) ) {
740 throw std::invalid_argument(
"Cannot find input case " + casename );
743 unsigned long long getTotalSystemMemory()
745 long pages = sysconf(_SC_PHYS_PAGES);
746 long page_size = sysconf(_SC_PAGE_SIZE);
747 return pages * page_size;
750 int64_t convertMessageType(
const Message::type& mtype)
753 case Message::type::Debug:
754 return Log::MessageType::Debug;
755 case Message::type::Info:
756 return Log::MessageType::Info;
757 case Message::type::Warning:
758 return Log::MessageType::Warning;
759 case Message::type::Error:
760 return Log::MessageType::Error;
761 case Message::type::Problem:
762 return Log::MessageType::Problem;
763 case Message::type::Bug:
764 return Log::MessageType::Bug;
765 case Message::type::Note:
766 return Log::MessageType::Note;
768 throw std::logic_error(
"Invalid messages type!\n");
772 {
return ebosSimulator_->gridManager().grid(); }
774 const Grid& globalGrid()
775 {
return *globalGrid_; }
777 Problem& ebosProblem()
778 {
return ebosSimulator_->problem(); }
780 const Problem& ebosProblem()
const
781 {
return ebosSimulator_->problem(); }
783 std::shared_ptr<MaterialLawManager> materialLawManager()
784 {
return ebosProblem().materialLawManager(); }
786 Scalar gravity()
const
787 {
return ebosProblem().gravity()[2]; }
789 std::unordered_set<std::string> defunctWellNames()
const
790 {
return ebosSimulator_->gridManager().defunctWellNames(); }
792 data::Solution computeLegacySimProps_()
794 const int* dims = UgGridHelpers::cartDims(grid());
795 const int globalSize = dims[0]*dims[1]*dims[2];
797 data::CellData tranx = {UnitSystem::measure::transmissibility, std::vector<double>( globalSize ), data::TargetType::INIT};
798 data::CellData trany = {UnitSystem::measure::transmissibility, std::vector<double>( globalSize ), data::TargetType::INIT};
799 data::CellData tranz = {UnitSystem::measure::transmissibility, std::vector<double>( globalSize ), data::TargetType::INIT};
801 for (
size_t i = 0; i < tranx.data.size(); ++i) {
807 const Grid& globalGrid = this->globalGrid();
808 const auto& globalGridView = globalGrid.leafGridView();
809 typedef typename Grid::LeafGridView GridView;
810 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
811 ElementMapper globalElemMapper(globalGridView);
812 const auto& cartesianCellIdx = globalGrid.globalCell();
814 const auto* globalTrans = &(ebosSimulator_->gridManager().globalTransmissibility());
815 if (grid().comm().size() < 2) {
822 globalTrans = &ebosSimulator_->problem().eclTransmissibilities();
825 auto elemIt = globalGridView.template begin<0>();
826 const auto& elemEndIt = globalGridView.template end<0>();
827 for (; elemIt != elemEndIt; ++ elemIt) {
828 const auto& elem = *elemIt;
830 auto isIt = globalGridView.ibegin(elem);
831 const auto& isEndIt = globalGridView.iend(elem);
832 for (; isIt != isEndIt; ++ isIt) {
833 const auto& is = *isIt;
840 unsigned c1 = globalElemMapper.index(is.inside());
841 unsigned c2 = globalElemMapper.index(is.outside());
849 int gc1 = std::min(cartesianCellIdx[c1], cartesianCellIdx[c2]);
850 int gc2 = std::max(cartesianCellIdx[c1], cartesianCellIdx[c2]);
851 if (gc2 - gc1 == 1) {
852 tranx.data[gc1] = globalTrans->transmissibility(c1, c2);
855 if (gc2 - gc1 == dims[0]) {
856 trany.data[gc1] = globalTrans->transmissibility(c1, c2);
859 if (gc2 - gc1 == dims[0]*dims[1]) {
860 tranz.data[gc1] = globalTrans->transmissibility(c1, c2);
865 return {{
"TRANX" , tranx},
870 void exportNncStructure_()
872 nnc_ = eclState().getInputNNC();
873 int nx = eclState().getInputGrid().getNX();
874 int ny = eclState().getInputGrid().getNY();
877 const Grid& globalGrid = this->globalGrid();
878 const auto& globalGridView = globalGrid.leafGridView();
879 typedef typename Grid::LeafGridView GridView;
880 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
881 ElementMapper globalElemMapper(globalGridView);
883 const auto* globalTrans = &(ebosSimulator_->gridManager().globalTransmissibility());
884 if (grid().comm().size() < 2) {
891 globalTrans = &ebosSimulator_->problem().eclTransmissibilities();
894 auto elemIt = globalGridView.template begin<0>();
895 const auto& elemEndIt = globalGridView.template end<0>();
896 for (; elemIt != elemEndIt; ++ elemIt) {
897 const auto& elem = *elemIt;
899 auto isIt = globalGridView.ibegin(elem);
900 const auto& isEndIt = globalGridView.iend(elem);
901 for (; isIt != isEndIt; ++ isIt) {
902 const auto& is = *isIt;
909 unsigned c1 = globalElemMapper.index(is.inside());
910 unsigned c2 = globalElemMapper.index(is.outside());
920 int cc1 = globalGrid.globalCell()[c1];
921 int cc2 = globalGrid.globalCell()[c2];
923 if (std::abs(cc1 - cc2) != 1 &&
924 std::abs(cc1 - cc2) != nx &&
925 std::abs(cc1 - cc2) != nx*ny)
927 nnc_.addNNC(cc1, cc2, globalTrans->transmissibility(c1, c2));
933 std::unique_ptr<EbosSimulator> ebosSimulator_;
935 bool output_cout_ =
false;
936 FileOutputValue output_ = OUTPUT_ALL;
937 bool must_distribute_ =
false;
938 ParameterGroup param_;
939 bool output_to_files_ =
false;
940 std::string output_dir_ = std::string(
".");
941 std::unique_ptr<ReservoirState> state_;
943 std::unique_ptr<EclipseIO> eclIO_;
944 std::unique_ptr<OutputWriter> output_writer_;
945 boost::any parallel_information_;
946 std::unique_ptr<NewtonIterationBlackoilInterface> fis_solver_;
947 std::unique_ptr<Simulator> simulator_;
948 std::string logFile_;
950 std::shared_ptr<Grid> globalGrid_;
954 #endif // OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
std::string moduleVersionName()
Return the version name of the module, for example "2015.10" (for a release branch) or "2016...
Definition: moduleVersion.cpp:28
void ensureDirectoryExists(const boost::filesystem::path &dirpath)
The directory pointed to by 'dirpath' will be created if it does not already exist.
Definition: ensureDirectoryExists.cpp:30
a simulator for the blackoil model
Definition: SimulatorFullyImplicitBlackoilEbos.hpp:48
Definition: FlowMainEbos.hpp:67
void createSimulator()
This is the main function of Flow.
Definition: FlowMainEbos.hpp:702
int execute(int argc, char **argv)
This is the main function of Flow.
Definition: FlowMainEbos.hpp:96
Wrapper class for VTK, Matlab, and ECL output.
Definition: SimulatorFullyImplicitBlackoilOutput.hpp:206