Skip to content

Commit

Permalink
Adding SourceFluxStatistics (#2954)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelReyCG committed Jun 14, 2024
1 parent ee751b0 commit 880d43c
Show file tree
Hide file tree
Showing 41 changed files with 2,508 additions and 161 deletions.
16 changes: 8 additions & 8 deletions src/coreComponents/codingUtilities/UnitTestUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ T expected( T expectedSerial,
constexpr real64 DEFAULT_ABS_TOL = 1E-12;
constexpr real64 DEFAULT_REL_TOL = std::numeric_limits< real64 >::epsilon();

::testing::AssertionResult checkRelativeErrorFormat( const char *, const char *, const char *, const char *,
real64 const v1, real64 const v2, real64 const relTol, real64 const absTol )
inline ::testing::AssertionResult checkRelativeErrorFormat( const char *, const char *, const char *, const char *,
real64 const v1, real64 const v2, real64 const relTol, real64 const absTol )
{
real64 const delta = std::abs( v1 - v2 );
real64 const value = std::max( std::abs( v1 ), std::abs( v2 ) );
Expand All @@ -99,23 +99,23 @@ ::testing::AssertionResult checkRelativeErrorFormat( const char *, const char *,
return ::testing::AssertionSuccess();
}

::testing::AssertionResult checkRelativeErrorFormat( char const * a, char const * b, char const * c,
real64 const v1, real64 const v2, real64 const relTol )
inline ::testing::AssertionResult checkRelativeErrorFormat( char const * a, char const * b, char const * c,
real64 const v1, real64 const v2, real64 const relTol )
{ return checkRelativeErrorFormat( a, b, c, "DEFAULT_ABS_TOL", v1, v2, relTol, DEFAULT_ABS_TOL ); }

void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol )
inline void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol )
{ EXPECT_PRED_FORMAT3( checkRelativeErrorFormat, v1, v2, relTol ); }

void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, real64 const absTol )
inline void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, real64 const absTol )
{ EXPECT_PRED_FORMAT4( checkRelativeErrorFormat, v1, v2, relTol, absTol ); }

void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, string const & name )
inline void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, string const & name )
{
SCOPED_TRACE( name );
EXPECT_PRED_FORMAT3( checkRelativeErrorFormat, v1, v2, relTol );
}

void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, real64 const absTol, string const & name )
inline void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol, real64 const absTol, string const & name )
{
SCOPED_TRACE( name );
EXPECT_PRED_FORMAT4( checkRelativeErrorFormat, v1, v2, relTol, absTol );
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/common/DataTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ rtTypes::RegexMapType rtTypes::createBasicTypesRegexMap()

string_view const groupNameDesc = "Input value must be a string that cannot be empty and contains only upper/lower letters, digits, and the characters . - _";
string_view const groupNameRegex = "[a-zA-Z0-9.\\-_]+";
string_view const groupNameRefDesc = "Input value must be a string that can contain only upper/lower letters, digits, and the characters . - _ /";
string_view const groupNameRefRegex = "[a-zA-Z0-9.\\-_/]*";
string_view const groupNameRefDesc = "Input value must be a string that can contain only upper/lower letters, digits, and the characters . - _ / *";
string_view const groupNameRefRegex = "[a-zA-Z0-9.\\-_/*]*";


// Build master list of regexes
Expand Down
32 changes: 32 additions & 0 deletions src/coreComponents/common/Units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ enum Unit : integer

/// Solubility in g/L
Solubility,

/// Mass in kg
Mass,

/// Mole in mol
Mole,

/// Mass rate in kg/s
MassRate,

/// Mole rate in mol/s
MoleRate,
};


Expand All @@ -104,6 +116,10 @@ constexpr inline std::string_view getDescription( Unit unit )
case Enthalpy: return "enthalpy [J/kg]";
case Density: return "density [kg/m3]";
case Solubility: return "solubility [g/L]";
case Mass: return "mass [kg]";
case Mole: return "mole [mol]";
case MassRate: return "mass rate [kg/s]";
case MoleRate: return "mole rate [mol/s]";
}
}

Expand All @@ -122,6 +138,14 @@ constexpr inline std::string_view getSymbol( Unit unit )
case TemperatureInC: return "C";
case Distance: return "m";
case Time: return "s";
case Viscosity: return "Pa*s";
case Enthalpy: return "J/kg";
case Density: return "kg/m3";
case Solubility: return "g/L";
case Mass: return "kg";
case Mole: return "mol";
case MassRate: return "kg/s";
case MoleRate: return "mol/s";
}
}

