Skip to content

Commit

Permalink
Merge pull request #698 from Pressio/684-update-code-to-reflect-minim…
Browse files Browse the repository at this point in the history
…um-c++-version-is-17

#684: Update code to reflect minimum C++ version is 17
  • Loading branch information
fnrizzi authored Oct 25, 2024
2 parents 896121c + adeed54 commit a250560
Show file tree
Hide file tree
Showing 71 changed files with 37 additions and 734 deletions.
4 changes: 0 additions & 4 deletions docs/source/keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ Other Options
- to enable debugging print statements
- ``OFF``

* - ``PRESSIO_ENABLE_CXX17``
- enables C++17 standard
- ``ON`` since min standard is 17

* - ``PRESSIO_ENABLE_CXX20``
- enables C++20 standard
- ``OFF``; turned on if ``CMAKE_CXX_STANDARD`` is set to 20
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
#ifndef PRESSIO_ODE_CONCEPTS_ODE_HAS_CONST_DISCRETE_RESIDUAL_JACOBIAN_METHOD_HPP_
#define PRESSIO_ODE_CONCEPTS_ODE_HAS_CONST_DISCRETE_RESIDUAL_JACOBIAN_METHOD_HPP_

#ifdef PRESSIO_ENABLE_CXX17
#include <optional>
#endif

namespace pressio{ namespace ode{

Expand Down Expand Up @@ -80,11 +78,7 @@ struct has_const_discrete_residual_jacobian_method<
std::declval<IndVarType const &>(),
std::declval<IndVarType const &>(),
std::declval<ResidualType &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<JacobianType*> >(),
#else
std::declval<JacobianType*>(),
#endif
std::declval< std::optional<JacobianType*> >(),
std::declval<state_t const&>()
)
)
Expand All @@ -108,11 +102,7 @@ struct has_const_discrete_residual_jacobian_method<
std::declval<IndVarType const &>(),
std::declval<IndVarType const &>(),
std::declval<ResidualType &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<JacobianType*> >(),
#else
std::declval<JacobianType*>(),
#endif
std::declval< std::optional<JacobianType*> >(),
std::declval<state_t const&>(),
std::declval<state_t const&>()
)
Expand All @@ -136,11 +126,7 @@ struct has_const_discrete_residual_jacobian_method<
std::declval<IndVarType const &>(),
std::declval<IndVarType const &>(),
std::declval<ResidualType &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<JacobianType*> >(),
#else
std::declval<JacobianType*>(),
#endif
std::declval< std::optional<JacobianType*> >(),
std::declval<state_t const&>(),
std::declval<state_t const&>(),
std::declval<state_t const&>()
Expand All @@ -166,11 +152,7 @@ struct has_const_discrete_residual_jacobian_method<
std::declval<IndVarType const &>(),
std::declval<IndVarType const &>(),
std::declval<ResidualType &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<JacobianType*> >(),
#else
std::declval<JacobianType*>(),
#endif
std::declval< std::optional<JacobianType*> >(),
std::declval<state_t const&>(),
std::declval<state_t const&>(),
std::declval<state_t const&>(),
Expand Down
12 changes: 0 additions & 12 deletions include/pressio/ode/concepts/ode_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ struct OdeSystemFusingRhsAndJacobian<
std::declval<typename T::state_type const&>(),
std::declval<typename T::independent_variable_type const &>(),
std::declval<typename T::rhs_type &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<typename T::jacobian_type*> >()
#else
std::declval< typename T::jacobian_type* >()
#endif
)
)
>::value
Expand Down Expand Up @@ -144,11 +140,7 @@ struct CompleteOdeSystem<
std::declval<typename T::independent_variable_type const &>(),
std::declval<typename T::mass_matrix_type &>(),
std::declval<typename T::rhs_type &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<typename T::jacobian_type*> >()
#else
std::declval< typename T::jacobian_type* >()
#endif
)
)
>::value
Expand Down Expand Up @@ -327,11 +319,7 @@ struct ImplicitResidualJacobianPolicy<
std::declval< ::pressio::ode::StepCount >(),
std::declval< ::pressio::ode::StepSize<typename T::independent_variable_type> >(),
std::declval<typename T::residual_type &>(),
#ifdef PRESSIO_ENABLE_CXX17
std::declval< std::optional<typename T::jacobian_type*> >()
#else
std::declval< typename T::jacobian_type* >()
#endif
)
)
>::value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ class ResidualJacobianWithMassMatrixStandardPolicy
::pressio::ode::StepCount step,
const ::pressio::ode::StepSize<IndVarType> & dt,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{

if (name == StepScheme::BDF1){
Expand Down Expand Up @@ -152,11 +148,7 @@ class ResidualJacobianWithMassMatrixStandardPolicy
const IndVarType & dt,
const StepType & step,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> & Jo) const
#else
jacobian_type* Jo) const
#endif
{

try{
Expand All @@ -167,11 +159,7 @@ class ResidualJacobianWithMassMatrixStandardPolicy
massMatrix_, R, stencilStatesManager, dt);

if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
discrete_jacobian(BDF1(), Jv, massMatrix_, dt);
}
}
Expand All @@ -191,11 +179,7 @@ class ResidualJacobianWithMassMatrixStandardPolicy
const IndVarType & dt,
const StepType & step,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
std::optional<jacobian_type*> Jo) const
{

stepTracker_ = step;
Expand All @@ -209,23 +193,15 @@ class ResidualJacobianWithMassMatrixStandardPolicy
massMatrix_, R, stencilStatesManager, dt);

if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
discrete_jacobian(BDF1(), Jv, massMatrix_, dt);
}
}
else{
discrete_residual(BDF2(), predictedState, scratchState_, rhs_,
massMatrix_, R, stencilStatesManager, dt);
if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
discrete_jacobian(BDF2(), Jv, massMatrix_, dt);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ class ResidualJacobianStandardPolicy
::pressio::ode::StepCount step,
const ::pressio::ode::StepSize<IndVarType> & dt,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{

trampoline(name, predictedState, stencilStatesManager,
Expand Down Expand Up @@ -153,11 +149,7 @@ class ResidualJacobianStandardPolicy
const IndVarType & dt,
const StepType & step,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
std::optional<jacobian_type*> Jo) const
{

try{
Expand All @@ -168,11 +160,7 @@ class ResidualJacobianStandardPolicy
R, stencilStatesManager, dt);

if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
auto & Jv = *(Jo.value());
::pressio::ode::impl::discrete_jacobian(BDF1(), Jv, dt);
}
}
Expand All @@ -196,11 +184,7 @@ class ResidualJacobianStandardPolicy
const IndVarType & dt,
const StepType & step,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
std::optional<jacobian_type*> Jo) const
{

stepTracker_ = step;
Expand All @@ -213,11 +197,7 @@ class ResidualJacobianStandardPolicy
R, stencilStatesManager, dt);

if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
::pressio::ode::impl::discrete_jacobian(BDF1(), Jv, dt);
}
}
Expand All @@ -233,11 +213,7 @@ class ResidualJacobianStandardPolicy
R, stencilStatesManager, dt);

