Skip to content
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fd5d21a
well time step selector based on rates/bhp tables
Nov 6, 2024
a724165
remove debug
Nov 6, 2024
2ed34d6
clean up logic
Nov 6, 2024
42827b1
Update WellSolverBase.cpp
paveltomin Nov 6, 2024
f70fb2d
Merge remote-tracking branch 'origin/develop' into pt/well-dt
Nov 6, 2024
05d5168
Merge branch 'pt/well-dt' of https://github.com/GEOS-DEV/GEOS into pt…
Nov 6, 2024
433498b
Merge branch 'develop' into pt/well-dt
paveltomin Nov 7, 2024
6c87a96
code style
Nov 7, 2024
11bb54b
Merge branch 'develop' into pt/well-dt
paveltomin Nov 11, 2024
2c3ea5f
code style
Nov 12, 2024
4a34a38
build fix
Nov 12, 2024
e03621b
doc fix
Nov 12, 2024
d1374da
dim
Nov 13, 2024
997a58e
flag to enable
Nov 13, 2024
32782a7
revert rename, Dick's suggestion
Nov 13, 2024
4e4eee0
revert some more
Nov 13, 2024
3e950fe
Merge branch 'develop' into pt/well-dt
paveltomin Nov 17, 2024
56594c3
Merge branch 'develop' into pt/well-dt
paveltomin Nov 22, 2024
e3e0f10
Feature/byer3/well dt (#3473)
tjb-ltk Dec 3, 2024
9946aa7
Merge remote-tracking branch 'origin/develop' into pt/well-dt
Dec 4, 2024
7304811
build fix
Dec 4, 2024
a7eaf4a
code style
Dec 4, 2024
4562fe4
Merge branch 'develop' into pt/well-dt
paveltomin Dec 12, 2024
6ceb88e
revert
Dec 12, 2024
6d8f9ff
Merge branch 'pt/well-dt' of https://github.com/GEOS-DEV/GEOS into pt…
Dec 12, 2024
47ea23c
Merge branch 'develop' into pt/well-dt
paveltomin Dec 23, 2024
c20745b
build fix
Dec 23, 2024
301527f
Merge remote-tracking branch 'origin/develop' into pt/well-dt
Jan 9, 2025
a448c9f
Merge branch 'develop' into pt/well-dt
paveltomin Jan 13, 2025
e71b608
Merge branch 'develop' into pt/well-dt
paveltomin Jan 16, 2025
a2ed152
Merge remote-tracking branch 'origin/develop' into pt/well-dt
Jan 22, 2025
03170a3
missing file
Jan 22, 2025
4cf1a3e
Merge branch 'develop' into pt/well-dt
paveltomin Jan 28, 2025
777f05f
Merge branch 'develop' into pt/well-dt
paveltomin Feb 1, 2025
842ae59
build fix
Feb 1, 2025
42a49ff
Merge branch 'develop' into pt/well-dt
paveltomin Feb 6, 2025
31fcd8c
Merge branch 'develop' into pt/well-dt
paveltomin Feb 8, 2025
638bf71
Update PhysicsSolverBase.cpp
paveltomin Feb 18, 2025
0451f0a
Merge branch 'develop' into pt/well-dt
paveltomin Feb 19, 2025
75e38a7
merge fix
Feb 19, 2025
111eea8
Merge branch 'develop' into pt/well-dt
paveltomin Mar 4, 2025
7a8e7eb
Merge branch 'develop' into pt/well-dt
paveltomin Mar 7, 2025
494eb93
review comments
Mar 7, 2025
0c52b88
Merge branch 'develop' into pt/well-dt
paveltomin Mar 9, 2025
f0bce1b
Merge branch 'develop' into pt/well-dt
paveltomin Mar 10, 2025
f641234
remove std
Mar 10, 2025
c2d84ac
try this
Mar 10, 2025
7eca216
Update .integrated_tests.yaml
paveltomin Mar 10, 2025
dcd9121
Update BASELINE_NOTES.md
paveltomin Mar 10, 2025
34d1de8
mpi fix
Mar 11, 2025
a30fdbe
Update .integrated_tests.yaml
paveltomin Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/coreComponents/codingUtilities/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ bool isZero( T const val, T const tol = LvArray::NumericLimits< T >::epsilon )
return -tol <= val && val <= tol;
}

