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

refactor: FieldSpecification context when targeting wrong fieldName #3508

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

Conversation

arng40
Copy link
Contributor

@arng40 arng40 commented Jan 6, 2025

Here's the typical error encountered when setting the wrong target for a FieldSpecification :

Importing field Perm into rockPerm_permeability on Reservoir/2_tetrahedra
Importing field porosity into rockPorosity_referencePorosity on Reservoir/2_tetrahedra
 
***** LOCATION: /path/to/GEOS/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp:208
***** Controlling expression (should be false): true
***** Rank 17:
bcTemperatureAquiferBottom/fieldName (compressible_base_injection_well.xml, l.246): there is no fieldName named `rock_initialPorosity` under the objectPath `ElementRegions/aquiferBottom`.
 
 
** StackTrace of 5 frames **
Frame 0: geos::FieldSpecificationManager::validateBoundaryConditions(geos::MeshLevel&) const
[...]
=====

Here we wanted to define initial conditions in FieldSpecifications to impose the value of a property (here: “rock_initialPorosity”).
However, this property doesn't exist because we've given it the wrong name. It expects the name of the Porosity model for stress (i.e. “rockPorosity_initialPorosity” here).

With more indications we would have (in progress)

***** LOCATION: /path/to/GEOS/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp:228
***** Controlling expression (should be false): true
***** Rank 0: 
bcTemperatureAquiferBottom/fieldName (thermalLeakyWell_base_iterative.xml, l.179): there is no fieldName named `rock_initialPorosity` under the objectPath `ElementRegions/aquiferBottom`.
Available fields in ElementRegions/aquiferBottom are:
localToGlobalMap globalToLocalMap isExternal ghostRank domainBoundaryIndicator localMaxGlobalIndex maxGlobalIndex numNodesPerElement numEdgesPerElement numFacesPerElement elementCenter elementVolume nodeList edgeList faceList ConstitutiveGrouping ConstitutivePointVolumeFraction dNdX detJ ToEmbeddedSurfaces fracturedCells bubbleCells toFaceElements fluid_phaseFraction fluid_dPhaseFraction fluid_phaseDensity fluid_phaseDensity_n fluid_dPhaseDensity fluid_phaseMassDensity fluid_dPhaseMassDensity fluid_phaseViscosity fluid_dPhaseViscosity fluid_phaseEnthalpy 
fluid_phaseEnthalpy_n fluid_dPhaseEnthalpy fluid_phaseInternalEnergy fluid_phaseInternalEnergy_n fluid_dPhaseInternalEnergy fluid_phaseCompFraction fluid_phaseCompFraction_n fluid_dPhaseCompFraction fluid_totalDensity fluid_totalDensity_n fluid_dTotalDensity rockPorosity_porosity rockPorosity_porosity_n rockPorosity_dPorosity_dPressure rockPorosity_dPorosity_dTemperature rockPorosity_initialPorosity rockPorosity_referencePorosity rockPerm_permeability rockPerm_dPerm_dPressure relperm_phaseRelPerm relperm_dPhaseRelPerm_dPhaseVolFraction relperm_phaseTrappedVolFraction relperm_phaseRelPerm_n cappres_phaseCapPressure cappres_dPhaseCapPressure_dPhaseVolFraction fluidNames solidNames permeabilityNames relPermNames gravityCoefficient
 netToGross pressure pressure_n initialPressure deltaPressure bcPressure temperature temperature_n initialTemperature bcTemperature capPressureNames pressureScalingFactor temperatureScalingFactor globalCompDensityScalingFactor globalCompDensity globalCompDensity_n globalCompFraction dGlobalCompFraction_dGlobalCompDensity phaseVolumeFraction dPhaseVolumeFraction phaseMobility dPhaseMobility phaseVolumeFraction_n compAmount compAmount_n phaseOutflux componentOutflux phaseCFLNumber componentCFLNumber 

** StackTrace of 5 frames **
Frame 0: geos::FieldSpecificationManager::validateBoundaryConditions(geos::MeshLevel&) const 
Frame 1: geos::ProblemManager::applyInitialConditions() 
Frame 2: geos::GeosxState::applyInitialConditions() 
Frame 3: main 

@arng40 arng40 self-assigned this Jan 6, 2025
@arng40 arng40 added the type: feature New feature or request label Jan 6, 2025
@arng40 arng40 linked an issue Jan 6, 2025 that may be closed by this pull request
9 tasks
@arng40 arng40 requested a review from MelReyCG January 6, 2025 09:55
@arng40 arng40 changed the title FieldSpecification msg when targeting the wrong fieldName FieldSpecification message when targeting wrong fieldName Jan 6, 2025
@arng40 arng40 changed the title FieldSpecification message when targeting wrong fieldName FieldSpecification context when targeting wrong fieldName Jan 6, 2025
@arng40 arng40 marked this pull request as ready for review January 6, 2025 14:23
@arng40 arng40 changed the title FieldSpecification context when targeting wrong fieldName refactor: FieldSpecification context when targeting wrong fieldName Jan 6, 2025
@arng40 arng40 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 Jan 10, 2025
Comment on lines +197 to +203
std::string fieldNamePath =
GEOS_FMT( "\n{}: there is no {} named `{}` under the {} `{}`.\n",
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
FieldSpecificationBase::viewKeyStruct::fieldNameString(),
fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() );
fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath());

fieldNameNotFoundMessage << fieldNamePath;
Copy link
Contributor

Choose a reason for hiding this comment

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

      fieldNameNotFoundMessage <<
        GEOS_FMT( "\n{}: there is no {} named `{}` under the {} `{}`.\n",
                  fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
                  FieldSpecificationBase::viewKeyStruct::fieldNameString(),
                  fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath());

for( auto const & wrapperIter : subCellRegion.wrappers() )
{
auto const & wrapper = wrapperIter.second;
fieldNameNotFoundMessage << wrapper->getName() << " ";
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a comma here

Suggested change
fieldNameNotFoundMessage << wrapper->getName() << " ";
fieldNameNotFoundMessage << wrapper->getName() << ", ";

Comment on lines 215 to 216
if( stopIteration )
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure that, by exiting the iteration process, you gather all possible field name?
I'm not sure that all region contains the same set of fields.

Maybe it would be safer to gather them all in a std::set<string>, then output them all (it would also have the benefit to sort them).

Comment on lines 221 to 224
for( auto const & wrapperIter : subCellRegion.wrappers() )
{
auto const & wrapper = wrapperIter.second;
fieldNameNotFoundMessage << wrapper->getName() << " ";
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you are assuming that all sub-region wrappers are wrappers of fields, but they are not all! localToGlobalMap globalToLocalMap isExternal ghostRank, those are attributes not related to mesh fields.
Here is an exemple of fields declaration: src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp
The goal is to output only fields in this error output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[EPIC] Improve feedback to user on XML errors
2 participants