Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocess int64 #819

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions opm/grid/CellQuadrature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int CellQuadrature::numQuadPts() const
}
assert(grid_.dimensions == 3);
int sumnodes = 0;
for (int hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
for (grid_size_t hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
const int face = grid_.cell_faces[hf];
sumnodes += grid_.face_nodepos[face + 1] - grid_.face_nodepos[face];
}
Expand Down Expand Up @@ -133,7 +133,7 @@ void CellQuadrature::quadPtCoord(const int index, double* coord) const
int tetindex = index / 4;
const int subindex = index % 4;
const double* nc = grid_.node_coordinates;
for (int hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
for (grid_size_t hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
const int face = grid_.cell_faces[hf];
const int nfn = grid_.face_nodepos[face + 1] - grid_.face_nodepos[face];
if (nfn <= tetindex) {
Expand Down Expand Up @@ -178,7 +178,7 @@ double CellQuadrature::quadPtWeight(const int index) const
assert(dim == 3);
int tetindex = index / 4;
const double* nc = grid_.node_coordinates;
for (int hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
for (grid_size_t hf = grid_.cell_facepos[cell_]; hf < grid_.cell_facepos[cell_ + 1]; ++hf) {
const int face = grid_.cell_faces[hf];
const int nfn = grid_.face_nodepos[face + 1] - grid_.face_nodepos[face];
if (nfn <= tetindex) {
Expand Down
2 changes: 1 addition & 1 deletion opm/grid/ColumnExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct ExtractColumnCompare
/// \return true if two cells are neighbours.
bool neighbours(const UnstructuredGrid& grid, const int c0, const int c1)
{
for (int hf = grid.cell_facepos[c0]; hf < grid.cell_facepos[c0 + 1]; ++hf) {
for (grid_size_t hf = grid.cell_facepos[c0]; hf < grid.cell_facepos[c0 + 1]; ++hf) {
const int f = grid.cell_faces[hf];
if (grid.face_cells[2*f] == c1 || grid.face_cells[2*f+1] == c1) {
return true;
Expand Down
19 changes: 8 additions & 11 deletions opm/grid/CpGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@
#include <opm/grid/cpgrid/OrientedEntityTable.hpp>
#include <opm/grid/cpgpreprocess/preprocess.h>
#include <opm/grid/utility/platform_dependent/reenable_warnings.h> // Not really needed it seems, but alas.
#include "common/GridEnums.hpp"
#include <opm/grid/utility/OpmWellType.hpp>
#include "common/GridEnums.hpp"
#include <opm/grid/utility/OpmWellType.hpp>

#include <iostream>
#if ! HAVE_MPI
#include <list>
#endif
#include <set>

namespace Opm
{
Expand Down Expand Up @@ -1196,20 +1193,20 @@ namespace Dune
std::vector<std::array<int,2>> mapLeafIndexSetToLocalCartesianIndexSets() const;

/// \brief Size of the overlap on the leaf level
unsigned int overlapSize(int) const;
grid_size_t overlapSize(int) const;


/// \brief Size of the ghost cell layer on the leaf level
unsigned int ghostSize(int) const;
grid_size_t ghostSize(int) const;

/// \brief Size of the overlap on a given level
unsigned int overlapSize(int, int) const;
grid_size_t overlapSize(int, int) const;

/// \brief Size of the ghost cell layer on a given level
unsigned int ghostSize(int, int) const;
grid_size_t ghostSize(int, int) const;

/// \brief returns the number of boundary segments within the macro grid
unsigned int numBoundarySegments() const;
grid_size_t numBoundarySegments() const;

void setPartitioningParams(const std::map<std::string,std::string>& params);

Expand Down
10 changes: 5 additions & 5 deletions opm/grid/GridHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ double cellCenterDepth(const UnstructuredGrid& grid, int cell_index)
const int nv = 8; // Assuming 2*4 vertices ...
double zz = 0.0;
// Traverse the bottom and top cell-face
for (int i=grid.cell_facepos[cell_index+1]-2; i<grid.cell_facepos[cell_index+1]; ++i) {
for (grid_size_t i = grid.cell_facepos[cell_index+1] - 2; i < grid.cell_facepos[cell_index+1]; ++i) {
// Traverse the vertices associated with each face
assert(grid.face_nodepos[grid.cell_faces[i]+1] - grid.face_nodepos[grid.cell_faces[i]] == nv/2);
for (int j=grid.face_nodepos[grid.cell_faces[i]]; j<grid.face_nodepos[grid.cell_faces[i]+1]; ++j) {
for (grid_size_t j = grid.face_nodepos[grid.cell_faces[i]]; j < grid.face_nodepos[grid.cell_faces[i]+1]; ++j) {
zz += (grid.node_coordinates+nd*(grid.face_nodes[j]))[nd-1];
}
}
Expand All @@ -112,7 +112,7 @@ Dune::FieldVector<double,3> faceCenterEcl(const UnstructuredGrid& grid, int cell
Dune::FieldVector<double,3> center(0.0);
//Vector center(0.0);
// Traverse the bottom and top cell-face
for (int i=grid.cell_facepos[cell_index+1]-2; i<grid.cell_facepos[cell_index+1]; ++i) {
for (grid_size_t i = grid.cell_facepos[cell_index+1] - 2; i < grid.cell_facepos[cell_index+1]; ++i) {
// Traverse the vertices associated with each face
assert(grid.face_nodepos[grid.cell_faces[i]+1] - grid.face_nodepos[grid.cell_faces[i]] == nv);

Expand Down Expand Up @@ -154,7 +154,7 @@ Dune::FieldVector<double,3> faceCenterEcl(const UnstructuredGrid& grid, int cell
}
break;
case 4: {
if (i == grid.cell_facepos[cell_index+1]-2) {
if (i == grid.cell_facepos[cell_index+1] - 2) {
for (int indx = 0; indx < nd; ++indx) {
center[indx] += (grid.node_coordinates+nd*(grid.face_nodes[start]))[indx];
center[indx] += (grid.node_coordinates+nd*(grid.face_nodes[start+1]))[indx];
Expand All @@ -165,7 +165,7 @@ Dune::FieldVector<double,3> faceCenterEcl(const UnstructuredGrid& grid, int cell
}
break;
case 5: {
if (i == grid.cell_facepos[cell_index+1]-1) {
if (i == grid.cell_facepos[cell_index+1] - 1) {
for (int indx = 0; indx < nd; ++indx) {
center[indx] += (grid.node_coordinates+nd*(grid.face_nodes[start]))[indx];
center[indx] += (grid.node_coordinates+nd*(grid.face_nodes[start+1]))[indx];
Expand Down
4 changes: 2 additions & 2 deletions opm/grid/GridHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SparseTableView
/// \param offset The offsets of the rows. Row i starts
/// at offset[i] and ends a offset[i+1]
/// \param size The number of entries/rows of the table
SparseTableView(int* data, int *offset, std::size_t size_arg)
SparseTableView(int* data, grid_size_t *offset, std::size_t size_arg)
: data_(data), offset_(offset), size_(size_arg)
{}

Expand Down Expand Up @@ -84,7 +84,7 @@ class SparseTableView
/// \brief offset The offsets of the rows.
///
/// Row i starts at offset[i] and ends a offset[i+1]
const int* offset_;
const grid_size_t* offset_;
/// \brief The size, i.e. the number of rows.
std::size_t size_;
};
Expand Down
4 changes: 2 additions & 2 deletions opm/grid/GridUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Opm
const int num_faces = numFaces(grid);
const auto fc = faceCells(grid);
for (int face = 0; face < num_faces; ++face) {
for (int nodepos = grid.face_nodepos[face]; nodepos < grid.face_nodepos[face + 1]; ++nodepos) {
for (grid_size_t nodepos = grid.face_nodepos[face]; nodepos < grid.face_nodepos[face + 1]; ++nodepos) {
const int vertex = grid.face_nodes[nodepos];
for (int face_nb = 0; face_nb < 2; ++face_nb) {
const int face_nb_cell = fc(face, face_nb);
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace Opm
const int num_cell_faces = cell_faces.size();
for (int local_face = 0; local_face < num_cell_faces; ++local_face) {
const int face = cell_faces[local_face];
for (int nodepos = grid.face_nodepos[face]; nodepos < grid.face_nodepos[face + 1]; ++nodepos) {
for (grid_size_t nodepos = grid.face_nodepos[face]; nodepos < grid.face_nodepos[face + 1]; ++nodepos) {
const int vertex = grid.face_nodes[nodepos];
nb.insert(v2c[vertex].begin(), v2c[vertex].end());
}
Expand Down
36 changes: 18 additions & 18 deletions opm/grid/LookUpData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public:
/// For CpGrid, the field property vector is assumed to be given for level 0 when isFieldPropLgr_ == false,
/// and for certain LGR/level > 0 when isFieldPropLgr_ == true.
template<typename EntityType, typename FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, unsigned int>, FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, grid_size_t>, FieldPropType>
operator()(const EntityType& elem, const std::vector<FieldPropType>& fieldProp) const;

/// \brief: Get field property of type double from field properties manager by name.
Expand Down Expand Up @@ -120,7 +120,7 @@ public:
/// \tparam GridType Auxiliary type to overload the method, distinguishing general grids from CpGrid, with std::enable_if.
/// Default: GridType = Grid.
template<typename EntityType, typename GridType = Grid>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
getFieldPropIdx(const EntityType& elem) const;

/// \brief: Return index to search for the field propertries, for CpGrids.
Expand All @@ -132,7 +132,7 @@ public:
/// \tparam GridType Auxiliary type to overload the method, distinguishing general grids from CpGrid, with std::enable_if.
/// Default: GridType = Grid.
template<typename EntityType, typename GridType = Grid>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
getFieldPropIdx(const EntityType& elem) const;

/// \brief: Return the same element index for all grids different from CpGrid.
Expand Down Expand Up @@ -204,7 +204,7 @@ public:
/// For CpGrid, the field property vector is assumed to be given for level 0 when isFieldPropLgr_ == false,
/// and for certain LGR/level > 0 when isFieldPropLgr_ == true.
template<typename EntityType, typename FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, unsigned int>, FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, grid_size_t>, FieldPropType>
operator()(const EntityType& elem,const std::vector<FieldPropType>& fieldProp) const;

/// \brief: Get field property of type double from field properties manager by name.
Expand Down Expand Up @@ -235,7 +235,7 @@ public:
/// \tparam GridType Auxiliary type to overload the method, distinguishing general grids from CpGrid, with std::enable_if.
/// Default: GridType = Grid.
template<typename EntityType, typename GridType = Grid>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
getFieldPropCartesianIdx(const EntityType& elem) const;

/// \brief: Return index to search for the field propertries, for CpGrids.
Expand All @@ -246,7 +246,7 @@ public:
/// \tparam GridType Auxiliary type to overload the method, distinguishing general grids from CpGrid, with std::enable_if.
/// Default: GridType = Grid.
template<typename EntityType, typename GridType = Grid>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
getFieldPropCartesianIdx(const EntityType& elem) const;

/// \brief: Return the same element index for all grids different from CpGrid.
Expand Down Expand Up @@ -293,7 +293,7 @@ FieldPropType Opm::LookUpData<Grid,GridView>::operator()(const int& elemIdx,

template<typename Grid, typename GridView>
template<typename EntityType, typename FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, unsigned int>,FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, grid_size_t>,FieldPropType>
Opm::LookUpData<Grid,GridView>::operator()(const EntityType& elem,
const std::vector<FieldPropType>& fieldProp) const
{
Expand All @@ -307,7 +307,7 @@ std::vector<double> Opm::LookUpData<Grid,GridView>::assignFieldPropsDoubleOnLeaf
const std::string& propString) const
{
std::vector<double> fieldPropOnLeaf;
unsigned int numElements = gridView_.size(0);
grid_size_t numElements = gridView_.size(0);
fieldPropOnLeaf.resize(numElements);
const auto& fieldProp = fieldPropsManager.get_double(propString);
if ( (propString == "PORV") && (gridView_.grid().maxLevel() > 0)) {
Expand Down Expand Up @@ -346,7 +346,7 @@ std::vector<IntType> Opm::LookUpData<Grid,GridView>::assignFieldPropsIntOnLeaf(c
std::function<void(IntType, int)> valueCheck) const
{
std::vector<IntType> fieldPropOnLeaf;
unsigned int numElements = gridView_.size(0);
grid_size_t numElements = gridView_.size(0);
fieldPropOnLeaf.resize(numElements);
const auto& fieldProp = fieldPropsManager.get_int(propString);
for (const auto& element : elements(gridView_)) {
Expand Down Expand Up @@ -380,7 +380,7 @@ int Opm::LookUpData<Grid,GridView>::fieldPropInt(const FieldPropsManager& fieldP

template<typename Grid, typename GridView>
template<typename EntityType, typename GridType>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
Opm::LookUpData<Grid,GridView>::getFieldPropIdx(const EntityType& elem) const
{
static_assert(std::is_same_v<Grid,GridType>);
Expand All @@ -390,7 +390,7 @@ Opm::LookUpData<Grid,GridView>::getFieldPropIdx(const EntityType& elem) const

template<typename Grid, typename GridView>
template<typename EntityType,typename GridType>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
Opm::LookUpData<Grid,GridView>::getFieldPropIdx(const EntityType& elem) const
{
static_assert(std::is_same_v<Grid,GridType>);
Expand Down Expand Up @@ -448,7 +448,7 @@ FieldPropType Opm::LookUpCartesianData<Grid,GridView>::operator()(const int& ele

template<typename Grid, typename GridView>
template<typename EntityType, typename FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, unsigned int>,FieldPropType>
typename std::enable_if_t<!std::is_same_v<EntityType, grid_size_t>,FieldPropType>
Opm::LookUpCartesianData<Grid,GridView>::operator()(const EntityType& elem,
const std::vector<FieldPropType>& fieldProp) const
{
Expand All @@ -463,10 +463,10 @@ std::vector<double> Opm::LookUpCartesianData<Grid,GridView>::assignFieldPropsDou
const std::string& propString) const
{
std::vector<double> fieldPropOnLeaf;
unsigned int numElements = gridView_.size(0);
grid_size_t numElements = gridView_.size(0);
fieldPropOnLeaf.resize(numElements);
const auto& fieldProp = fieldPropsManager.get_double(propString);
for (unsigned int elemIdx = 0; elemIdx < numElements; ++elemIdx) {
for (grid_size_t elemIdx = 0; elemIdx < numElements; ++elemIdx) {
const auto fieldPropCartIdx = this->getFieldPropCartesianIdx<Grid>(elemIdx);
fieldPropOnLeaf[elemIdx] = fieldProp[fieldPropCartIdx];
}
Expand All @@ -481,10 +481,10 @@ std::vector<IntType> Opm::LookUpCartesianData<Grid,GridView>::assignFieldPropsIn
std::function<void(IntType, int)> valueCheck) const
{
std::vector<IntType> fieldPropOnLeaf;
unsigned int numElements = gridView_.size(0);
grid_size_t numElements = gridView_.size(0);
fieldPropOnLeaf.resize(numElements);
const auto& fieldProp = fieldPropsManager.get_int(propString);
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
for (grid_size_t elemIdx = 0; elemIdx < numElements; ++elemIdx) {
const auto fieldPropCartIdx = this->getFieldPropCartesianIdx<Grid>(elemIdx);
fieldPropOnLeaf[elemIdx] = fieldProp[fieldPropCartIdx] - needsTranslation;
valueCheck(fieldProp[fieldPropCartIdx], fieldPropCartIdx);
Expand Down Expand Up @@ -514,7 +514,7 @@ int Opm::LookUpCartesianData<Grid,GridView>::fieldPropInt(const FieldPropsManage

template<typename Grid, typename GridView>
template<typename EntityType, typename GridType>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
Opm::LookUpCartesianData<Grid,GridView>::getFieldPropCartesianIdx(const EntityType& elem) const
{
static_assert(std::is_same_v<Grid,GridType>);
Expand All @@ -525,7 +525,7 @@ Opm::LookUpCartesianData<Grid,GridView>::getFieldPropCartesianIdx(const EntityTy

template<typename Grid, typename GridView>
template<typename EntityType, typename GridType>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, unsigned int>,int>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid> && !std::is_same_v<EntityType, grid_size_t>,int>
Opm::LookUpCartesianData<Grid,GridView>::getFieldPropCartesianIdx(const EntityType& elem) const
{
static_assert(std::is_same_v<Grid,GridType>);
Expand Down
2 changes: 1 addition & 1 deletion opm/grid/UnstructuredGrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ allocate_grid_from_file(FILE *fp, int *has_tag, int *has_indexmap)
struct UnstructuredGrid *G;

int save_errno;
unsigned long tmp;
grid_size_t tmp;
size_t dimens[GRID_NMETA], i;

save_errno = errno;
Expand Down
8 changes: 6 additions & 2 deletions opm/grid/UnstructuredGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>

#include <opm/grid/grid_size.h>

/**
* \file
Expand Down Expand Up @@ -78,6 +81,7 @@ read_grid(const char *fname);
---- end of synopsis of grid.h ----
*/


/**
Data structure for an unstructured grid, unstructured meaning that
any cell may have an arbitrary number of adjacent cells. The struct
Expand Down Expand Up @@ -124,7 +128,7 @@ struct UnstructuredGrid
for f's nodes in the face_nodes array.
The size of the array is equal to (number_of_faces + 1).
*/
int *face_nodepos;
grid_size_t *face_nodepos;
/**
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain
the cell indices of the cells adjacent to f. The number -1
Expand All @@ -149,7 +153,7 @@ struct UnstructuredGrid
for c's faces in the cell_faces array.
The size of the array is equal to (number_of_cells + 1).
*/
int *cell_facepos;
grid_size_t *cell_facepos;

/**
Node coordinates, stored consecutively for each node. That is,
Expand Down
6 changes: 4 additions & 2 deletions opm/grid/cart_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ fill_cart_topology_3d(struct UnstructuredGrid *G)
int nxf, nyf;
int i,j,k;

int *cfaces, *cfacepos, *fnodes, *fnodepos, *fcells;
int *cfaces, *fnodes, *fcells;
grid_size_t *fnodepos, *cfacepos;

nx = G->cartdims[0];
ny = G->cartdims[1];
Expand Down Expand Up @@ -548,7 +549,8 @@ fill_cart_topology_2d(struct UnstructuredGrid *G)
int nxf;
int Nx;

int *fnodes, *fnodepos, *fcells, *cfaces, *cfacepos;
int *fnodes, *fcells, *cfaces;
grid_size_t *cfacepos, *fnodepos;

cfaces = G->cell_faces;
cfacepos = G->cell_facepos;
Expand Down
4 changes: 2 additions & 2 deletions opm/grid/common/GridAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ class GridAdapter
UnstructuredGrid g_;
// Topology storage.
std::vector<int> face_nodes_;
std::vector<int> face_nodepos_;
std::vector<grid_size_t> face_nodepos_;
std::vector<int> face_cells_;
std::vector<int> cell_faces_;
std::vector<int> cell_facepos_;
std::vector<grid_size_t> cell_facepos_;
// Geometry storage.
std::vector<double> node_coordinates_;
std::vector<double> face_centroids_;
Expand Down
Loading