1- // SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
1+ // SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
22//
33// SPDX-License-Identifier: BSD-3-Clause
44
55#include " ginkgo/core/preconditioner/ilu.hpp"
66
77#include < ginkgo/core/base/types.hpp>
8+ #include < ginkgo/core/base/utils.hpp>
89#include < ginkgo/core/config/config.hpp>
910#include < ginkgo/core/config/registry.hpp>
1011#include < ginkgo/core/config/type_descriptor.hpp>
11- #include < ginkgo/core/preconditioner/isai.hpp>
12- #include < ginkgo/core/preconditioner/utils.hpp>
13- #include < ginkgo/core/solver/gmres.hpp>
14- #include < ginkgo/core/solver/ir.hpp>
1512
1613#include " core/config/config_helper.hpp"
1714#include " core/config/dispatch.hpp"
@@ -22,24 +19,27 @@ namespace preconditioner {
2219namespace detail {
2320
2421
25- template <typename Ilu,
26- std::enable_if_t <support_ilu_parse<typename Ilu::l_solver_type,
27- typename Ilu::u_solver_type>>*>
22+ template <typename Ilu, std::enable_if_t <support_ilu_parse<Ilu>>*>
2823typename Ilu::parameters_type ilu_parse (
2924 const config::pnode& config, const config::registry& context,
3025 const config::type_descriptor& td_for_child)
3126{
3227 auto params = Ilu::build ();
33-
28+ using l_solver_type = typename Ilu::l_solver_type;
29+ using u_solver_type = typename Ilu::u_solver_type;
30+ static_assert (std::is_same_v<l_solver_type, LinOp>,
31+ " only support ILU parse when l_solver_type is LinOp." );
32+ static_assert (std::is_same_v<u_solver_type, LinOp>,
33+ " only support ILU parse when u_solver_type is LinOp." );
3434 if (auto & obj = config.get (" l_solver" )) {
3535 params.with_l_solver (
36- gko::config::parse_or_get_specific_factory<
37- const typename Ilu::l_solver_type>( obj, context, td_for_child));
36+ gko::config::parse_or_get_factory< const LinOpFactory>(
37+ obj, context, td_for_child));
3838 }
3939 if (auto & obj = config.get (" u_solver" )) {
4040 params.with_u_solver (
41- gko::config::parse_or_get_specific_factory<
42- const typename Ilu::u_solver_type>( obj, context, td_for_child));
41+ gko::config::parse_or_get_factory< const LinOpFactory>(
42+ obj, context, td_for_child));
4343 }
4444 if (auto & obj = config.get (" factorization" )) {
4545 params.with_factorization (
@@ -51,82 +51,33 @@ typename Ilu::parameters_type ilu_parse(
5151}
5252
5353
54- #define GKO_DECLARE_TRS_ILU_FALSE_PARSE (ValueType, IndexType ) \
55- typename Ilu<solver::LowerTrs<ValueType, IndexType>, \
56- solver::UpperTrs<ValueType, IndexType>, false , \
57- IndexType>::parameters_type \
58- ilu_parse<Ilu<solver::LowerTrs<ValueType, IndexType>, \
59- solver::UpperTrs<ValueType, IndexType>, false , IndexType>>( \
60- const config::pnode&, const config::registry&, \
61- const config::type_descriptor&)
62- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_TRS_ILU_FALSE_PARSE);
63-
64- #define GKO_DECLARE_TRS_ILU_TRUE_PARSE (ValueType, IndexType ) \
65- typename Ilu<solver::LowerTrs<ValueType, IndexType>, \
66- solver::UpperTrs<ValueType, IndexType>, true , \
67- IndexType>::parameters_type \
68- ilu_parse<Ilu<solver::LowerTrs<ValueType, IndexType>, \
69- solver::UpperTrs<ValueType, IndexType>, true , IndexType>>( \
70- const config::pnode&, const config::registry&, \
71- const config::type_descriptor&)
72- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_TRS_ILU_TRUE_PARSE);
73-
74- #define GKO_DECLARE_GMRES_ILU_FALSE_PARSE (ValueType, IndexType ) \
75- typename Ilu<solver::Gmres<ValueType>, solver::Gmres<ValueType>, false , \
76- IndexType>::parameters_type \
77- ilu_parse<Ilu<solver::Gmres<ValueType>, solver::Gmres<ValueType>, false , \
78- IndexType>>(const config::pnode&, const config::registry&, \
79- const config::type_descriptor&)
80- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (
81- GKO_DECLARE_GMRES_ILU_FALSE_PARSE);
82-
83- #define GKO_DECLARE_GMRES_ILU_TRUE_PARSE (ValueType, IndexType ) \
84- typename Ilu<solver::Gmres<ValueType>, solver::Gmres<ValueType>, true , \
85- IndexType>::parameters_type \
86- ilu_parse<Ilu<solver::Gmres<ValueType>, solver::Gmres<ValueType>, true , \
87- IndexType>>(const config::pnode&, const config::registry&, \
88- const config::type_descriptor&)
89- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_GMRES_ILU_TRUE_PARSE);
90-
91- #define GKO_DECLARE_IR_ILU_FALSE_PARSE (ValueType, IndexType ) \
92- typename Ilu<solver::Ir<ValueType>, solver::Ir<ValueType>, false , \
93- IndexType>::parameters_type \
94- ilu_parse< \
95- Ilu<solver::Ir<ValueType>, solver::Ir<ValueType>, false , IndexType>>( \
96- const config::pnode&, const config::registry&, \
97- const config::type_descriptor&)
98- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_IR_ILU_FALSE_PARSE);
99-
100- #define GKO_DECLARE_IR_ILU_TRUE_PARSE (ValueType, IndexType ) \
101- typename Ilu<solver::Ir<ValueType>, solver::Ir<ValueType>, true , \
102- IndexType>::parameters_type \
103- ilu_parse< \
104- Ilu<solver::Ir<ValueType>, solver::Ir<ValueType>, true , IndexType>>( \
105- const config::pnode&, const config::registry&, \
54+ #define GKO_DECLARE_ILU_PARSE_FALSE (ValueType, IndexType ) \
55+ typename Ilu<ValueType, ValueType, false , IndexType>::parameters_type \
56+ ilu_parse<Ilu<ValueType, ValueType, false , IndexType>>( \
57+ const config::pnode&, const config::registry&, \
10658 const config::type_descriptor&)
107- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_IR_ILU_TRUE_PARSE);
108-
109- #define GKO_DECLARE_ISAI_ILU_FALSE_PARSE (ValueType, IndexType ) \
110- typename Ilu<LowerIsai<ValueType, IndexType>, \
111- UpperIsai<ValueType, IndexType>, false , \
112- IndexType>::parameters_type \
113- ilu_parse<Ilu<LowerIsai<ValueType, IndexType>, \
114- UpperIsai<ValueType, IndexType>, false , IndexType>>( \
115- const config::pnode&, const config::registry&, \
59+ #define GKO_DECLARE_ILU_PARSE_TRUE (ValueType, IndexType ) \
60+ typename Ilu<ValueType, ValueType, true , IndexType>::parameters_type \
61+ ilu_parse<Ilu<ValueType, ValueType, true , IndexType>>( \
62+ const config::pnode&, const config::registry&, \
11663 const config::type_descriptor&)
117- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ISAI_ILU_FALSE_PARSE);
118-
119- #define GKO_DECLARE_ISAI_ILU_TRUE_PARSE (ValueType, IndexType ) \
120- typename Ilu<LowerIsai<ValueType, IndexType>, \
121- UpperIsai<ValueType, IndexType>, true , \
122- IndexType>::parameters_type \
123- ilu_parse<Ilu<LowerIsai<ValueType, IndexType>, \
124- UpperIsai<ValueType, IndexType>, true , IndexType>>( \
125- const config::pnode&, const config::registry&, \
126- const config::type_descriptor&)
127- GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ISAI_ILU_TRUE_PARSE);
64+
65+ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ILU_PARSE_FALSE);
66+ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ILU_PARSE_TRUE);
12867
12968
13069} // namespace detail
70+
71+
72+ // only instantiate the value type variants of ILU, whose solver is LinOp.
73+ #define GKO_DECLARE_ILU_FALSE (ValueType, IndexType ) \
74+ class Ilu <ValueType, ValueType, false , IndexType>
75+ #define GKO_DECLARE_ILU_TRUE (ValueType, IndexType ) \
76+ class Ilu <ValueType, ValueType, true , IndexType>
77+
78+ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ILU_FALSE);
79+ GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE (GKO_DECLARE_ILU_TRUE);
80+
81+
13182} // namespace preconditioner
13283} // namespace gko
0 commit comments