Skip to content

Commit

Permalink
remove fixed_coarsening
Browse files Browse the repository at this point in the history
Co-authored-by: Marcel Koch <[email protected]>
  • Loading branch information
yhmtsai and MarcelKoch committed May 14, 2024
1 parent 4c8e74c commit ad4316e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 64 deletions.
6 changes: 3 additions & 3 deletions core/config/multigrid_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
//
// SPDX-License-Identifier: BSD-3-Clause

#include <core/config/parse_marco.hpp>


#include <ginkgo/core/base/exception_helpers.hpp>
#include <ginkgo/core/config/config.hpp>
#include <ginkgo/core/config/registry.hpp>
#include <ginkgo/core/multigrid/fixed_coarsening.hpp>
#include <ginkgo/core/multigrid/pgm.hpp>


#include "core/config/config_helper.hpp"
#include "core/config/dispatch.hpp"
#include "core/config/parse_marco.hpp"
#include "core/config/type_descriptor_helper.hpp"


Expand All @@ -20,7 +21,6 @@ namespace config {


PARSE_VALUE_AND_INDEX_TYPE(Pgm, gko::multigrid::Pgm);
PARSE_VALUE_AND_INDEX_TYPE(FixedCoarsening, gko::multigrid::FixedCoarsening);


} // namespace config
Expand Down
15 changes: 0 additions & 15 deletions core/multigrid/fixed_coarsening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ GKO_REGISTER_OPERATION(fill_seq_array, components::fill_seq_array);
} // namespace fixed_coarsening


template <typename ValueType, typename IndexType>
typename FixedCoarsening<ValueType, IndexType>::parameters_type
FixedCoarsening<ValueType, IndexType>::parse(
const config::pnode& config, const config::registry& context,
const config::type_descriptor& td_for_child)
{
auto factory = FixedCoarsening<ValueType, IndexType>::build();
// TODO: ARRAY
if (auto& obj = config.get("skip_sorting")) {
factory.with_skip_sorting(gko::config::get_value<bool>(obj));
}
return factory;
}


