Fixed Problem regarding negative riTrans values

The reason was a bit sloppy detection of whether the surface normals was
pointing outwards or inwards in a cell.
The cells can be turned inside out due to depth/Z or mapaxis conditions.
This commit is contained in:
Jacob Støren
2014-09-23 12:24:48 +02:00
parent b58862ad93
commit 6e55ca82e2
8 changed files with 45 additions and 15 deletions

View File

@@ -610,7 +610,7 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
{ {
if (m_rimFaultCollection->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING) if (m_rimFaultCollection->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING)
{ {
if (m_grid->mainGrid()->faceNormalsIsOutwards()) if (m_grid->mainGrid()->isFaceNormalsOutwards())
{ {
return caf::FC_BACK; return caf::FC_BACK;
} }
@@ -621,7 +621,7 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
} }
else if (m_rimFaultCollection->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING) else if (m_rimFaultCollection->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING)
{ {
if (m_grid->mainGrid()->faceNormalsIsOutwards()) if (m_grid->mainGrid()->isFaceNormalsOutwards())
{ {
return caf::FC_FRONT; return caf::FC_FRONT;
} }

View File

@@ -846,7 +846,7 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr
const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo();
const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes(); const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes();
bool isFaceNormalsOutwards = m_ownerMainGrid->faceNormalsIsOutwards(); bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cells().size(); nativeResvCellIndex++) for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cells().size(); nativeResvCellIndex++)
{ {
@@ -990,7 +990,7 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans()
const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo();
const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes(); const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes();
bool isFaceNormalsOutwards = m_ownerMainGrid->faceNormalsIsOutwards(); bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
// NNC calculation // NNC calculation
std::vector<RigConnection>& nncConnections = m_ownerMainGrid->nncData()->connections(); std::vector<RigConnection>& nncConnections = m_ownerMainGrid->nncData()->connections();
@@ -1274,7 +1274,7 @@ void RimReservoirCellResultsStorage::computeRiTRANSbyAreaComponent(const QString
const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo();
const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes(); const std::vector<cvf::Vec3d>& nodes = m_ownerMainGrid->nodes();
bool isFaceNormalsOutwards = m_ownerMainGrid->faceNormalsIsOutwards(); bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards();
for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cells().size(); nativeResvCellIndex++) for (size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cells().size(); nativeResvCellIndex++)
{ {

View File

@@ -351,7 +351,7 @@ cvf::Vec3d RigGridBase::displayModelOffset() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Returns the min size of the I and J charactristic cell sizes /// Returns the min size of the I and J charactristic cell sizes
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double RigGridBase::characteristicIJCellSize() double RigGridBase::characteristicIJCellSize() const
{ {
double characteristicCellSize = HUGE_VAL; double characteristicCellSize = HUGE_VAL;

View File

@@ -60,7 +60,7 @@ public:
void setGridId(int id) { m_gridId = id; } void setGridId(int id) { m_gridId = id; }
int gridId() const { return m_gridId; } int gridId() const { return m_gridId; }
double characteristicIJCellSize(); double characteristicIJCellSize() const;
std::string gridName() const; std::string gridName() const;
void setGridName(const std::string& gridName); void setGridName(const std::string& gridName);

View File

@@ -363,9 +363,39 @@ void RigMainGrid::calculateFaults()
/// The cell is normally inverted due to Depth becoming -Z at import, /// The cell is normally inverted due to Depth becoming -Z at import,
/// but if (only) one of the flipX/Y is done, the cell is back to normal /// but if (only) one of the flipX/Y is done, the cell is back to normal
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigMainGrid::faceNormalsIsOutwards() const bool RigMainGrid::isFaceNormalsOutwards() const
{ {
return m_flipXAxis ^ m_flipYAxis;
for (int gcIdx = 0 ; gcIdx < static_cast<int>(m_cells.size()); ++gcIdx)
{
if (!m_cells[gcIdx].isInvalid())
{
cvf::Vec3d cellCenter = m_cells[gcIdx].center();
cvf::Vec3d faceCenter = m_cells[gcIdx].faceCenter(StructGridInterface::POS_I);
cvf::Vec3d faceNormal = m_cells[gcIdx].faceNormalWithAreaLenght(StructGridInterface::POS_I);
double typicalIJCellSize = characteristicIJCellSize();
double dummy, dummy2, typicalKSize;
characteristicCellSizes(&dummy, &dummy2, &typicalKSize);
if ( (faceCenter - cellCenter).length() > 0.2 * typicalIJCellSize
&& (faceNormal.length() > (0.2 * typicalIJCellSize * 0.2* typicalKSize)))
{
// Cell is assumed ok to use, so calculate whether the normals are outwards or inwards
if ((faceCenter - cellCenter) * faceNormal >= 0)
{
return true;
}
else
{
return false;
}
}
}
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -52,7 +52,7 @@ public:
const cvf::Collection<RigFault>& faults() { return m_faults; } const cvf::Collection<RigFault>& faults() { return m_faults; }
void calculateFaults(); void calculateFaults();
const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const; const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const;
bool faceNormalsIsOutwards() const; bool isFaceNormalsOutwards() const;
void computeCachedData(); void computeCachedData();

View File

@@ -220,7 +220,7 @@ cvf::Vec3d StructGridInterface::displayModelOffset() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize, double* kSize) void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize, double* kSize) const
{ {
CVF_ASSERT(iSize && jSize && kSize); CVF_ASSERT(iSize && jSize && kSize);

View File

@@ -84,7 +84,7 @@ public:
virtual cvf::Vec3d minCoordinate() const = 0; virtual cvf::Vec3d minCoordinate() const = 0;
virtual cvf::Vec3d maxCoordinate() const = 0; virtual cvf::Vec3d maxCoordinate() const = 0;
void characteristicCellSizes(double* iSize, double* jSize, double* kSize); void characteristicCellSizes(double* iSize, double* jSize, double* kSize) const;
virtual cvf::Vec3d displayModelOffset() const; virtual cvf::Vec3d displayModelOffset() const;
@@ -109,9 +109,9 @@ public:
static void neighborIJKAtCellFace(size_t i, size_t j, size_t k, StructGridInterface::FaceType face, size_t* ni, size_t* nj, size_t* nk); static void neighborIJKAtCellFace(size_t i, size_t j, size_t k, StructGridInterface::FaceType face, size_t* ni, size_t* nj, size_t* nk);
private: private:
double m_characteristicCellSizeI; mutable double m_characteristicCellSizeI;
double m_characteristicCellSizeJ; mutable double m_characteristicCellSizeJ;
double m_characteristicCellSizeK; mutable double m_characteristicCellSizeK;
}; };
} // namespace cvf } // namespace cvf