Expand All @@ -143,6 +167,14 @@ inline string formatValue( real64 value, Unit unit )
case TemperatureInC: return GEOS_FMT( "temperature of {} [K]", convertCToK( value ) );
case Distance: return GEOS_FMT( "distance of {} [s]", value );
case Time: return GEOS_FMT( "time of {} [s]", value );
case Viscosity: return GEOS_FMT( "viscosity of {} [Pa*s]", value );
case Enthalpy: return GEOS_FMT( "enthalpy of {} [J/kg]", value );
case Density: return GEOS_FMT( "density of {} [kg/m3]", value );
case Solubility: return GEOS_FMT( "solubility of {} [g/L]", value );
case Mass: return GEOS_FMT( "mass of {} [kg]", value );
case Mole: return GEOS_FMT( "mole of {} [mol]", value );
case MassRate: return GEOS_FMT( "mass rate of {} [kg/s]", value );
case MoleRate: return GEOS_FMT( "mole rate of {} [mol/s]", value );
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,8 @@ void Group::postRestartInitializationRecursive()

void Group::enableLogLevelInput()
{
string const logLevelString = "logLevel";

registerWrapper( logLevelString, &m_logLevel ).
// TODO : Improve the Log Level description to clearly assign a usecase per log level (incoming PR).
registerWrapper( viewKeyStruct::logLevelString(), &m_logLevel ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Log level" );
Expand Down
9 changes: 9 additions & 0 deletions src/coreComponents/dataRepository/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,15 @@ class Group
*/
void setInputFlags( InputFlags flags ) { m_input_flags = flags; }

/**
* @brief Structure to hold scoped key names
*/
struct viewKeyStruct
{
/// @return String for the logLevel wrapper
static constexpr char const * logLevelString() { return "logLevel"; }
};

///@}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/coreComponents/dataRepository/Wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,15 @@ class Wrapper final : public WrapperBase
return *this;
}

/**
* @copydoc WrapperBase::appendDescription(string const &)
*/
Wrapper< T > & appendDescription( string const & description )
{
WrapperBase::appendDescription( description );
return *this;
}

/**
* @copydoc WrapperBase::setRegisteringObjects(string const &)
*/
Expand Down
11 changes: 11 additions & 0 deletions src/coreComponents/dataRepository/WrapperBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,17 @@ class WrapperBase
return *this;
}

/**
* @brief Add up more text to the existing description string of the wrapper.
* @param description the description to add to the end of the previous one.
* @return a pointer to this wrapper
*/
WrapperBase & appendDescription( string const & description )
{
m_description += description;
return *this;
}

/**
* @brief Get the description string of the wrapper.
* @return this wrapper's description string
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/fieldSpecification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set( fieldSpecification_headers
TractionBoundaryCondition.hpp
AquiferBoundaryCondition.hpp
PerfectlyMatchedLayer.hpp
SourceFluxStatistics.hpp
)

#
Expand All @@ -24,6 +25,7 @@ set( fieldSpecification_sources
TractionBoundaryCondition.cpp
AquiferBoundaryCondition.cpp
PerfectlyMatchedLayer.cpp
SourceFluxStatistics.cpp
)

set( dependencyList ${parallelDeps} functions linearAlgebra )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "SourceFluxBoundaryCondition.hpp"
#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp"

namespace geos
{
Expand All @@ -29,6 +30,18 @@ SourceFluxBoundaryCondition::SourceFluxBoundaryCondition( string const & name, G
getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ).
setInputFlag( InputFlags::FALSE );
setFieldName( catalogName() );

getWrapper< string >( FieldSpecificationBase::viewKeyStruct::functionNameString() ).
setDescription( GEOS_FMT( "Name of a function that specifies the variation of the production rate variations of this {}."
"Multiplied by {}. If no function is provided, a constant value of 1 is used."
"The producted fluid rate unit is in kg by default, or in mole if the flow solver has a {} of 0.",
catalogName(),
FieldSpecificationBase::viewKeyStruct::scaleString(),
CompositionalMultiphaseBase::viewKeyStruct::useMassFlagString() ) );

getWrapper< real64 >( FieldSpecificationBase::viewKeyStruct::scaleString() ).
setDescription( GEOS_FMT( "Multiplier of the {0} value. If no {0} is provided, this value is used directly.",
FieldSpecificationBase::viewKeyStruct::functionNameString() ) );
}

REGISTER_CATALOG_ENTRY( FieldSpecificationBase, SourceFluxBoundaryCondition, string const &, Group * const )
Expand Down
Loading

0 comments on commit 880d43c

Please sign in to comment.