Skip to content

feat: encountered negative pressure/density cells summary output#3677

Open
MelReyCG wants to merge 75 commits intodevelopfrom
feature/rey/negative-pressure-cells
Open

feat: encountered negative pressure/density cells summary output#3677
MelReyCG wants to merge 75 commits intodevelopfrom
feature/rey/negative-pressure-cells

Conversation

@MelReyCG
Copy link
Contributor

@MelReyCG MelReyCG commented May 20, 2025

This PR aims at adding a partial logging of the element ids that have negative pressures / densities, to allow the user to quickly see where negative pressure / densities are computed.
To enable the output, it is proposed to set the logLevel at least to 2 on the flow solver.

Here is an exemple of an output (from a synthetic case):

        compflow: 8 negative pressure values encountered. Minimum value: -126475.570 [Pa].
                  ---------------------------------------------------
                  |      Summary of negative pressure elements      |
                  |-------------------------------------------------|
                  |--------------Rank 0, 2 / 2 values---------------|
                  |     Global Id |              0 |          13200 |
                  | pressure [Pa] | -126475.570318 | -126475.570318 |
                  |               |                |                |
                  |--------------Rank 2, 2 / 2 values---------------|
                  |     Global Id |          13140 |          26340 |
                  | pressure [Pa] | -126475.570318 | -126475.570318 |
                  |               |                |                |
                  |--------------Rank 3, 2 / 2 values---------------|
                  |     Global Id |             59 |          13259 |
                  | pressure [Pa] | -126475.570318 | -126475.570318 |
                  |               |                |                |
                  |--------------Rank 5, 2 / 2 values---------------|
                  |     Global Id |          13199 |          26399 |
                  | pressure [Pa] | -126475.570318 | -126475.570318 |
                  |               |                |                |
                  ---------------------------------------------------

A standard component is proposed to do so this kind of "limited kernel output": the ElementReporterOutput & . Its goal is to:

  • ElementReporterBuffer, allocate global memory & be able to disable the whole system (ie: by a logLevel),
  • ElementReporterCollector, manage the atomic counting & collection of elements,
  • ElementReporterOutput, output the result (i.e. in the log),
    If the number of reported elements exceed the rank ElementReporterBuffer size, the row ends with ..., but the elements still gets counted.

This table has been drawn by the new TableTextMpiOutput (also proposed in this PR), which allows to draw a single table on the rank 0 from multiple ranks:

        TableLayout const layout = TableLayout().
                                     setTitle( GEOS_FMT( "Summary of {} elements", valueNaming ) ).
        TableData data;
        
        // new TableMpiLayout for customization
        TableMpiLayout mpiLayout;
        mpiLayout.m_separatorBetweenRanks = true; // visually separate each ranks data

        if( signaledCount > 0 ) // <- if some ranks have an empty TableData, they will be ignored
        {
          // title of each rank table part
          mpiLayout.m_rankTitle = GEOS_FMT( "Rank {}, {} / {} values",
                                            MpiWrapper::commRank(), collectedCount, signaledCount );

          // filling rank data...
          data.addRow( stdVector< TableData::CellData >( tableColumnsCount, { CellType::MergeNext, "" } ) );
          cells[globalIdLine].front() = { CellType::Value, "Global Id" };
          // [...]
        }

        // draw the ranks table
        TableTextMpiOutput const formatter = TableTextMpiOutput( layout, mpiLayout );
        formatter.toStream( std::cout, data );

@MelReyCG MelReyCG self-assigned this May 20, 2025
@MelReyCG MelReyCG added the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label May 20, 2025
Copy link
Collaborator

@paveltomin paveltomin left a comment

Choose a reason for hiding this comment

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

looks ok, hopefully no performance impact

@paveltomin paveltomin added type: feature New feature or request flag: no rebaseline Does not require rebaseline and removed ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI ci: run code coverage enables running of the code coverage CI jobs labels Aug 6, 2025
@MelReyCG MelReyCG requested a review from rasimHZ as a code owner August 26, 2025 08:46
@paveltomin paveltomin requested a review from Copilot August 26, 2025 14:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the flow solver's error reporting capabilities by adding detailed logging of element IDs that exhibit negative pressures or densities. The implementation introduces a new component ElementsReporterOutput to manage limited collection and reporting of problematic elements, with configurable output detail level controlled by log levels.

  • Implements a buffer-based collection system to track and report negative pressure/density elements
  • Replaces simple counter-based negative value reporting with detailed element-specific information
  • Adds MPI-distributed table formatting capabilities for consistent multi-rank output

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
SolutionCheckHelpers.hpp/.cpp Core implementation of element reporting buffer and output system
SolutionCheckKernelsHelpers.hpp Helper classes for element collection in CUDA kernels
SinglePhaseBase.cpp, SinglePhaseWell.cpp, CompositionalMultiphaseWell.cpp, CompositionalMultiphaseFVM.cpp Integration of new reporting system into existing solvers
kernels/singlePhase/SolutionCheckKernel.hpp, kernels/compositional/*.hpp Kernel updates to use new element collection mechanism
TableMpiComponents.hpp/.cpp New MPI-aware table formatting system
TableLayout.hpp/.cpp, TableFormatter.hpp/.cpp, TableData.hpp/.cpp Table formatting enhancements
LogLevelsInfo.hpp, wells/LogLevelsInfo.hpp Addition of new log level for solution details

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MelReyCG MelReyCG added ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI labels Nov 4, 2025
@MelReyCG
Copy link
Contributor Author

MelReyCG commented Nov 4, 2025

@paveltomin I did a benchmark with a real case of 1M+ cells, with the different logLevel values (0, 1, 2), on CPU & GPU. This PR has no detectable performance impact.

@MelReyCG MelReyCG added the ci: run code coverage enables running of the code coverage CI jobs label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run code coverage enables running of the code coverage CI jobs ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants