-
Notifications
You must be signed in to change notification settings - Fork 102
14345 grid calculation undefined values #14348
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
base: dev
Are you sure you want to change the base?
Changes from all commits
b7803ee
64e1499
d6893ab
0f51362
13d2165
b62540e
07a3973
861ae17
7c4e239
cc215fd
b2b5462
604d498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // Copyright (C) 2026 Equinor ASA | ||
| // | ||
| // ResInsight 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. | ||
| // | ||
| // ResInsight 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 at <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #include "RimCellFilterTools.h" | ||
|
|
||
| #include "RigEclipseCaseData.h" | ||
| #include "RigGridBase.h" | ||
| #include "RigLocalGrid.h" | ||
| #include "RigMainGrid.h" | ||
|
|
||
| #include "RimCellFilter.h" | ||
| #include "RimEclipseCase.h" | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// Evaluate the filter against the given case for all grids, and return the visibility indexed by | ||
| /// reservoir cell index. Property filters are evaluated against the given case's own result values. | ||
| //-------------------------------------------------------------------------------------------------- | ||
| cvf::ref<cvf::UByteArray> | ||
| RimCellFilterTools::computeReservoirCellVisibility( RimCellFilter* filter, RimEclipseCase* eclipseCase, size_t timeStepIndex ) | ||
| { | ||
| if ( !filter || !eclipseCase || !eclipseCase->eclipseCaseData() || !eclipseCase->eclipseCaseData()->mainGrid() ) return nullptr; | ||
|
|
||
| RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); | ||
|
|
||
| cvf::ref<cvf::UByteArray> reservoirVisibility = new cvf::UByteArray( caseData->mainGrid()->totalCellCount() ); | ||
| reservoirVisibility->setAll( false ); | ||
|
|
||
| const bool isInclude = ( filter->filterMode() == RimCellFilter::INCLUDE ); | ||
|
|
||
| // Grid local masks are kept to allow propagation of parent grid visibility into LGRs | ||
| std::vector<cvf::ref<cvf::UByteArray>> gridMasks( caseData->gridCount() ); | ||
|
|
||
| for ( size_t gridIndex = 0; gridIndex < caseData->gridCount(); gridIndex++ ) | ||
| { | ||
| RigGridBase* grid = caseData->grid( gridIndex ); | ||
|
|
||
| gridMasks[gridIndex] = new cvf::UByteArray( grid->cellCount() ); | ||
| cvf::UByteArray& gridMask = *gridMasks[gridIndex]; | ||
| gridMask.setAll( true ); | ||
|
|
||
| if ( filter->isRangeFilter() ) | ||
| { | ||
| // Range filters evaluate only on their target grid. On other grids an INCLUDE filter | ||
| // contributes no cells, while an EXCLUDE filter removes none. | ||
| const bool isTargetGrid = ( filter->gridIndex() == static_cast<int>( gridIndex ) ); | ||
| if ( isTargetGrid ) | ||
| { | ||
| filter->applyToCellVisibility( &gridMask, grid, timeStepIndex, eclipseCase ); | ||
| } | ||
| else | ||
| { | ||
| gridMask.setAll( !isInclude ); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| // Index filters (polygon, user defined) and property filters evaluate on all grids | ||
| filter->applyToCellVisibility( &gridMask, grid, timeStepIndex, eclipseCase ); | ||
| } | ||
|
|
||
| // Cells in LGRs follow the visibility of their parent grid cell, as in the filtered geometry | ||
| // of a 3d view. Geometry based filters (range and index, e.g. an INDEX_K polygon) can fail to | ||
| // select the refined cells directly on a fine LGR, so propagate the parent grid visibility. | ||
| // Property filters evaluate each cell against its own result value and must be left untouched. | ||
| const bool isGeometryFilter = filter->isRangeFilter() || filter->isIndexFilter(); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: |
||
| if ( isGeometryFilter && !grid->isMainGrid() ) | ||
| { | ||
| auto localGrid = static_cast<const RigLocalGrid*>( grid ); | ||
| const cvf::UByteArray& parentMask = *gridMasks[localGrid->parentGrid()->gridIndex()]; | ||
|
|
||
| for ( size_t localIdx = 0; localIdx < grid->cellCount(); localIdx++ ) | ||
| { | ||
| const size_t parentCellIndex = grid->cell( localIdx ).parentCellIndex(); | ||
| if ( isInclude ) | ||
| { | ||
| gridMask[localIdx] = gridMask[localIdx] || parentMask[parentCellIndex]; | ||
| } | ||
| else | ||
| { | ||
| gridMask[localIdx] = gridMask[localIdx] && parentMask[parentCellIndex]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for ( size_t localIdx = 0; localIdx < grid->cellCount(); localIdx++ ) | ||
| { | ||
| reservoirVisibility->set( grid->reservoirCellIndex( localIdx ), gridMask[localIdx] ); | ||
| } | ||
| } | ||
|
|
||
| return reservoirVisibility; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // Copyright (C) 2026 Equinor ASA | ||
| // | ||
| // ResInsight 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. | ||
| // | ||
| // ResInsight 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 at <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "cvfArray.h" | ||
| #include "cvfObject.h" | ||
|
|
||
| class RimCellFilter; | ||
| class RimEclipseCase; | ||
|
|
||
| //================================================================================================== | ||
| /// | ||
| //================================================================================================== | ||
| class RimCellFilterTools | ||
| { | ||
| public: | ||
| static cvf::ref<cvf::UByteArray> computeReservoirCellVisibility( RimCellFilter* filter, RimEclipseCase* eclipseCase, size_t timeStepIndex ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,10 @@ void RimCombinedFilter::onGridChanged() | |
| /// INCLUDE/EXCLUDE mode inside applyToCellVisibility), AND/OR combine the masks, then apply this | ||
| /// combined filter's INCLUDE/EXCLUDE mode onto the incoming cellVisibility. | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RimCombinedFilter::applyToCellVisibility( cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex ) | ||
| void RimCombinedFilter::applyToCellVisibility( cvf::UByteArray* cellVisibility, | ||
| const RigGridBase* grid, | ||
| size_t timeStepIndex, | ||
| RimEclipseCase* sourceCaseOverride ) | ||
| { | ||
| if ( cellVisibility == nullptr || grid == nullptr ) return; | ||
|
|
||
|
|
@@ -125,7 +128,7 @@ void RimCombinedFilter::applyToCellVisibility( cvf::UByteArray* cellVisibility, | |
| { | ||
| cvf::UByteArray childMask( n ); | ||
| childMask.setAll( 1 ); | ||
| child->applyToCellVisibility( &childMask, grid, timeStepIndex ); | ||
| child->applyToCellVisibility( &childMask, grid, timeStepIndex, sourceCaseOverride ); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important: An INCLUDE range child produces the wrong mask on grids other than its target grid. |
||
|
|
||
| if ( m_combineMode() == CombineMode::AND ) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important: Please handle
!filter->isFilterEnabled()before evaluating the selected data filter. Property filters currently no-op when unchecked, but base range/index filters andRimCombinedFilterdo not check their own active state, so an unchecked range or combined filter still changes the calculation. This makes filter activation behave differently depending on filter type.