Commit f989345d authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#531 Internal of assembling: Modify determination of previous coefficient to...

#531 Internal of assembling: Modify determination of previous coefficient to ahndle properly cases in which vectors and matrices are both assembled.
parent 513f84ea
......@@ -90,8 +90,14 @@ namespace HappyHeart
template<class LinearAlgebraTupleT, std::size_t I>
struct ZeroSpecialCase
{
using current_type = typename std::tuple_element<I, LinearAlgebraTupleT>::type;
// What we really seek is the previous coefficient FOR THE SAME TYPE of linear algebra.
// However, nothing prevent a user to ask for:
// non_linear_operator.Assemble(*matrix1*, *vector1*, *matrix2*);
// In this case, the expected previous coefficient are respectively: 1., 1., coeff(matrix1).
template<class CurrentTypeT>
static double FetchPreviousCoefficient(const LinearAlgebraTupleT& linear_algebra_tuple);
......@@ -103,7 +109,7 @@ namespace HappyHeart
struct ZeroSpecialCase<LinearAlgebraTupleT, 0>
{
template<class CurrentTypeT>
static double FetchPreviousCoefficient(const LinearAlgebraTupleT& linear_algebra_tuple);
......
......@@ -55,12 +55,9 @@ namespace HappyHeart
)
, "Given linear algebra given for assembling must be compatible with the operator.");
const double previous_coefficient =
ZeroSpecialCase<LinearAlgebraTupleT, I>::FetchPreviousCoefficient(linear_algebra_tuple);
ZeroSpecialCase<LinearAlgebraTupleT, I>::template FetchPreviousCoefficient<current_type>(linear_algebra_tuple);
const auto& global_linear_algebra = std::get<I>(linear_algebra_tuple);
......@@ -209,6 +206,7 @@ namespace HappyHeart
template<class LinearAlgebraTupleT>
template<class CurrentTypeT>
double ZeroSpecialCase<LinearAlgebraTupleT, 0>
::FetchPreviousCoefficient(const LinearAlgebraTupleT& linear_algebra_tuple)
{
......@@ -219,10 +217,21 @@ namespace HappyHeart
template<class LinearAlgebraTupleT, std::size_t I>
template<class CurrentTypeT>
double ZeroSpecialCase<LinearAlgebraTupleT, I>
::FetchPreviousCoefficient(const LinearAlgebraTupleT& linear_algebra_tuple)
{
return std::get<I-1>(linear_algebra_tuple).second;
// What we really seek is the previous coefficient FOR THE SAME TYPE of linear algebra.
// However, nothing prevent a user to ask for:
// non_linear_operator.Assemble(*matrix1*, *vector1*, *matrix2*);
// In this case, the expected previous coefficient are respectively: 1., 1., coeff(matrix1).
using previous_type = typename std::tuple_element<I - 1, LinearAlgebraTupleT>::type;
return std::is_same<CurrentTypeT, previous_type>::value
? std::get<I - 1>(linear_algebra_tuple).second
: ZeroSpecialCase<LinearAlgebraTupleT, I - 1>::template FetchPreviousCoefficient<CurrentTypeT>(linear_algebra_tuple);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment