Skip to content

Commit

Permalink
added concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
lformaggia committed May 12, 2024
1 parent 800e480 commit 2f98da9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
16 changes: 16 additions & 0 deletions Examples/src/RKFSolver/ButcherRKF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define SRC_RK45_BUTCHERRKF_HPP_
#include <algorithm>
#include <array>
#include <concepts>
#include <numeric>
namespace apsc
{
Expand Down Expand Up @@ -97,6 +98,21 @@ template <unsigned int NSTAGES> struct ButcherArray
}
};

template <typename B>
concept ButcherArrayConcept = requires(B b) {
b.A;
b.b1;
b.b2;
b.c;
b.order;
{
b.implicit()
} -> std::same_as<bool>;
{
B::Nstages()
} -> std::convertible_to<unsigned int>;
};

namespace RKFScheme
{
// SOME COMMON RK embedded schemes
Expand Down
2 changes: 1 addition & 1 deletion Examples/src/RKFSolver/RKF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template <RKFKind KIND> struct RKFResult
* scheme shown in ButcherRKF.hpp
* @tparam KIND The type of traits to be used: SCALAR, VECTOR, MATRIX
*/
template <class B, RKFKind KIND = RKFKind::SCALAR>
template <apsc::ButcherArrayConcept B, RKFKind KIND = RKFKind::SCALAR>
class RKF : public RKFTraits<KIND>
{
public:
Expand Down
10 changes: 7 additions & 3 deletions Examples/src/RKFSolver/main_rk45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ main()
<< errorDesired << " Failed:" << solution.failed
<< " Estimated Error " << solution.estimatedError
<< "\n Contractions=" << solution.contractions
<< " Expansions=" << solution.expansions;
<< " Expansions=" << solution.expansions << " Total steps "
<< solution.time.size();
std::cout << std::endl;

// auto solution = solver(t0,T, y0, h_init, errorDesired);
Expand Down Expand Up @@ -66,7 +67,8 @@ main()
<< " Failed:" << solution.failed << " Estimated Error "
<< solution.estimatedError
<< "\n Contractions=" << solution.contractions
<< " Expansions=" << solution.expansions;
<< " Expansions=" << solution.expansions << " Total steps "
<< solution.time.size();
std::cout << std::endl;
ofstream file3("resultVDP.dat");
file3 << solution;
Expand Down Expand Up @@ -97,7 +99,9 @@ main()
<< " Failed:" << solution.failed << " Estimated Error "
<< solution.estimatedError
<< "\n Contractions=" << solution.contractions
<< " Expansions=" << solution.expansions;
<< " Expansions=" << solution.expansions << " Total steps "
<< solution.time.size();

std::cout << std::endl;
ofstream file3("resultstiff.dat");
file3 << solution;
Expand Down

0 comments on commit 2f98da9

Please sign in to comment.