Skip to content
Open
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
8 changes: 4 additions & 4 deletions opm/grid/CpGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,28 +1743,28 @@ namespace Dune
/// \brief Get the Position of a vertex.
/// \param cell The index identifying the cell.
/// \return The coordinates of the vertex.
const Vector& vertexPosition(int vertex) const;
Vector vertexPosition(int vertex) const;

/// \brief Get the area of a face.
/// \param cell The index identifying the face.
double faceArea(int face) const;

/// \brief Get the coordinates of the center of a face.
/// \param cell The index identifying the face.
const Vector& faceCentroid(int face) const;
Vector faceCentroid(int face) const;

/// \brief Get the unit normal of a face.
/// \param cell The index identifying the face.
/// \see faceCell
const Vector& faceNormal(int face) const;
Vector faceNormal(int face) const;

/// \brief Get the volume of the cell.
/// \param cell The index identifying the cell.
double cellVolume(int cell) const;

/// \brief Get the coordinates of the center of a cell.
/// \param cell The index identifying the face.
const Vector& cellCentroid(int cell) const;
Vector cellCentroid(int cell) const;

/// \brief An iterator over the centroids of the geometry of the entities.
/// \tparam codim The co-dimension of the entities.
Expand Down
36 changes: 17 additions & 19 deletions opm/grid/cpgrid/CpGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ const Dune::FieldVector<double,3> CpGrid::faceAreaNormalEcl(int face) const
}
}

const Dune::FieldVector<double,3>& CpGrid::vertexPosition(int vertex) const
Dune::FieldVector<double,3> CpGrid::vertexPosition(int vertex) const
{
return current_view_data_->geomVector<3>()[cpgrid::EntityRep<3>(vertex, true)].center();
}
Expand All @@ -1765,12 +1765,12 @@ double CpGrid::faceArea(int face) const
return current_view_data_->geomVector<1>()[cpgrid::EntityRep<1>(face, true)].volume();
}

const Dune::FieldVector<double,3>& CpGrid::faceCentroid(int face) const
Dune::FieldVector<double,3> CpGrid::faceCentroid(int face) const
{
return current_view_data_->geomVector<1>()[cpgrid::EntityRep<1>(face, true)].center();
}

const Dune::FieldVector<double,3>& CpGrid::faceNormal(int face) const
Dune::FieldVector<double,3> CpGrid::faceNormal(int face) const
{
return current_view_data_->face_normals_.get(face);
}
Expand All @@ -1780,7 +1780,7 @@ double CpGrid::cellVolume(int cell) const
return current_view_data_->geomVector<0>()[cpgrid::EntityRep<0>(cell, true)].volume();
}

const Dune::FieldVector<double,3>& CpGrid::cellCentroid(int cell) const
Dune::FieldVector<double,3> CpGrid::cellCentroid(int cell) const
{
return current_view_data_->geomVector<0>()[cpgrid::EntityRep<0>(cell, true)].center();
}
Expand Down Expand Up @@ -2857,10 +2857,10 @@ void CpGrid::refineAndProvideMarkedRefinedRelations( /* Marked elements paramete
int& cell_count,
std::vector<std::vector<int>>& preAdapt_level_to_leaf_cells_vec,
/* Additional parameters */
const std::vector<std::array<int,3>>& cells_per_dim_vec) const
const std::vector<std::array<int,3>>& cells_per_dim_vec) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

