#3185 Use std::array instead of FixedArray

This commit is contained in:
Magne Sjaastad 2018-08-07 10:07:42 +02:00
parent 371969db3c
commit aeae19c748
8 changed files with 51 additions and 46 deletions

View File

@ -85,8 +85,12 @@ void RivEclipseIntersectionGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d
//--------------------------------------------------------------------------------------------------
void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const
{
const caf::SizeTArray8& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices();
memcpy(cornerIndices, cornerIndicesSource.data(), 8 * sizeof(size_t));
const std::array<size_t, 8>& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices();
for (size_t i = 0; i < 8; i++)
{
cornerIndices[i] = cornerIndicesSource[i];
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ public:
m_baseK(baseK)
{}
const caf::SizeTArray8* neighborIndices(int offsetI, int offsetJ, int offsetK)
const std::array<size_t, 8>* neighborIndices(int offsetI, int offsetJ, int offsetK)
{
if (offsetI < 0 && m_baseI == 0) return nullptr;
if (offsetJ < 0 && m_baseJ == 0) return nullptr;
@ -88,35 +88,35 @@ void RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell(const RigMainGrid
// 6 <- PI[7] PIPJ[4] PJ[5] PK[2] PIPK[3] PIPJPK[0] PJPK[1]
// 7 <- PJ[4] NIPJ[5] NI[6] PK[3] PJPK[0] NIPJPK[1] NIPK[2]
const caf::SizeTArray8* IJK = nbFinder.neighborIndices( 0, 0, 0);
const caf::SizeTArray8* NI = nbFinder.neighborIndices(-1, 0, 0);
const caf::SizeTArray8* NJ = nbFinder.neighborIndices( 0,-1, 0);
const caf::SizeTArray8* PI = nbFinder.neighborIndices( 1, 0, 0);
const caf::SizeTArray8* PJ = nbFinder.neighborIndices( 0, 1, 0);
const caf::SizeTArray8* NK = nbFinder.neighborIndices( 0, 0,-1);
const caf::SizeTArray8* PK = nbFinder.neighborIndices( 0, 0, 1);
const caf::SizeTArray8* NINJ = nbFinder.neighborIndices(-1,-1, 0);
const caf::SizeTArray8* PINJ = nbFinder.neighborIndices( 1,-1, 0);
const std::array<size_t, 8>* IJK = nbFinder.neighborIndices( 0, 0, 0);
const std::array<size_t, 8>* NI = nbFinder.neighborIndices(-1, 0, 0);
const std::array<size_t, 8>* NJ = nbFinder.neighborIndices( 0,-1, 0);
const std::array<size_t, 8>* PI = nbFinder.neighborIndices( 1, 0, 0);
const std::array<size_t, 8>* PJ = nbFinder.neighborIndices( 0, 1, 0);
const std::array<size_t, 8>* NK = nbFinder.neighborIndices( 0, 0,-1);
const std::array<size_t, 8>* PK = nbFinder.neighborIndices( 0, 0, 1);
const std::array<size_t, 8>* NINJ = nbFinder.neighborIndices(-1,-1, 0);
const std::array<size_t, 8>* PINJ = nbFinder.neighborIndices( 1,-1, 0);
const caf::SizeTArray8* PIPJ = nbFinder.neighborIndices( 1, 1, 0);
const caf::SizeTArray8* NIPJ = nbFinder.neighborIndices(-1, 1, 0);
const caf::SizeTArray8* NINK = nbFinder.neighborIndices(-1, 0,-1);
const caf::SizeTArray8* NJNK = nbFinder.neighborIndices( 0,-1,-1);
const caf::SizeTArray8* PINK = nbFinder.neighborIndices( 1, 0,-1);
const caf::SizeTArray8* PJNK = nbFinder.neighborIndices( 0, 1,-1);
const caf::SizeTArray8* NIPK = nbFinder.neighborIndices(-1, 0, 1);
const caf::SizeTArray8* NJPK = nbFinder.neighborIndices( 0,-1, 1);
const caf::SizeTArray8* PIPK = nbFinder.neighborIndices( 1, 0, 1);
const std::array<size_t, 8>* PIPJ = nbFinder.neighborIndices( 1, 1, 0);
const std::array<size_t, 8>* NIPJ = nbFinder.neighborIndices(-1, 1, 0);
const std::array<size_t, 8>* NINK = nbFinder.neighborIndices(-1, 0,-1);
const std::array<size_t, 8>* NJNK = nbFinder.neighborIndices( 0,-1,-1);
const std::array<size_t, 8>* PINK = nbFinder.neighborIndices( 1, 0,-1);
const std::array<size_t, 8>* PJNK = nbFinder.neighborIndices( 0, 1,-1);
const std::array<size_t, 8>* NIPK = nbFinder.neighborIndices(-1, 0, 1);
const std::array<size_t, 8>* NJPK = nbFinder.neighborIndices( 0,-1, 1);
const std::array<size_t, 8>* PIPK = nbFinder.neighborIndices( 1, 0, 1);
const caf::SizeTArray8* PJPK = nbFinder.neighborIndices( 0, 1, 1);
const caf::SizeTArray8* NINJNK = nbFinder.neighborIndices(-1,-1,-1);
const caf::SizeTArray8* PINJNK = nbFinder.neighborIndices( 1,-1,-1);
const caf::SizeTArray8* PIPJNK = nbFinder.neighborIndices( 1, 1,-1);
const caf::SizeTArray8* NIPJNK = nbFinder.neighborIndices(-1, 1,-1);
const caf::SizeTArray8* NINJPK = nbFinder.neighborIndices(-1,-1, 1);
const caf::SizeTArray8* PINJPK = nbFinder.neighborIndices( 1,-1, 1);
const caf::SizeTArray8* PIPJPK = nbFinder.neighborIndices( 1, 1, 1);
const caf::SizeTArray8* NIPJPK = nbFinder.neighborIndices(-1, 1, 1);
const std::array<size_t, 8>* PJPK = nbFinder.neighborIndices( 0, 1, 1);
const std::array<size_t, 8>* NINJNK = nbFinder.neighborIndices(-1,-1,-1);
const std::array<size_t, 8>* PINJNK = nbFinder.neighborIndices( 1,-1,-1);
const std::array<size_t, 8>* PIPJNK = nbFinder.neighborIndices( 1, 1,-1);
const std::array<size_t, 8>* NIPJNK = nbFinder.neighborIndices(-1, 1,-1);
const std::array<size_t, 8>* NINJPK = nbFinder.neighborIndices(-1,-1, 1);
const std::array<size_t, 8>* PINJPK = nbFinder.neighborIndices( 1,-1, 1);
const std::array<size_t, 8>* PIPJPK = nbFinder.neighborIndices( 1, 1, 1);
const std::array<size_t, 8>* NIPJPK = nbFinder.neighborIndices(-1, 1, 1);
std::vector<size_t> contributingNodeIndicesPrCellCorner[8];
@ -432,7 +432,7 @@ if ( ( (es.x() + xyTolerance) >= cs.x() && (el.x() - xyTolerance) <= cl.x())
{
const std::vector<cvf::Vec3d>& eclNodes = eclGrid->nodes();
const RigCell& cell = eclGrid->cells()[reservoirCellIndex];
const caf::SizeTArray8& cornerIndices = cell.cornerIndices();
const std::array<size_t, 8>& cornerIndices = cell.cornerIndices();
int faceNodeCount;
const int* localElmNodeIndicesForTopZFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, 4, &faceNodeCount);
const int* localElmNodeIndicesForBotZFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, 5, &faceNodeCount);

View File

@ -20,8 +20,10 @@
#pragma once
#include "RigLocalGrid.h"
#include "cvfStructGrid.h"
#include "cafFixedArray.h"
#include <array>
namespace cvf
{
@ -36,8 +38,9 @@ public:
RigCell();
~RigCell(); // Not virtual, to save space. Do not inherit from this class
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
std::array<size_t, 8>& cornerIndices() { return m_cornerIndices;}
const std::array<size_t, 8>& cornerIndices() const { return m_cornerIndices;}
void faceIndices(cvf::StructGridInterface::FaceType face, caf::SizeTArray4 * faceIndices) const ;
bool isInvalid() const { return m_isInvalid; }
@ -71,7 +74,7 @@ public:
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
bool isCollapsedCell( double nodeNearTolerance = 1e-3) const;
private:
caf::SizeTArray8 m_cornerIndices;
std::array<size_t, 8> m_cornerIndices;
size_t m_gridLocalCellIndex; ///< This cells index in the grid it belongs to.
RigGridBase* m_hostGrid;

View File

@ -626,17 +626,15 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
}
else
{
std::array<cvf::Vec3d, 8> hexCorners;
for (size_t i = 0; i < m_mainGrid->cellCount(); i++)
{
if (activeInfos[acIdx]->isActive(i))
{
const RigCell& c = m_mainGrid->globalCellArray()[i];
const caf::SizeTArray8& indices = c.cornerIndices();
size_t idx;
for (idx = 0; idx < 8; idx++)
m_mainGrid->cellCornerVertices(i, hexCorners.data());
for (const auto& corner : hexCorners)
{
bb.add(m_mainGrid->nodes()[indices[idx]]);
bb.add(corner);
}
}
}

View File

@ -154,7 +154,7 @@ void RigGridBase::initSubCellsMainGridCellIndex()
//--------------------------------------------------------------------------------------------------
void RigGridBase::cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const
{
const caf::SizeTArray8& indices = cell(cellIndex).cornerIndices();
const std::array<size_t, 8>& indices = cell(cellIndex).cornerIndices();
vertices[0].set(m_mainGrid->nodes()[indices[0]]);
vertices[1].set(m_mainGrid->nodes()[indices[1]]);

View File

@ -597,10 +597,10 @@ void RigMainGrid::buildCellSearchTree()
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
{
const caf::SizeTArray8& cellIndices = m_cells[cIdx].cornerIndices();
if (m_cells[cIdx].isInvalid()) continue;
const std::array<size_t, 8>& cellIndices = m_cells[cIdx].cornerIndices();
cvf::BoundingBox& cellBB = cellBoundingBoxes[cIdx];
cellBB.add(m_nodes[cellIndices[0]]);
cellBB.add(m_nodes[cellIndices[1]]);

View File

@ -222,7 +222,7 @@ void RigReservoirBuilderMock::populateReservoir(RigEclipseCaseData* eclipseCase)
{
RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[mainGridIndicesWithSubGrid[cellIdx]];
caf::SizeTArray8& indices = cell.cornerIndices();
std::array<size_t, 8>& indices = cell.cornerIndices();
int nodeIdx;
for (nodeIdx = 0; nodeIdx < 8; nodeIdx++)
{

View File

@ -754,7 +754,7 @@ private:
if ( wellCell.isInvalid() ) continue;
const caf::SizeTArray8& cellIndices = wellCell.cornerIndices();
const std::array<size_t, 8>& cellIndices = wellCell.cornerIndices();
cvf::BoundingBox& cellBB = m_cellBoundingBoxes[cIdx];
cellBB.add(nodes[cellIndices[0]]);