Skip to content

[LGR] Aquifer cells/connections refinement is not supported or ignored for CpGrid#1008

Open
aritorto wants to merge 4 commits intoOPM:masterfrom
aritorto:skipAquConn
Open

[LGR] Aquifer cells/connections refinement is not supported or ignored for CpGrid#1008
aritorto wants to merge 4 commits intoOPM:masterfrom
aritorto:skipAquConn

Conversation

@aritorto
Copy link
Member

@aritorto aritorto commented Mar 16, 2026

Local Grid Refinement (LGR) in CpGrid does not support refinement of aquifer cells or cells that have neighboring aquifer connections.

The following methods will throw an exception if aquifer cells or aquifer connections occur inside an LGR region:

  • CpGrid::addLgrsUpdateLeafView(...) (used by the CARFIN keyword)
  • CpGrid::autoRefine(...) (used by the AUTOREF keyword)

In contrast, DUNE Grid refinement methods:

  • CpGrid::globalRefine(...)
  • CpGrid::adapt()

ignore aquifer cells and aquifer connections during refinement and perform the refinement only on the remaining cells.

Additionally, and unrelated to aquifer cells/connections, a small refactor was implemented to reduce code duplication across LGR tests. This introduces a new method createGridFromDeck and its usage in a few tests.

@aritorto aritorto added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Mar 16, 2026
@aritorto
Copy link
Member Author

jenkins build this serial please

@aritorto aritorto force-pushed the skipAquConn branch 2 times, most recently from fe14642 to f5726fa Compare March 17, 2026 14:34
@aritorto
Copy link
Member Author

jenkins build this serial please

Comment on lines +2276 to +2291
bool throwIfAquiferCell(const std::vector<int>& levelAquiferCells,
const Dune::cpgrid::Entity<0>& element,
bool throwOnFailure)
{
if (!levelAquiferCells.empty()) {
bool isAquifer = std::ranges::find(levelAquiferCells, element.getLevelElem().index()) != levelAquiferCells.end();
if (isAquifer) {
if (throwOnFailure)
OPM_THROW(std::invalid_argument, "Refinement of aquifer cells is not supported, yet.");
else
return false;
}
}
return true;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unused. Should we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I missed that


#include <config.h>

#define NVERBOSE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Member Author

@aritorto aritorto Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. I’m not sure what it’s for. It’s a leftover (copy-paste issue) from older tests and shouldn’t be here. I’ll remove it.


grid.globalRefine(2);

Opm::checkGridWithLgrs(grid,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we check that cells connected to aquifer are not refined?

grid.adapt();
grid.postAdapt();

Opm::checkGridWithLgrs(grid,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


grid.processEclipseFormat(&eclipse_grid, &ecl_state, false, false, false);
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not waste too much time on this comment of mine, but I think the next function should also be inside the #if ... #endif

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Now both methods are guarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants