TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
142 stars 72 forks source link

Cartesian Product Mesh Point Generators #319

Closed max91219 closed 7 years ago

max91219 commented 8 years ago

Hi,

I'm having some problems using the mesh_pt_generator, I can use it fine when the mesh is just a standard imfreq mesh however, once I try and use a product mesh (specifically imfreq,imfreq,imfreq) the to_point() function causes the code to not compile. I was wondering if you could point me in the direction of how to use the mesh_pt_generator correctly for product meshes?

I have attached below some code that reproduces the problem along with the corresponding compiler output:

code:

triqs::mpi::environment env(argc, argv);
triqs::mpi::communicator world;

double beta = 20;
int n_iw = 100;
int dim = 2;
int rank = world.rank();

gf<cartesian_product<imfreq, imfreq, imfreq>> g4_w{{
        {beta, Fermion, n_iw},
        {beta, Fermion, n_iw},
        {beta, Boson, 25}}, {dim,dim}};

auto G4_w = make_block_gf(1,g4_w);
auto mesh = G4_w[0].mesh();
auto N = mesh.size();
auto slice = triqs::mpi::slice_range(0,N,world.size(),world.rank());
auto mpg = triqs::gfs::mesh_pt_generator<gf_mesh<cartesian_product<imfreq,imfreq,imfreq>>>(&G4_w[0].mesh());

mpg += slice.first;
mpg.to_point(); 

Compiler:

/u/del/bras3786/ClionProjects/TRIQS_PlAYGROUND/main.cpp:28:18:   required from here
/u/del/bras3786/TRIQS_1.4/include/triqs/gfs/./meshes/product.hpp:158:60: error: no matching function for call to ‘triqs::gfs::gf_mesh<triqs::gfs::cartesian_product<triqs::gfs::imfreq, triqs::gfs::imfreq, triqs::gfs::imfreq> >::index_to_point(<unresolved overloaded function type>) const’
    operator cast_t() const { return m->index_to_point(index); }

/u/del/bras3786/ClionProjects/TRIQS_PlAYGROUND/main.cpp:28:18:   required from here
/u/del/bras3786/TRIQS_1.4/include/triqs/gfs/./meshes/product.hpp:158:60: error: no matching function for call to ‘triqs::gfs::gf_mesh<triqs::gfs::cartesian_product<triqs::gfs::imfreq, triqs::gfs::imfreq, triqs::gfs::imfreq> >::index_to_point(<unresolved overloaded function type>) const’
    operator cast_t() const { return m->index_to_point(index); }

/u/del/bras3786/ClionProjects/TRIQS_PlAYGROUND/main.cpp:28:18:   required from here
/u/del/bras3786/TRIQS_1.4/include/triqs/gfs/./meshes/product.hpp:158:60: error: no matching function for call to ‘triqs::gfs::gf_mesh<triqs::gfs::cartesian_product<triqs::gfs::imfreq, triqs::gfs::imfreq, triqs::gfs::imfreq> >::index_to_point(<unresolved overloaded function type>) const’
    operator cast_t() const { return m->index_to_point(index); }

Many Thanks,

Max

krivenko commented 8 years ago

Hi Max, I've committed a simple fix (704ff0a64db906bbde6266a13c86ff71d7ef67ee), which should make your code compile. Regardless of it being a solution to your problem, I'd like to keep this issue open until the fix is reviewed by Olivier @parcollet for correctness and generality.

max91219 commented 8 years ago

Hi Igor, thank you for the timely reply and fix, this has solved my issue. I will leave the issue open as you have requested. thanks, Max

parcollet commented 7 years ago

Fine.