template< typename ARRAY_TYPE >
GEOS_FORCE_INLINE GEOS_HOST_DEVICE
bool hasNonZero( ARRAY_TYPE const & array )
{
return std::any_of( array.begin(), array.end(), []( real64 value ) {
return !isZero( value ); // Check if the value is non-zero
} );
}

template< typename T >
GEOS_FORCE_INLINE GEOS_HOST_DEVICE constexpr
bool isOdd( T x )
Expand Down
5 changes: 5 additions & 0 deletions src/coreComponents/functions/TableFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ real64 TableFunction::evaluate( real64 const * const input ) const
return m_kernelWrapper.compute( input );
}

real64 TableFunction::getCoord( real64 const * const input, localIndex const dim, InterpolationType interpolationMethod ) const
{
return m_kernelWrapper.getCoord( input, dim, interpolationMethod );
}

TableFunction::KernelWrapper::KernelWrapper( InterpolationType const interpolationMethod,
ArrayOfArraysView< real64 const > const & coordinates,
arrayView1d< real64 const > const & values )
Expand Down
72 changes: 72 additions & 0 deletions src/coreComponents/functions/TableFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ class TableFunction : public FunctionBase
real64
interpolateRound( IN_ARRAY const & input ) const;

/**
* @brief ...
* @param[in] input vector of input value
* @param[in] dim table dimension
* @param[in] interpolationMethod interpolation method
* @return coordinate value
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe unify the documentation with the other getCoord signature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

*/
template< typename IN_ARRAY >
GEOS_HOST_DEVICE
real64
getCoord( IN_ARRAY const & input, localIndex dim, InterpolationType interpolationMethod ) const;

/**
* @brief Interpolate in the table with derivatives using linear method.
* @param[in] input vector of input value
Expand Down Expand Up @@ -240,6 +252,15 @@ class TableFunction : public FunctionBase
*/
virtual real64 evaluate( real64 const * const input ) const override final;

/**
* @brief Method to get coordinates
* @param input a scalar input
* @param dim the table dimension
* @param interpolationMethod the interpolation method
* @return the coordinate
*/
real64 getCoord( real64 const * const input, localIndex dim, InterpolationType interpolationMethod ) const;
Comment on lines +255 to +262
Copy link
Contributor

@MelReyCG MelReyCG Mar 7, 2025

Choose a reason for hiding this comment

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

I think you should annotate the docs that this method is assuming createKernelWrapper() has been called (because it is based on the m_kernelWrapper data).
Maybe add an error in it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added
GEOS_ASSERT( dim >= 0 && dim < m_coordinates.size() );


