Skip to content

Group species for temporals#591

Merged
baperry2 merged 14 commits intoAMReX-Combustion:developmentfrom
SreejithNREL:GroupSpeciesBpatch
Nov 17, 2025
Merged

Group species for temporals#591
baperry2 merged 14 commits intoAMReX-Combustion:developmentfrom
SreejithNREL:GroupSpeciesBpatch

Conversation

@SreejithNREL
Copy link
Copy Markdown
Collaborator

At times, we may need to monitor the combined mass flow rates of a set of species through temporals. For example, we might be interested to monitor the mass flow rate of air through a boundary patch 'inlet'. Currently, the code outputs the MFRs of O2 and N2 separately when the user specifies O2 and N2 in the species list of the bpatch functionality as,

bpatch.inlet.species= O2 N2

This PR lets the user specify a mixture and group species in it in the following way:

bpatch.inlet.species= {Air:O2,N2}

The temporal then outputs the total air MFR under the column 'inlet_Air'.

Copy link
Copy Markdown
Contributor

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 adds functionality to group multiple species together for combined mass flow rate monitoring through temporal diagnostics. Instead of separately tracking species like O2 and N2, users can now define a mixture (e.g., {Air:O2,N2}) to monitor the total combined mass flow rate.

Key changes:

  • Extended BPatch to support species groups with new data structures (groupNames, speciesinGroup, num_groups)
  • Updated temporal output to sum fluxes across grouped species
  • Added documentation and examples for the new grouping syntax

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
Source/PeleLMeX_BPatch.H Added num_groups field and vectors for storing group names and species-to-group mappings
Source/PeleLMeX_BPatch.cpp Implemented parsing logic for species group syntax {GroupName:Species1,Species2,...} and validation
Source/PeleLMeX_Temporals.cpp Modified output loops to iterate over groups and sum species fluxes for each group
Docs/sphinx/manual/LMeXControls.rst Added documentation and example usage of the species grouping feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +266 to +269
auto it = std::find(names.begin(), names.end(), s);
if (it != names.end()) {
size_t index = std::distance(names.begin(), it);
tmp.push_back(static_cast<int>(index));
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Incorrect indexing: speciesinGroup is being filled with mechanism species indices (from std::distance(names.begin(), it)), but it should contain local species indices (0 to num_species-1). In speciesBalancePatch(), these indices are used to access speciesFlux[s], which is indexed by local species indices, not mechanism indices. This will cause incorrect flux summation or potential out-of-bounds access. To fix: find the position of this species in tmp_species_only and use that index instead.

Copilot uses AI. Check for mistakes.
Comment on lines +294 to +297
while (std::getline(ss, item, ',')) {
auto it = std::find(names.begin(), names.end(), item);
size_t index = std::distance(names.begin(), it);
tmp.push_back(static_cast<int>(index));
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

Incorrect indexing: speciesinGroup is being filled with mechanism species indices (from std::distance(names.begin(), it)), but it should contain local species indices (0 to num_species-1). In speciesBalancePatch(), these indices are used to access speciesFlux[s], which is indexed by local species indices, not mechanism indices. This will cause incorrect flux summation or potential out-of-bounds access. To fix: find the position of each species in tmp_species_only and use that index instead. Also add validation that it != names.end() before computing the distance.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@baperry2 baperry2 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 to me but Copilot has a lot of suggestions on how to add error checking for the string parsing. Look through those and implement any that seem to have a good value/effort ratio. Let me know when you're done and I'll merge.

@baperry2 baperry2 enabled auto-merge (squash) November 17, 2025 19:49
@baperry2 baperry2 merged commit 9798183 into AMReX-Combustion:development Nov 17, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants