2014-02-20 06:08:10 -06:00
|
|
|
/*
|
2015-02-20 05:23:35 -06:00
|
|
|
Copyright 2014, 2015 Dr. Markus Blatt - HPC-Simulation-Software & Services.
|
2014-02-20 06:08:10 -06:00
|
|
|
Copyright 2014 Statoil AS
|
2015-02-20 05:23:35 -06:00
|
|
|
Copyright 2015 NTNU
|
2014-02-20 06:08:10 -06:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
2015-02-23 04:02:13 -06:00
|
|
|
#ifndef OPM_AUTODIFF_GRIDHELPERS_HEADER_INCLUDED
|
|
|
|
#define OPM_AUTODIFF_GRIDHELPERS_HEADER_INCLUDED
|
2014-02-20 06:08:10 -06:00
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
#include <functional>
|
|
|
|
|
2018-02-09 06:42:16 -06:00
|
|
|
#include <opm/grid/UnstructuredGrid.h>
|
|
|
|
#include <opm/grid/GridHelpers.hpp>
|
2014-04-15 13:46:45 -05:00
|
|
|
|
2015-10-06 05:11:49 -05:00
|
|
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
2014-04-15 13:46:45 -05:00
|
|
|
|
2014-02-20 06:08:10 -06:00
|
|
|
#include <Eigen/Eigen>
|
|
|
|
#include <Eigen/Sparse>
|
|
|
|
|
2015-11-30 07:15:19 -06:00
|
|
|
#include <boost/range/iterator_range.hpp>
|
|
|
|
|
2016-04-05 08:17:17 -05:00
|
|
|
#ifdef HAVE_OPM_GRID
|
2018-02-09 06:42:16 -06:00
|
|
|
#include <opm/grid/CpGrid.hpp>
|
|
|
|
#include <opm/grid/cpgrid/GridHelpers.hpp>
|
|
|
|
#include <opm/grid/polyhedralgrid.hh>
|
2014-02-20 06:08:10 -06:00
|
|
|
#endif
|
|
|
|
|
2015-10-06 05:11:49 -05:00
|
|
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
2014-04-15 13:46:45 -05:00
|
|
|
|
|
|
|
|
2014-02-20 06:08:10 -06:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
namespace AutoDiffGrid
|
|
|
|
{
|
2014-02-20 06:08:10 -06:00
|
|
|
|
|
|
|
/// \brief Mapps a grid type to the corresponding face to cell mapping.
|
|
|
|
///
|
|
|
|
/// The value of the mapping is provided by the type Type.
|
|
|
|
template<class T>
|
|
|
|
struct ADFaceCellTraits
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Get the z coordinates of the cell centroids of a grid.
|
|
|
|
Eigen::Array<double, Eigen::Dynamic, 1>
|
2014-08-28 07:44:13 -05:00
|
|
|
cellCentroidsZToEigen(const UnstructuredGrid& grid);
|
2014-02-20 06:08:10 -06:00
|
|
|
|
|
|
|
/// \brief Mapping of the grid type to the type of the cell to faces mapping.
|
|
|
|
template<class T>
|
|
|
|
struct ADCell2FacesTraits
|
|
|
|
: public Opm::UgGridHelpers::Cell2FacesTraits<T>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief extracts the internal faces of a grid.
|
|
|
|
/// \param[in] The grid whose internal faces we query.
|
|
|
|
/// \param[out] internal_faces The internal faces.
|
2015-07-10 07:15:54 -05:00
|
|
|
/// \param[out] nbi
|
2014-02-20 06:08:10 -06:00
|
|
|
void extractInternalFaces(const UnstructuredGrid& grid,
|
|
|
|
Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
|
|
|
|
Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
|
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
} // end namespace AutoDiffGrid
|
|
|
|
} // end namespace Opm
|
2014-02-20 06:08:10 -06:00
|
|
|
|
2016-04-05 08:17:17 -05:00
|
|
|
#ifdef HAVE_OPM_GRID
|
2014-02-20 06:08:10 -06:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace AutoDiffGrid
|
2014-02-20 06:17:18 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief Get the z coordinates of the cell centroids of a grid.
|
2014-08-28 07:44:13 -05:00
|
|
|
/// \return The z coordinates of the cell centroids in an Eigen array
|
2014-02-20 06:17:18 -06:00
|
|
|
Eigen::Array<double, Eigen::Dynamic, 1>
|
2014-08-28 07:44:13 -05:00
|
|
|
cellCentroidsZToEigen(const Dune::CpGrid& grid);
|
2014-02-20 06:17:18 -06:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ADCell2FacesTraits<Dune::CpGrid>
|
|
|
|
{
|
2015-02-23 04:02:13 -06:00
|
|
|
typedef Dune::cpgrid::Cell2FacesContainer Type;
|
2014-02-20 06:17:18 -06:00
|
|
|
};
|
2014-02-20 06:08:10 -06:00
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
/// \brief extracts the internal faces of a grid.
|
|
|
|
/// \param[in] The grid whose internal faces we query.
|
|
|
|
/// \param[out] internal_faces The internal faces.
|
2015-07-10 07:15:54 -05:00
|
|
|
/// \param[out] nbi
|
2014-02-20 06:17:18 -06:00
|
|
|
void extractInternalFaces(const Dune::CpGrid& grid,
|
|
|
|
Eigen::Array<int, Eigen::Dynamic, 1>& internal_faces,
|
|
|
|
Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>& nbi);
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ADFaceCellTraits<Dune::CpGrid>
|
|
|
|
: public Opm::UgGridHelpers::FaceCellTraits<Dune::CpGrid>
|
|
|
|
{};
|
|
|
|
/// \brief Get the face to cell mapping of a grid.
|
2014-08-28 07:44:13 -05:00
|
|
|
ADFaceCellTraits<Dune::CpGrid>::Type
|
|
|
|
faceCellsToEigen(const Dune::CpGrid& grid);
|
2014-02-20 06:08:10 -06:00
|
|
|
} // end namespace AutoDiffGrid
|
|
|
|
} //end namespace OPM
|
|
|
|
|
|
|
|
#endif
|
2014-02-20 06:17:18 -06:00
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
namespace AutoDiffGrid
|
|
|
|
{
|
|
|
|
|
|
|
|
using Opm::UgGridHelpers::SparseTableView;
|
|
|
|
using Opm::UgGridHelpers::numCells;
|
2014-08-28 07:44:13 -05:00
|
|
|
using Opm::UgGridHelpers::faceCells;
|
2014-02-20 06:17:18 -06:00
|
|
|
using Opm::UgGridHelpers::numFaces;
|
|
|
|
using Opm::UgGridHelpers::dimensions;
|
|
|
|
using Opm::UgGridHelpers::cartDims;
|
|
|
|
using Opm::UgGridHelpers::globalCell;
|
|
|
|
using Opm::UgGridHelpers::cell2Faces;
|
|
|
|
using Opm::UgGridHelpers::increment;
|
|
|
|
using Opm::UgGridHelpers::getCoordinate;
|
|
|
|
using Opm::UgGridHelpers::numCellFaces;
|
|
|
|
using Opm::UgGridHelpers::beginFaceCentroids;
|
|
|
|
using Opm::UgGridHelpers::beginCellCentroids;
|
2015-02-23 05:24:40 -06:00
|
|
|
using Opm::UgGridHelpers::cellCentroid;
|
|
|
|
using Opm::UgGridHelpers::faceCentroid;
|
|
|
|
using Opm::UgGridHelpers::beginCellVolumes;
|
|
|
|
using Opm::UgGridHelpers::cellVolume;
|
2014-02-20 06:17:18 -06:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ADFaceCellTraits<UnstructuredGrid>
|
|
|
|
{
|
|
|
|
typedef Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor> Type;
|
|
|
|
};
|
|
|
|
|
2016-04-05 08:17:17 -05:00
|
|
|
#ifdef HAVE_OPM_GRID
|
2015-07-10 07:15:54 -05:00
|
|
|
// specialization for PolyhedralGrid as a fallback to UnstructuredGrid
|
|
|
|
template< int dim, int dimworld >
|
|
|
|
struct ADFaceCellTraits< Dune::PolyhedralGrid< dim, dimworld > >
|
|
|
|
: public ADFaceCellTraits<UnstructuredGrid>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
/// \brief Get the face to cell mapping of a grid.
|
|
|
|
ADFaceCellTraits<UnstructuredGrid>::Type
|
2014-08-28 07:44:13 -05:00
|
|
|
faceCellsToEigen(const UnstructuredGrid& grid);
|
2014-02-20 06:17:18 -06:00
|
|
|
|
2014-08-28 07:44:13 -05:00
|
|
|
} // end namespace AutoDiffGrid
|
|
|
|
} //end namespace OPM
|
2014-02-20 06:17:18 -06:00
|
|
|
|
2014-02-20 06:08:10 -06:00
|
|
|
#endif
|