if (Jo){
#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
::pressio::ode::impl::discrete_jacobian(BDF2(), Jv, dt);
}
}
Expand All @@ -263,11 +239,7 @@ class ResidualJacobianStandardPolicy
const IndVarType & dt,
const StepType & step,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{

if (stepTracker_ != step){
Expand All @@ -280,12 +252,7 @@ class ResidualJacobianStandardPolicy
auto & f_np1 = stencilVelocities(::pressio::ode::nPlusOne());
if (Jo){
systemObj_.get().rhsAndJacobian(predictedState, t_np1, f_np1, Jo);

#ifdef PRESSIO_ENABLE_CXX17
auto & Jv = *(Jo.value());
#else
auto & Jv = *Jo;
#endif
::pressio::ode::impl::discrete_jacobian(ode::CrankNicolson(), Jv, dt);
}
else{
Expand Down
12 changes: 0 additions & 12 deletions include/pressio/ode/impl/ode_implicit_stepper_arbitrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,7 @@ class StepperArbitrary
std::enable_if_t< _numAuxStates==1 >
residualAndJacobian(const state_type & odeState,
residual_type & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{
const auto & yn = stencilStates_(ode::n());

Expand All @@ -160,11 +156,7 @@ class StepperArbitrary
std::enable_if_t< _numAuxStates==2 >
residualAndJacobian(const state_type & odeState,
residual_type & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{
const auto & yn = stencilStates_(ode::n());
const auto & ynm1 = stencilStates_(ode::nMinusOne());
Expand All @@ -184,11 +176,7 @@ class StepperArbitrary
std::enable_if_t< _numAuxStates==3 >
residualAndJacobian(const state_type & odeState,
residual_type & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{
const auto & yn = stencilStates_(ode::n());
const auto & ynm1 = stencilStates_(ode::nMinusOne());
Expand Down
4 changes: 0 additions & 4 deletions include/pressio/ode/impl/ode_implicit_stepper_standard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ class ImplicitStepperStandardImpl

void residualAndJacobian(const StateType & odeState,
ResidualType & R,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> Jo) const
#else
jacobian_type* Jo) const
#endif
{
rj_policy_.get()(name_, odeState, stencil_states_, stencil_rhs_,
::pressio::ode::StepEndAt<IndVarType>(t_np1_),
Expand Down
12 changes: 0 additions & 12 deletions include/pressio/rom/impl/galerkin_steady_system_default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ class GalerkinSteadyDefaultSystem

void residualAndJacobian(const state_type & reducedState,
residual_type & reducedResidual,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> reducedJacobian) const
#else
jacobian_type* reducedJacobian) const
#endif
{

const auto & phi = trialSubspace_.get().basisOfTranslatedSpace();
Expand All @@ -82,12 +78,8 @@ class GalerkinSteadyDefaultSystem
using R_scalar_t = typename ::pressio::Traits<residual_type>::scalar_type;
constexpr auto beta = static_cast<R_scalar_t>(0);

#ifdef PRESSIO_ENABLE_CXX17
fomSystem_.get().residualAndJacobianAction(fomState_, fomResidual_, phi,
std::optional<fom_jac_action_result_type *>(&fomJacAction_));
#else
fomSystem_.get().residualAndJacobianAction(fomState_, fomResidual_, phi, &fomJacAction_);
#endif

::pressio::ops::product(::pressio::transpose(),
alpha, phi, fomResidual_, beta, reducedResidual);
Expand All @@ -98,11 +90,7 @@ class GalerkinSteadyDefaultSystem
::pressio::ops::product(::pressio::transpose(),
::pressio::nontranspose(),
alpha, phi, fomJacAction_, beta,
#ifdef PRESSIO_ENABLE_CXX17
*reducedJacobian.value());
#else
*reducedJacobian);
#endif
}
}

Expand Down
13 changes: 0 additions & 13 deletions include/pressio/rom/impl/galerkin_steady_system_hypred.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,17 @@ class GalerkinSteadyHypRedSystem

void residualAndJacobian(const state_type & reducedState,
residual_type & reducedResidual,
#ifdef PRESSIO_ENABLE_CXX17
std::optional<jacobian_type*> reducedJacobian) const
#else
jacobian_type* reducedJacobian) const
#endif
{

const auto & phi = trialSubspace_.get().basisOfTranslatedSpace();
trialSubspace_.get().mapFromReducedState(reducedState, fomState_);

#ifdef PRESSIO_ENABLE_CXX17
fomSystem_.get().residualAndJacobianAction(fomState_, fomResidual_, phi,
std::optional<fom_jac_action_result_type *>(&fomJacAction_));
#else
fomSystem_.get().residualAndJacobianAction(fomState_, fomResidual_, phi, &fomJacAction_);
#endif

hyperReducer_(fomResidual_, reducedResidual);
if (reducedJacobian){
#ifdef PRESSIO_ENABLE_CXX17
hyperReducer_(fomJacAction_, *reducedJacobian.value());
#else
hyperReducer_(fomJacAction_, *reducedJacobian);
#endif
}
}

Expand Down
Loading

0 comments on commit a250560

Please sign in to comment.