From cf06a322ec5c69fccd3fb4084b351e89c543052c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 29 Apr 2021 09:45:06 +0200 Subject: [PATCH] countGlobalCells: put non-template code in separate compile unit --- CMakeLists_files.cmake | 1 + opm/simulators/flow/countGlobalCells.cpp | 50 ++++++++++++++++++++++++ opm/simulators/flow/countGlobalCells.hpp | 33 +++++----------- 3 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 opm/simulators/flow/countGlobalCells.cpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index c7870912b..6e9fc77cd 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -26,6 +26,7 @@ list (APPEND MAIN_SOURCE_FILES opm/core/props/phaseUsageFromDeck.cpp opm/core/props/satfunc/RelpermDiagnostics.cpp opm/simulators/timestepping/SimulatorReport.cpp + opm/simulators/flow/countGlobalCells.cpp opm/simulators/flow/KeywordValidation.cpp opm/simulators/linalg/ExtractParallelGridInformationToISTL.cpp opm/simulators/linalg/FlexibleSolver1.cpp diff --git a/opm/simulators/flow/countGlobalCells.cpp b/opm/simulators/flow/countGlobalCells.cpp new file mode 100644 index 000000000..d72c550c3 --- /dev/null +++ b/opm/simulators/flow/countGlobalCells.cpp @@ -0,0 +1,50 @@ +/* + Copyright 2013, 2015 SINTEF ICT, Applied Mathematics. + Copyright 2014, 2015 Dr. Blatt - HPC-Simulation-Software & Services + Copyright 2014, 2015 Statoil ASA. + Copyright 2015 NTNU + Copyright 2015 IRIS AS + + 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 . +*/ + +#include "countGlobalCells.hpp" + +#include + +namespace Opm { +namespace detail { + +std::vector buildAllCells(const int nc) { + std::vector all_cells(nc); + std::iota(all_cells.begin(), all_cells.end(), 0); + return all_cells; +} + +double getGravity(const double* g, const int dim) { + double grav = 0.0; + if (g) { + // Guard against gravity in anything but last dimension. + for (int dd = 0; dd < dim - 1; ++dd) { + assert(g[dd] == 0.0); + } + grav = g[dim - 1]; + } + return grav; +} + +} // namespace detail +} // namespace Opm diff --git a/opm/simulators/flow/countGlobalCells.hpp b/opm/simulators/flow/countGlobalCells.hpp index 323204fca..fc2836b5d 100644 --- a/opm/simulators/flow/countGlobalCells.hpp +++ b/opm/simulators/flow/countGlobalCells.hpp @@ -21,28 +21,24 @@ along with OPM. If not, see . */ -#ifndef OPM_BLACKOILDETAILS_HEADER_INCLUDED -#define OPM_BLACKOILDETAILS_HEADER_INCLUDED +#ifndef OPM_COUNTGLOBALCELLS_HEADER_INCLUDED +#define OPM_COUNTGLOBALCELLS_HEADER_INCLUDED #include #include +#include + +#include + #include +#include namespace Opm { namespace detail { - inline - std::vector - buildAllCells(const int nc) - { - std::vector all_cells(nc); - - for (int c = 0; c < nc; ++c) { all_cells[c] = c; } - - return all_cells; - } + std::vector buildAllCells(const int nc); @@ -80,18 +76,7 @@ namespace detail { - inline - double getGravity(const double* g, const int dim) { - double grav = 0.0; - if (g) { - // Guard against gravity in anything but last dimension. - for (int dd = 0; dd < dim - 1; ++dd) { - assert(g[dd] == 0.0); - } - grav = g[dim - 1]; - } - return grav; - } + double getGravity(const double* g, const int dim); /// \brief Compute the Euclidian norm of a vector