/**
* @brief Check if the given coordinate is in the bounds of the table coordinates in the
* specified dimension, throw an exception otherwise.
Expand Down Expand Up @@ -554,6 +575,57 @@ TableFunction::KernelWrapper::interpolateRound( IN_ARRAY const & input ) const
return m_values[tableIndex];
}

template< typename IN_ARRAY >
GEOS_HOST_DEVICE
GEOS_FORCE_INLINE
real64
TableFunction::KernelWrapper::getCoord( IN_ARRAY const & input, localIndex const dim, InterpolationType interpolationMethod ) const
{
// Determine the index to the nearest table entry
localIndex subIndex;
arraySlice1d< real64 const > const coords = m_coordinates[dim];
// Determine the index along each table axis
if( input[dim] <= coords[0] )
{
// Coordinate is to the left of the table axis
subIndex = 0;
}
else if( input[dim] >= coords[coords.size() - 1] )
{
// Coordinate is to the right of the table axis
subIndex = coords.size() - 1;
}
else
{
// Coordinate is within the table axis
// Note: find() will return the index of the upper table vertex
auto const lower = LvArray::sortedArrayManipulation::find( coords.begin(), coords.size(), input[dim] );
subIndex = LvArray::integerConversion< localIndex >( lower );

// Interpolation types:
// - Nearest returns the value of the closest table vertex
// - Upper returns the value of the next table vertex
// - Lower returns the value of the previous table vertex
if( interpolationMethod == TableFunction::InterpolationType::Nearest )
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there are 4 interpolation types... Linear, Nearest, Upper, Lower... Using the find method defaults to Upper ? then overridden if method is nearest or lower... Is there any chance of method being called with Linear

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

calling for Linear would not make much sense i think, should i add a check and throw an error for Linear?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

  GEOS_ASSERT_MSG( interpolationMethod != InterpolationType::Linear,
                   GEOS_FMT( "{}: TableFunction::getCoord should not be called with {} interpolation method",
                             getDataContext(), EnumStrings< InterpolationType >::toString( interpolationMethod )));

{
if( ( input[dim] - coords[subIndex - 1]) <= ( coords[subIndex] - input[dim]) )
{
--subIndex;
}
}
else if( interpolationMethod == TableFunction::InterpolationType::Lower )
{
if( subIndex > 0 )
{
--subIndex;
}
}
}

// Retrieve the nearest coordinate
return coords[subIndex];
}

template< typename IN_ARRAY, typename OUT_ARRAY >
GEOS_HOST_DEVICE
GEOS_FORCE_INLINE
Expand Down
25 changes: 13 additions & 12 deletions src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ bool PhysicsSolverBase::execute( real64 const time_n,

if( dtRemaining > 0.0 )
{
nextDt = setNextDt( dtAccepted, domain );
nextDt = setNextDt( time_n + (dt - dtRemaining), dtAccepted, domain );
if( nextDt < dtRemaining )
{
// better to do two equal steps than one big and one small (even potentially tiny)
Expand Down Expand Up @@ -333,7 +333,7 @@ bool PhysicsSolverBase::execute( real64 const time_n,
" reached. Consider increasing maxSubSteps." );

// Decide what to do with the next Dt for the event running the solver.
m_nextDt = setNextDt( nextDt, domain );
m_nextDt = setNextDt( time_n + dt, nextDt, domain );

// Increase counter to indicate how many cycles since the last timestep cut
if( m_numTimestepsSinceLastDtCut >= 0 )
Expand Down Expand Up @@ -364,15 +364,16 @@ void PhysicsSolverBase::logEndOfCycleInformation( integer const cycleNumber,
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::TimeStep, "------------------------------------------------------------------\n" );
}

real64 PhysicsSolverBase::setNextDt( real64 const & currentDt,
real64 PhysicsSolverBase::setNextDt( real64 const & GEOS_UNUSED_PARAM( currentTime ),
real64 const & currentDt,
DomainPartition & domain )
{
integer const minTimeStepIncreaseInterval = m_nonlinearSolverParameters.minTimeStepIncreaseInterval();
real64 const nextDtNewton = setNextDtBasedOnNewtonIter( currentDt );
if( m_nonlinearSolverParameters.getLogLevel() > 0 )
GEOS_LOG_RANK_0( GEOS_FMT( "{}: next time step based on Newton iterations = {}", getName(), nextDtNewton ));
real64 const nextDtIter = setNextDtBasedOnIterNumber( currentDt );
if( m_nonlinearSolverParameters.getLogLevel() > 0 && nextDtIter < LvArray::NumericLimits< real64 >::max )
GEOS_LOG_RANK_0( GEOS_FMT( "{}: next time step based on number of iterations = {}", getName(), nextDtIter ));
real64 const nextDtStateChange = setNextDtBasedOnStateChange( currentDt, domain );
if( m_nonlinearSolverParameters.getLogLevel() > 0 )
if( m_nonlinearSolverParameters.getLogLevel() > 0 && nextDtStateChange < LvArray::NumericLimits< real64 >::max )
GEOS_LOG_RANK_0( GEOS_FMT( "{}: next time step based on state change = {}", getName(), nextDtStateChange ));

if( ( m_numTimestepsSinceLastDtCut >= 0 ) && ( m_numTimestepsSinceLastDtCut < minTimeStepIncreaseInterval ) )
Expand All @@ -382,14 +383,14 @@ real64 PhysicsSolverBase::setNextDt( real64 const & currentDt,
return currentDt;
}

if( nextDtNewton < nextDtStateChange ) // time step size decided based on convergence
if( nextDtIter < nextDtStateChange ) // time step size decided based on convergence
{
if( nextDtNewton > currentDt )
if( nextDtIter > currentDt )
{
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::TimeStep, GEOS_FMT( "{}: time-step required will be increased based on number of iterations.",
getName() ) );
}
else if( nextDtNewton < currentDt )
else if( nextDtIter < currentDt )
{
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::TimeStep, GEOS_FMT( "{}: time-step required will be decreased based on number of iterations.",
getName() ) );
Expand Down Expand Up @@ -419,7 +420,7 @@ real64 PhysicsSolverBase::setNextDt( real64 const & currentDt,
}
}

return std::min( nextDtNewton, nextDtStateChange );
return std::min( nextDtIter, nextDtStateChange );
}

real64 PhysicsSolverBase::setNextDtBasedOnStateChange( real64 const & currentDt,
Expand All @@ -429,7 +430,7 @@ real64 PhysicsSolverBase::setNextDtBasedOnStateChange( real64 const & currentDt,
return LvArray::NumericLimits< real64 >::max; // i.e., not implemented
}

real64 PhysicsSolverBase::setNextDtBasedOnNewtonIter( real64 const & currentDt )
real64 PhysicsSolverBase::setNextDtBasedOnIterNumber( real64 const & currentDt )
{
integer & newtonIter = m_nonlinearSolverParameters.m_numNewtonIterations;
integer const iterDecreaseLimit = m_nonlinearSolverParameters.timeStepDecreaseIterLimit();
Expand Down
8 changes: 5 additions & 3 deletions src/coreComponents/physicsSolvers/PhysicsSolverBase.hpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing BasedOnNewton tier changed to just IterNumber looks to support workflows beyond newton solvers? for better understanding. what is an example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

simply the coupled sequential solver, it's not Newton iterations but the solver uses same logic for time step selection

Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,21 @@ class PhysicsSolverBase : public ExecutableGroup

/**
* @brief function to set the next time step size
* @param[in] currentTime the current time
* @param[in] currentDt the current time step size
* @param[in] domain the domain object
* @return the prescribed time step size
*/
virtual real64 setNextDt( real64 const & currentDt,
virtual real64 setNextDt( real64 const & currentTime,
real64 const & currentDt,
DomainPartition & domain );

/**
* @brief function to set the next time step size based on Newton convergence
* @brief function to set the next time step size based on convergence
* @param[in] currentDt the current time step size
* @return the prescribed time step size
*/
virtual real64 setNextDtBasedOnNewtonIter( real64 const & currentDt );
virtual real64 setNextDtBasedOnIterNumber( real64 const & currentDt );

/**
* @brief function to set the next dt based on state change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,10 +1546,12 @@ void CompositionalMultiphaseFVM::assembleHydrofracFluxTerms( real64 const GEOS_U
} );
}

real64 CompositionalMultiphaseFVM::setNextDt( const geos::real64 & currentDt, geos::DomainPartition & domain )
real64 CompositionalMultiphaseFVM::setNextDt( real64 const & currentTime,
real64 const & currentDt,
DomainPartition & domain )
{
if( m_targetFlowCFL < 0 )
return CompositionalMultiphaseBase::setNextDt( currentDt, domain );
return CompositionalMultiphaseBase::setNextDt( currentTime, currentDt, domain );
else
return setNextDtBasedOnCFL( currentDt, domain );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ class CompositionalMultiphaseFVM : public CompositionalMultiphaseBase

/**
* @brief function to set the next time step size
* @param[in] currentTime the current time
* @param[in] currentDt the current time step size
* @param[in] domain the domain object
* @return the prescribed time step size
*/
real64 setNextDt( real64 const & currentDt,
real64 setNextDt( real64 const & currentTime,
real64 const & currentDt,
DomainPartition & domain ) override;

struct viewKeyStruct : CompositionalMultiphaseBase::viewKeyStruct
Expand Down
Loading
Loading