// Each marked element for refinement (mark equal to 1), will be refined individuality, creating its own Lgr. The element index will
// be also used to identify its lgr. Even though, in the end, all the refined entities will belong to a unique level grid.
// For this reason, we associate "-1" with those elements that are not involved in any refinement and will appear
Expand All @@ -2878,7 +2878,7 @@ void CpGrid::refineAndProvideMarkedRefinedRelations( /* Marked elements paramete
cell_count +=1;
preAdapt_level_to_leaf_cells_vec[element.level()][element.getLevelElem().index()] = cell_count;
}

// When the element is marked for refinement, we also mark its corners and faces
// since they will get replaced by refined ones.
if (getMark(element) == 1) {
Expand Down Expand Up @@ -2914,7 +2914,7 @@ void CpGrid::refineAndProvideMarkedRefinedRelations( /* Marked elements paramete
refined_cell_count_vec[shiftedLevel] +=1;

}

preAdapt_parent_to_children_cells_vec[element.level()][element.getLevelElem().index()] = std::make_pair( markedElemLevel, refinedChildrenList);
for (const auto& [markedCorner, lgrEquivCorner] : parentCorners_to_equivalentRefinedCorners) {
cornerInMarkedElemWithEquivRefinedCorner[markedCorner].push_back({elemIdx, lgrEquivCorner});
Expand All @@ -2934,7 +2934,7 @@ CpGrid::defineChildToParentAndIdxInParentCell(const std::map<std::array<int,2>,s
const int& cell_count) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

// ------------------------ Refined grid parameters
// Refined child cells and their parents. Entry is {-1,-1} when cell has no father. Otherwise, {level parent cell, parent cell index}
// Each entry represents a refined level.
Expand Down Expand Up @@ -3304,7 +3304,7 @@ void CpGrid::identifyLeafGridCorners(std::map<std::array<int,2>,int>& elemLgrAnd
const std::vector<std::array<int,3>>& cells_per_dim_vec) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

// Step 1. Select/store the corners from the starting grid not involved in any (new) LGR.
// Replace the corners from level zero involved in LGR by the equivalent ones, born in LGRs.
// In this case, we avoid repetition considering the last appearance of the level zero corner
Expand Down Expand Up @@ -3458,8 +3458,8 @@ void CpGrid::identifyLeafGridFaces(std::map<std::array<int,2>,int>& elemLgrAndEl
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

// Max level before calling adapt.
const int& preAdaptMaxLevel = this->maxLevel();
const int& preAdaptMaxLevel = this->maxLevel();

// Step 1. Add the LGR faces, for each LGR
for (int elem = 0; elem < current_view_data_->size(0); ++elem) {
if (markedElem_to_itsLgr[elem]!=nullptr) {
Expand Down Expand Up @@ -3520,7 +3520,7 @@ void CpGrid::populateLeafGridCorners(Dune::cpgrid::EntityVariableBase<cpgrid::Ge
const std::unordered_map<int,std::array<int,2>>& adaptedCorner_to_elemLgrAndElemLgrCorner) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

adapted_corners.resize(corner_count);
for (int corner = 0; corner < corner_count; ++corner) {
const auto& [elemLgr, elemLgrCorner] = adaptedCorner_to_elemLgrAndElemLgrCorner.at(corner);
Expand Down Expand Up @@ -3561,7 +3561,7 @@ void CpGrid::populateLeafGridFaces(Dune::cpgrid::EntityVariableBase<cpgrid::Geom
const int& preAdaptMaxLevel) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

adapted_faces.resize(face_count);
mutable_face_tags.resize(face_count);
mutable_face_normals.resize(face_count);
Expand Down Expand Up @@ -3741,7 +3741,7 @@ void CpGrid::populateLeafGridCells(Dune::cpgrid::EntityVariableBase<cpgrid::Geom
const int& preAdaptMaxLevel) const
{
// If the (level zero) grid has been distributed, then the preAdaptGrid is data_[0]. Otherwise, preApaptGrid is current_view_data_.

// --- Adapted cells ---
// Store the adapted cells. Main difficulty: to lookup correctly the indices of the corners and faces of each cell.
adapted_cells.resize(cell_count);
Expand Down Expand Up @@ -3871,7 +3871,7 @@ void CpGrid::populateRefinedCells(std::vector<Dune::cpgrid::EntityVariableBase<c
const std::map<std::array<int,2>,int>& markedElemAndEquivRefinedCorn_to_corner,
const std::vector<std::vector<std::array<int,2>>>& cornerInMarkedElemWithEquivRefinedCorner,
const std::vector<std::array<int,3>>& cells_per_dim_vec) const
{
{
// --- Refined cells ---
for (std::size_t shiftedLevel = 0; shiftedLevel < refined_cell_count_vec.size(); ++shiftedLevel) {

Expand Down Expand Up @@ -4137,7 +4137,7 @@ void CpGrid::updateCornerHistoryLevels(const std::vector<std::vector<std::array<
currentData()[refinedLevel]->corner_history_[refinedCorner] = preAdaptGrid_corner_history.empty() ? std::array<int,2>{{0, static_cast<int>(corner)}} : preAdaptGrid_corner_history[corner];
}
}

// corner_history_ leaf grid view
for ( int leafCorner = 0; leafCorner < corner_count; ++leafCorner){
currentData().back()->corner_history_.resize(corner_count);
Expand Down Expand Up @@ -4664,5 +4664,3 @@ int CpGrid::replaceLgr1FaceIdxByLgr2FaceIdx(const std::array<int,3>& cells_per_d
}

} // namespace Dune


4 changes: 2 additions & 2 deletions opm/grid/cpgrid/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Entity : public EntityRep<codim>
}

/// @brief Return the geometry of the entity (does not depend on its orientation).
const Geometry& geometry() const;
Geometry geometry() const;

/// @brief Return the level of the entity in the grid hierarchy. Level = 0 represents the coarsest grid.
int level() const;
Expand Down Expand Up @@ -387,7 +387,7 @@ unsigned int Entity<codim>::subEntities ( const unsigned int cc ) const
}

template <int codim>
const typename Entity<codim>::Geometry& Entity<codim>::geometry() const
typename Entity<codim>::Geometry Entity<codim>::geometry() const
{
return pgrid_->geomVector<codim>()[*this];
}
Expand Down
18 changes: 9 additions & 9 deletions opm/grid/cpgrid/Geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace Dune
}

/// Returns the position of the vertex.
const GlobalCoordinate& global(const LocalCoordinate&) const
GlobalCoordinate global(const LocalCoordinate&) const
{
return pos_;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace Dune
}

/// Returns the centroid of the geometry.
const GlobalCoordinate& center() const
GlobalCoordinate center() const
{
return pos_;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ namespace Dune
}

/// This method is meaningless for singular geometries.
const GlobalCoordinate& global(const LocalCoordinate&) const
GlobalCoordinate global(const LocalCoordinate&) const
{
OPM_THROW(std::runtime_error, "Geometry::global() meaningless on singular geometry.");
}
Expand Down Expand Up @@ -319,20 +319,20 @@ namespace Dune
}

/// Returns the centroid of the geometry.
const GlobalCoordinate& center() const
GlobalCoordinate center() const
{
return pos_;
}

/// This method is meaningless for singular geometries.
const FieldMatrix<ctype, mydimension, coorddimension>&
FieldMatrix<ctype, mydimension, coorddimension>
jacobianTransposed(const LocalCoordinate& /* local */) const
{
OPM_THROW(std::runtime_error, "Meaningless to call jacobianTransposed() on singular geometries.");
}