template <typename ValueType, typename IndexType>
void FixedCoarsening<ValueType, IndexType>::generate()
{
Expand Down
24 changes: 2 additions & 22 deletions core/solver/multigrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,6 @@ void MultigridState::run_cycle(multigrid::cycle cycle, size_type level,
} // namespace multigrid


std::function<size_type(const size_type, const LinOp*)> get_selector(
std::string key)
{
static std::map<std::string,
std::function<size_type(const size_type, const LinOp*)>>
selector_map{
{{"first_for_top", [](const size_type level, const LinOp*) {
return (level == 0) ? 0 : 1;
}}}};
return selector_map.at(key);
}


typename Multigrid::parameters_type Multigrid::parse(
const config::pnode& config, const config::registry& context,
const config::type_descriptor& td_for_child)
Expand All @@ -595,9 +582,6 @@ typename Multigrid::parameters_type Multigrid::parse(
gko::config::get_factory_vector<const gko::LinOpFactory>(
obj, context, td_for_child));
}
if (auto& obj = config.get("level_selector")) {
factory.with_level_selector(get_selector(obj.get_string()));
}
if (auto& obj = config.get("pre_smoother")) {
factory.with_pre_smoother(
gko::config::get_factory_vector<const LinOpFactory>(obj, context,
Expand Down Expand Up @@ -627,7 +611,7 @@ typename Multigrid::parameters_type Multigrid::parse(
} else if (str == "standalone") {
factory.with_mid_case(multigrid::mid_smooth_type::standalone);
} else {
GKO_INVALID_STATE("Not valid mid_smooth_type value");
GKO_INVALID_CONFIG_VALUE("mid_smooth_type", str);
}
}
if (auto& obj = config.get("max_levels")) {
Expand All @@ -641,10 +625,6 @@ typename Multigrid::parameters_type Multigrid::parse(
gko::config::get_factory_vector<const LinOpFactory>(obj, context,
td_for_child));
}
if (auto& obj = config.get("solver_selector")) {
auto str = obj.get_string();
factory.with_solver_selector(get_selector(str));
}
if (auto& obj = config.get("cycle")) {
auto str = obj.get_string();
if (str == "v") {
Expand All @@ -654,7 +634,7 @@ typename Multigrid::parameters_type Multigrid::parse(
} else if (str == "f") {
factory.with_cycle(multigrid::cycle::f);
} else {
GKO_INVALID_STATE("Not valid cycle value");
GKO_INVALID_CONFIG_VALUE("cycle", str);
}
}
if (auto& obj = config.get("kcycle_base")) {
Expand Down
19 changes: 0 additions & 19 deletions include/ginkgo/core/multigrid/fixed_coarsening.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <ginkgo/core/base/exception_helpers.hpp>
#include <ginkgo/core/base/lin_op.hpp>
#include <ginkgo/core/base/types.hpp>
#include <ginkgo/core/config/config.hpp>
#include <ginkgo/core/config/registry.hpp>
#include <ginkgo/core/matrix/csr.hpp>
#include <ginkgo/core/matrix/dense.hpp>
#include <ginkgo/core/multigrid/multigrid_level.hpp>
Expand Down Expand Up @@ -86,23 +84,6 @@ class FixedCoarsening
GKO_ENABLE_LIN_OP_FACTORY(FixedCoarsening, parameters, Factory);
GKO_ENABLE_BUILD_METHOD(Factory);

/**
* Create the parameters from the property_tree.
* Because this is directly tied to the specific type. The value/index type
* settings are ignored and type_descriptor is for children objects.
*
* @param config the property tree for setting
* @param context the registry
* @param td_for_child the type descriptor for children objects. The
* default will directly from the specific type.
*
* @return parameters
*/
static parameters_type parse(
const config::pnode& config, const config::registry& context,
const config::type_descriptor& td_for_child =
config::make_type_descriptor<ValueType, IndexType>());

protected:
void apply_impl(const LinOp* b, LinOp* x) const override
{
Expand Down
6 changes: 4 additions & 2 deletions include/ginkgo/core/multigrid/pgm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <ginkgo/core/base/types.hpp>
#include <ginkgo/core/config/config.hpp>
#include <ginkgo/core/config/registry.hpp>
#include <ginkgo/core/config/type_descriptor.hpp>
#include <ginkgo/core/distributed/matrix.hpp>
#include <ginkgo/core/matrix/csr.hpp>
#include <ginkgo/core/matrix/dense.hpp>
Expand Down Expand Up @@ -134,12 +135,13 @@ class Pgm : public EnableLinOp<Pgm<ValueType, IndexType>>,
/**
* Create the parameters from the property_tree.
* Because this is directly tied to the specific type. The value/index type
* settings are ignored and type_descriptor is for children objects.
* settings within config are ignored and type_descriptor is only used
* for children objects.
*
* @param config the property tree for setting
* @param context the registry
* @param td_for_child the type descriptor for children objects. The
* default will directly from the specific type.
* default uses the value/index type of this class.
*
* @return parameters
*/
Expand Down
7 changes: 4 additions & 3 deletions include/ginkgo/core/solver/multigrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <ginkgo/core/base/types.hpp>
#include <ginkgo/core/config/config.hpp>
#include <ginkgo/core/config/registry.hpp>
#include <ginkgo/core/config/type_descriptor.hpp>
#include <ginkgo/core/log/logger.hpp>
#include <ginkgo/core/matrix/dense.hpp>
#include <ginkgo/core/matrix/identity.hpp>
Expand Down Expand Up @@ -384,12 +385,12 @@ class Multigrid : public EnableLinOp<Multigrid>,
/**
* Create the parameters from the property_tree.
* Because this is directly tied to the specific type. The value/index type
* settings are ignored and type_descriptor is for children objects.
* settings within config are ignored and type_descriptor is only used
* for children objects.
*
* @param config the property tree for setting
* @param context the registry
* @param td_for_child the type descriptor for children objects. The
* default will directly from the specific type.
* @param td_for_child the type descriptor for children objects
*
* @return parameters
*/
Expand Down

0 comments on commit ad4316e

Please sign in to comment.