20#ifndef __ULTRASOFT_PRECOND_HPP__
21#define __ULTRASOFT_PRECOND_HPP__
26#include <nlcglib/interface.hpp>
28#include "preconditioner/ultrasoft_precond_k.hpp"
39class UltrasoftPrecond :
public nlcglib::UltrasoftPrecondBase
42 using key_t = std::pair<int, int>;
43 using numeric_t = std::complex<double>;
44 using op_t = Ultrasoft_preconditioner<numeric_t>;
47 using buffer_t = nlcglib::MatrixBaseZ::buffer_t;
50 UltrasoftPrecond(
const K_point_set& kset, Simulation_context& ctx,
const Q_operator<double>& q_op);
52 virtual void apply(
const key_t& key, buffer_t& out, buffer_t& in)
const override;
53 virtual std::vector<std::pair<int, int>> get_keys()
const override;
56 std::map<key_t, std::shared_ptr<op_t>> data_;
59inline UltrasoftPrecond::UltrasoftPrecond(K_point_set
const& kset, Simulation_context& ctx,
60 Q_operator<double>
const& q_op)
62 for (
auto it : kset.spl_num_kpoints()) {
63 auto& kp = *kset.get<
double>(it.i);
64 for (
int ispn = 0; ispn < ctx.num_spins(); ++ispn) {
65 key_t
key{it.i.get(), ispn};
66 data_[
key] = std::make_shared<op_t>(ctx, q_op, ispn, kp.beta_projectors(), kp.gkvec());
72UltrasoftPrecond::apply(
const key_t& key, buffer_t& out, buffer_t& in)
const
74 auto& op = data_.at(key);
75 auto array_out = make_matrix_view(out);
76 auto array_in = make_matrix_view(in);
77 sddk::memory_t pm = out.memtype == nlcglib::memory_type::host ? sddk::memory_t::host : sddk::memory_t::device;
78 op->apply(array_out, array_in, pm);
81inline std::vector<std::pair<int, int>>
82UltrasoftPrecond::get_keys()
const
84 std::vector<key_t> keys;
85 for (
auto& elem : data_) {
86 keys.push_back(elem.first);
Contains defintion of nlcglib interface.
Contains declaration and partial implementation of sirius::K_point_set class.
Memory management functions and classes.
@ key
the parser read a key of a value in an object
op_t
Tyoe of MPI reduction.
Namespace of the SIRIUS library.
Contains declaration of sirius::Non_local_operator class.
Contains definition and implementation of Simulation_context class.