/// This method is meaningless for singular geometries.
const FieldMatrix<ctype, coorddimension, mydimension>&
FieldMatrix<ctype, coorddimension, mydimension>
jacobianInverseTransposed(const LocalCoordinate& /*local*/) const
{
OPM_THROW(std::runtime_error, "Meaningless to call jacobianInverseTransposed() on singular geometries.");
Expand Down Expand Up @@ -526,7 +526,7 @@ namespace Dune
}

/// Returns the centroid of the geometry.
const GlobalCoordinate& center() const
GlobalCoordinate center() const
{
return pos_;
}
Expand All @@ -537,7 +537,7 @@ namespace Dune
/// and {u_i} are the reference coordinates.
/// g = g(u) = (g_1(u), g_2(u), g_3(u)), u=(u_1,u_2,u_3)
/// g = map from (local) reference domain to global cell
const JacobianTransposed
JacobianTransposed
jacobianTransposed(const LocalCoordinate& local_coord) const
{
static_assert(mydimension == 3, "");
Expand Down Expand Up @@ -573,7 +573,7 @@ namespace Dune
}

/// @brief Inverse of Jacobian transposed. \see jacobianTransposed().
const JacobianInverseTransposed
JacobianInverseTransposed
jacobianInverseTransposed(const LocalCoordinate& local_coord) const
{
JacobianInverseTransposed Jti = jacobianTransposed(local_coord);
Expand Down
15 changes: 7 additions & 8 deletions opm/grid/cpgrid/GridHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ beginFaceCentroids(const Dune::CpGrid& grid)
return FaceCentroidTraits<Dune::CpGrid>::IteratorType(grid, 0);
}

const double* cellCentroid(const Dune::CpGrid& grid, int cell_index)
Vector cellCentroid(const Dune::CpGrid& grid, int cell_index)
{
return &(grid.cellCentroid(cell_index)[0]);
return grid.cellCentroid(cell_index);
}

double cellVolume(const Dune::CpGrid& grid, int cell_index)
Expand All @@ -161,8 +161,7 @@ CellVolumeIterator endCellVolumes(const Dune::CpGrid& grid)
return CellVolumeIterator(grid, numCells(grid));
}

const FaceCentroidTraits<Dune::CpGrid>::ValueType&
faceCentroid(const Dune::CpGrid& grid, int face_index)
Vector faceCentroid(const Dune::CpGrid& grid, int face_index)
{
return grid.faceCentroid(face_index);
}
Expand All @@ -184,14 +183,14 @@ face2Vertices(const Dune::CpGrid& grid)
return Dune::cpgrid::FaceVerticesContainerProxy(&grid);
}

