Skip to content
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

feat: Simplify region statistics output in HDF5 #3314

Open
wants to merge 132 commits into
base: develop
Choose a base branch
from

Conversation

arng40
Copy link
Contributor

@arng40 arng40 commented Aug 29, 2024

this PR is based on the work of @wrtobin & @untereiner : Memory Space Aware Packing , Export info embedded on regions

With the current impl, in order to output region statistics we would have to create :

  • 1 <CompositionalMultiphaseStatistics> component + 1 <PeriodicEvent>
  • 1 <TimeHistory> per region with each desired statistics fields (hidden to the user) + 1 <periodicEvent> per <TimeHistory>
  • 1 <PackCollection> per field and 1 <PeriodicEvent> per <packCollection>
    With multiple regions this could easily lead to hundred of components to create and maintain manually
<Tasks>

    <CompositionalMultiphaseStatistics
      name="compflowStatistics"
      flowSolverName="compflow"
      logLevel="1"
      computeCFLNumbers="1"
      computeRegionStatistics="1"/>

    <PackCollection
      name="pressureRegion1Collection"
      objectPath="Path/to/field/"
      fieldName="pressure"/>
[Omitting around 18 fields X 3 regions ...]
    <PackCollection
      name="minTRegion1Collection"
      objectPath="Path/to/field/"
      fieldName="minT"/>

</Tasks>
 <Outputs>

    <TimeHistory
      name="timeHistoryOutput"
      sources="{ Path/toregionA/field }"
      filename="outputRegions"/>
[Omitting 2 regions ...]
    <TimeHistory
      name="timeHistoryOutput"
      sources="{ Path/toregionD/field }"
      filename="outputRegions"/>

  </Outputs>
<Events>

    <PeriodicEvent
      name="statComputeEvent"
      forceDt="1e6"
      target="/Tasks/compflowStatistics"/> 

    <PeriodicEvent
      name="pressureCollectionEvent"
      forceDt="1e6"
      target="/Tasks/pressureRegion1Collection"/>
[Omitting around 18 fields X 3 regions ...]
    <PeriodicEvent
      name="pressureCollectionEvent"
      forceDt="1e6"
      target="/Tasks/minTRegion1Collection"/>

    <PeriodicEvent
      name="statOutputEvent"
      forceDt="1e6"
      target="/Output/timeHistoryOutput"/>

</Events>

With the controller component proposed in this PR, we would have all <PackCollection>, <TimeHistory> and their <PeriodicEvent> automatically created / managed :

<Problem>
     
  <Solvers>
    <CompositionalMultiphaseFVM
      name="compflow"
      logLevel="1"
      [...]
      />
    </CompositionalMultiphaseFVM>
  </Solvers>    

  <Events
    maxTime="8.64e6">
    <PeriodicEvent
      name="statistics"
      timeFrequency="1e6"
      target="/Tasks/statController"/>
  </Events>

  <Tasks>
    <StatOutputController name="statController" >
      <CompositionalMultiphaseStatistics
        name="compflowStatistics"
        flowSolverName="compflow"
        logLevel="1"
        computeCFLNumbers="1"
        computeRegionStatistics="1"
      />
    </StatOutputController>

  </Tasks>
  
</Problem>

for( string const & regionName : regionNames )
{
ElementRegionBase & region = elemManager.getRegion( regionName );
string const regionStatPath = GEOS_FMT( "{}/regionStatistics", region.getPath() );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should use a viewKey here.

Copy link
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

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

minor last comments

@@ -270,7 +364,7 @@ void CompositionalMultiphaseStatistics::computeRegionStatistics( real64 const ti
array1d< real64 > subRegionTrappedPhaseMass( numPhases );
array1d< real64 > subRegionImmobilePhaseMass( numPhases );
array1d< real64 > subRegionRelpermPhaseMass( numPhases );
array2d< real64 > subRegionComponentMass( numPhases, numComps );
array2d< real64 > subRegiondissolvedComponentMass( numPhases, numComps );
Copy link
Contributor

Choose a reason for hiding this comment

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

camelCase

{
ElementRegionBase & region = elemManager.getRegion( regionName );
string const regionStatPath = GEOS_FMT( "{}/{}", region.getPath(),
SinglePhaseStatistics::viewKeyStruct::regionStatisticsString() );
Copy link
Contributor

Choose a reason for hiding this comment

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

You can move this viewKey in FieldStatisticsBase if you add a comment on it to say it only exists for statistics that are computed for regions.

GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::Statistics,
GEOS_FMT( "{} Mobile phase mass (metric 2): {} {}",
statPrefix, mobilePhaseMass, massUnit ) );
statPrefix, mobilePhaseMass, massUnit ));

GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::Statistics,
GEOS_FMT( "{} Component mass: {} {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should let appear the "dissolved" term in the logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes XML input ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use data tables for log, and CSV / HDF5 to output statistics
6 participants