const double* vertexCoordinates(const Dune::CpGrid& grid, int index)
Vector vertexCoordinates(const Dune::CpGrid& grid, int index)
{
return &(grid.vertexPosition(index)[0]);
return grid.vertexPosition(index);
}

const double* faceNormal(const Dune::CpGrid& grid, int face_index)
Vector faceNormal(const Dune::CpGrid& grid, int face_index)
{
return &(grid.faceNormal(face_index)[0]);
return grid.faceNormal(face_index);
}

double faceArea(const Dune::CpGrid& grid, int face_index)
Expand Down
17 changes: 8 additions & 9 deletions opm/grid/cpgrid/GridHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ struct Cell2FacesTraits<Dune::CpGrid>
typedef Dune::cpgrid::Cell2FacesContainer Type;
};
/// \brief An iterator over the cell volumes.
template<const Dune::FieldVector<double, 3>& (Dune::CpGrid::*Method)(int)const>
template<Dune::FieldVector<double, 3> (Dune::CpGrid::*Method)(int)const>
class CpGridCentroidIterator
: public Dune::RandomAccessIteratorFacade<CpGridCentroidIterator<Method>, Dune::FieldVector<double, 3>,
const Dune::FieldVector<double, 3>&, int>
Dune::FieldVector<double, 3>, int>
{
public:
/// \brief Creates an iterator.
Expand All @@ -341,15 +341,15 @@ class CpGridCentroidIterator
: grid_(&grid), cell_index_(cell_index)
{}

const Dune::FieldVector<double, 3>& dereference() const
Dune::FieldVector<double, 3> dereference() const
{
return std::mem_fn(Method)(*grid_, cell_index_);
}
void increment()
{
++cell_index_;
}
const Dune::FieldVector<double, 3>& elementAt(int n) const
Dune::FieldVector<double, 3> elementAt(int n) const
{
return std::mem_fn(Method)(*grid_, n);
}
Expand Down Expand Up @@ -430,7 +430,7 @@ double cellCentroidCoordinate(const Dune::CpGrid& grid, int cell_index,
/// \brief Get the centroid of a cell.
/// \param grid The grid whose cell centroid we query.
/// \param cell_index The index of the corresponding cell.
const double* cellCentroid(const Dune::CpGrid& grid, int cell_index);
Vector cellCentroid(const Dune::CpGrid& grid, int cell_index);

/// \brief Get vertical position of cell center ("zcorn" average).
/// \brief grid The grid.
Expand Down Expand Up @@ -531,8 +531,7 @@ beginFaceCentroids(const Dune::CpGrid& grid);
/// \param grid The grid.
/// \param face_index The index of the specific face.
/// \param coordinate The coordinate index.
const FaceCentroidTraits<Dune::CpGrid>::ValueType&
faceCentroid(const Dune::CpGrid& grid, int face_index);
Vector faceCentroid(const Dune::CpGrid& grid, int face_index);

template<>
struct FaceCellTraits<Dune::CpGrid>
Expand All @@ -559,9 +558,9 @@ face2Vertices(const Dune::CpGrid& grid);
/// \brief Get the coordinates of a vertex of the grid.
/// \param grid The grid the vertex is part of.
/// \param index The index identifying the vertex.
const double* vertexCoordinates(const Dune::CpGrid& grid, int index);
Vector vertexCoordinates(const Dune::CpGrid& grid, int index);

const double* faceNormal(const Dune::CpGrid& grid, int face_index);
Vector faceNormal(const Dune::CpGrid& grid, int face_index);

double faceArea(const Dune::CpGrid& grid, int face_index);

Expand Down
4 changes: 2 additions & 2 deletions opm/grid/cpgrid/Intersection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace Dune
/// @brief
/// @todo Doc me!
/// @return
const LocalGeometry& geometryInInside() const
LocalGeometry geometryInInside() const
{
OPM_THROW(std::runtime_error, "This intersection class does not support geometryInInside().");
}
Expand All @@ -171,7 +171,7 @@ namespace Dune
/// @brief
/// @todo Doc me!
/// @return
const LocalGeometry& geometryInOutside() const
LocalGeometry geometryInOutside() const
{
if (boundary()) {
OPM_THROW(std::runtime_error, "Cannot access geometryInOutside(), intersection is at a boundary.");
Expand Down
Loading