|
Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
|
#include <multigrid_solver.h>

Public Types | |
| enum | Exit_Status { Exit_Status::SUCCESS, Exit_Status::FAILURE, Exit_Status::SLOW, Exit_Status::ITERATE, Exit_Status::MAX_STEPS } |
Public Member Functions | |
| MultiGridSolver () | |
| MultiGridSolver (size_t N) | |
| MultiGridSolver (size_t N, bool verbose) | |
| MultiGridSolver (size_t N, size_t Nmin, bool verbose) | |
| size_t | get_istep () const |
| T * | get_y (size_t level=0) |
| T const * | get_y (size_t level=0) const |
| Grid< NDIM, T > & | get_grid (size_t level=0) |
| const Grid< NDIM, T > & | get_grid (size_t level=0) const |
| MultiGrid< NDIM, T > & | get_mlt_grid (size_t level=0) |
| const MultiGrid< NDIM, T > & | get_mlt_grid (size_t level=0) const |
| T * | get_external_field (size_t level, size_t field) |
| T const * | get_external_field (size_t level, size_t field) const |
| Grid< NDIM, T > & | get_external_grid (size_t level, size_t field) |
| const Grid< NDIM, T > & | get_external_grid (size_t level, size_t field) const |
| size_t | get_external_field_size () const |
| T | get_multigrid_source (size_t level, size_t i) const |
| void | set_epsilon (double eps_converge) |
| void | set_maxsteps (size_t maxsteps) |
| void | set_ngs_sweeps (size_t ngs_fine, size_t ngs_coarse) |
| void | set_convergence_criterion_residual (bool use_residual) |
| void | set_Nlevel (size_t N) |
| size_t | get_N (size_t level=0) const |
| size_t | get_Ntot (size_t level=0) const |
| size_t | get_Nlevel () const |
| void | add_external_grid (MultiGrid< NDIM, T > *field) |
| void | set_initial_guess (T guess) |
| void | set_initial_guess (T *guess) |
| void | set_initial_guess (Grid< NDIM, T > &guess) |
| Exit_Status | solve () |
| void | clear () |
| virtual T | upd_operator (const T f, const size_t level, const std::vector< size_t > &index_list, const T h) const |
| virtual T | l_operator (const size_t level, const std::vector< size_t > &index_list, bool addsource, const T h) const |
| virtual T | dl_operator (const size_t level, const std::vector< size_t > &index_list, const T h) const |
| virtual void | correct_sol (Grid< NDIM, T > &f, const Grid< NDIM, T > &corr, const size_t level) |
| virtual Exit_Status | check_convergence () |
| virtual void | check_solution (size_t level, Grid< NDIM, T > &sol) |
| void | check_solution (size_t level) |
Public Attributes | |
| bool | _store_all_residual = false |
| std::vector< double > | _res_domain_array |
Protected Member Functions | |
| void | get_neighbor_gridindex (std::vector< size_t > &index_list, size_t i, size_t ngrid) |
Protected Attributes | |
| bool | _verbose |
| bool | _conv_criterion_residual = true |
| double | _eps_converge = 1e-5 |
| size_t | _maxsteps = 1000 |
| size_t | _istep_vcycle = 0 |
| double | _rms_res |
| double | _rms_res_i |
| double | _rms_res_old |
Private Member Functions | |
| double | calculate_residual (size_t level, Grid< NDIM, T > &res) |
| void | prolonge_up_array (size_t to_level, Grid< NDIM, T > &BottomGrid, Grid< NDIM, T > &TopGrid) |
| void | make_prolongation_array (Grid< NDIM, T > &f, Grid< NDIM, T > &Rf, Grid< NDIM, T > &df) |
| void | GaussSeidelSweep (size_t level, size_t curcolor, T *f) |
| void | solve_current_level (size_t level) |
| void | recursive_go_up (size_t to_level) |
| void | recursive_go_down (size_t from_level) |
| void | make_new_source (size_t level) |
Private Attributes | |
| size_t | _N |
| size_t | _Ntot |
| size_t | _Nmin |
| size_t | _Nlevel |
| MultiGrid< NDIM, T > | _f |
| MultiGrid< NDIM, T > | _res |
| MultiGrid< NDIM, T > | _source |
| std::vector< MultiGrid< NDIM, T > * > | _ext_field |
| size_t | _ngs_coarse = 2 |
| size_t | _ngs_fine = 2 |
| size_t | _ngridcolours = 2 |
| size_t | _tot_sweeps_domain_grid = 0 |
Definition at line 48 of file multigrid_solver.h.
|
strong |
| Enumerator | |
|---|---|
| SUCCESS | |
| FAILURE | |
| SLOW | |
| ITERATE | |
| MAX_STEPS | |
Definition at line 105 of file multigrid_solver.h.
|
inline |
Definition at line 111 of file multigrid_solver.h.
Referenced by MultiGridSolver< 3, T >::MultiGridSolver().
|
inline |
Definition at line 112 of file multigrid_solver.h.
|
inline |
Definition at line 113 of file multigrid_solver.h.
| MultiGridSolver< NDIM, T >::MultiGridSolver | ( | size_t | N, |
| size_t | Nmin, | ||
| bool | verbose | ||
| ) |
Definition at line 209 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_N, MultiGridSolver< NDIM, T >::_Nlevel, MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_source, and power().
| void MultiGridSolver< NDIM, T >::add_external_grid | ( | MultiGrid< NDIM, T > * | field | ) |
Definition at line 160 of file multigrid_solver.cpp.
References MultiGrid< NDIM, T >::get_Nlevel().
Referenced by ContinuitySolver< NDIM, T >::ContinuitySolver(), MultiGridSolver< 3, T >::get_multigrid_source(), main(), and PoissonSolver< NDIM, T >::PoissonSolver().
|
private |
Definition at line 282 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::get_N(), MultiGridSolver< NDIM, T >::get_neighbor_gridindex(), MultiGridSolver< NDIM, T >::get_Ntot(), ccl_test_distances::h, MultiGridSolver< NDIM, T >::l_operator(), Grid< NDIM, T >::rms_norm(), and growth_allz::T.
Referenced by MultiGridSolver< NDIM, T >::recursive_go_up(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
virtual |
Reimplemented in anonymous_namespace{chameleon.cpp}::ChiSolver< T >.
Definition at line 311 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_conv_criterion_residual, MultiGridSolver< NDIM, T >::_eps_converge, MultiGridSolver< NDIM, T >::_istep_vcycle, MultiGridSolver< NDIM, T >::_maxsteps, MultiGridSolver< NDIM, T >::_rms_res, MultiGridSolver< NDIM, T >::_rms_res_i, MultiGridSolver< NDIM, T >::_rms_res_old, MultiGridSolver< NDIM, T >::_verbose, MultiGridSolver< NDIM, T >::ITERATE, MultiGridSolver< NDIM, T >::MAX_STEPS, and MultiGridSolver< NDIM, T >::SUCCESS.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
|
virtual |
Definition at line 370 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< NDIM, T >::check_solution(), MultiGridSolver< 3, T >::get_multigrid_source(), MultiGridSolver< NDIM, T >::recursive_go_down(), and MultiGridSolver< NDIM, T >::recursive_go_up().
| void MultiGridSolver< NDIM, T >::check_solution | ( | size_t | level | ) |
Definition at line 373 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::check_solution(), and MultiGridSolver< NDIM, T >::get_grid().
| void MultiGridSolver< NDIM, T >::clear | ( | ) |
Definition at line 644 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_ext_field, MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_N, MultiGridSolver< NDIM, T >::_Nlevel, MultiGridSolver< NDIM, T >::_Ntot, MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_res_domain_array, and MultiGridSolver< NDIM, T >::_source.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and main().
|
virtual |
Definition at line 565 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and MultiGridSolver< NDIM, T >::recursive_go_up().
|
virtual |
Reimplemented in anonymous_namespace{chameleon.cpp}::ChiSolver< T >.
Definition at line 56 of file multigrid_solver.cpp.
References ccl_test_distances::h, and growth_allz::T.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
|
private |
Definition at line 444 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_ngridcolours, MultiGridSolver< NDIM, T >::get_N(), MultiGridSolver< NDIM, T >::get_neighbor_gridindex(), MultiGridSolver< NDIM, T >::get_Ntot(), ccl_test_distances::h, growth_allz::T, and MultiGridSolver< NDIM, T >::upd_operator().
Referenced by MultiGridSolver< NDIM, T >::solve_current_level().
|
inline |
Definition at line 129 of file multigrid_solver.h.
Referenced by ContinuitySolver< NDIM, T >::dl_operator(), PoissonSolver< NDIM, T >::l_operator(), ContinuitySolver< NDIM, T >::l_operator(), and FofrSolver< NDIM, T >::l_operator().
|
inline |
Definition at line 130 of file multigrid_solver.h.
|
inline |
Definition at line 135 of file multigrid_solver.h.
|
inline |
Definition at line 132 of file multigrid_solver.h.
|
inline |
Definition at line 133 of file multigrid_solver.h.
|
inline |
Definition at line 122 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_solution(), main(), and anonymous_namespace{chameleon.cpp}::transform_MultiGridSolver_to_Mesh().
|
inline |
Definition at line 123 of file multigrid_solver.h.
|
inline |
Definition at line 116 of file multigrid_solver.h.
|
inline |
Definition at line 125 of file multigrid_solver.h.
|
inline |
Definition at line 126 of file multigrid_solver.h.
|
inline |
Definition at line 138 of file multigrid_solver.h.
Referenced by PoissonSolver< NDIM, T >::l_operator(), ContinuitySolver< NDIM, T >::l_operator(), and FofrSolver< NDIM, T >::l_operator().
| size_t MultiGridSolver< NDIM, T >::get_N | ( | size_t | level = 0 | ) | const |
Definition at line 194 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< NDIM, T >::calculate_residual(), MultiGridSolver< NDIM, T >::GaussSeidelSweep(), MultiGridSolver< 3, T >::get_multigrid_source(), main(), MultiGridSolver< NDIM, T >::make_new_source(), and MultiGridSolver< NDIM, T >::prolonge_up_array().
|
protected |
Definition at line 263 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< NDIM, T >::calculate_residual(), MultiGridSolver< NDIM, T >::GaussSeidelSweep(), and MultiGridSolver< NDIM, T >::make_new_source().
| size_t MultiGridSolver< NDIM, T >::get_Nlevel | ( | ) | const |
Definition at line 204 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
| size_t MultiGridSolver< NDIM, T >::get_Ntot | ( | size_t | level = 0 | ) | const |
Definition at line 199 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< NDIM, T >::calculate_residual(), MultiGridSolver< NDIM, T >::GaussSeidelSweep(), MultiGridSolver< 3, T >::get_multigrid_source(), MultiGridSolver< NDIM, T >::make_new_source(), and MultiGridSolver< NDIM, T >::prolonge_up_array().
| T * MultiGridSolver< NDIM, T >::get_y | ( | size_t | level = 0 | ) |
Definition at line 145 of file multigrid_solver.cpp.
Referenced by FofrSolver< NDIM, T >::dl_operator(), MultiGridSolver< 3, T >::get_istep(), PoissonSolver< NDIM, T >::l_operator(), ContinuitySolver< NDIM, T >::l_operator(), and FofrSolver< NDIM, T >::l_operator().
| T const * MultiGridSolver< NDIM, T >::get_y | ( | size_t | level = 0 | ) | const |
Definition at line 150 of file multigrid_solver.cpp.
|
virtual |
Reimplemented in anonymous_namespace{chameleon.cpp}::ChiSolver< T >.
Definition at line 24 of file multigrid_solver.cpp.
References ccl_test_distances::h, cl_cmbl_bm::l, and growth_allz::T.
Referenced by MultiGridSolver< NDIM, T >::calculate_residual(), MultiGridSolver< 3, T >::get_multigrid_source(), and MultiGridSolver< NDIM, T >::make_new_source().
|
private |
Definition at line 588 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_source, MultiGridSolver< NDIM, T >::get_N(), MultiGridSolver< NDIM, T >::get_neighbor_gridindex(), MultiGridSolver< NDIM, T >::get_Ntot(), ccl_test_distances::h, MultiGridSolver< NDIM, T >::l_operator(), and growth_allz::T.
Referenced by MultiGridSolver< NDIM, T >::recursive_go_down().
|
private |
Definition at line 578 of file multigrid_solver.cpp.
References Grid< NDIM, T >::get_Ntot().
Referenced by MultiGridSolver< NDIM, T >::recursive_go_up().
|
private |
Definition at line 381 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::get_N(), MultiGridSolver< NDIM, T >::get_Ntot(), m, and growth_allz::T.
Referenced by MultiGridSolver< NDIM, T >::recursive_go_up().
|
private |
Definition at line 612 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_Nlevel, MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_verbose, MultiGridSolver< NDIM, T >::check_solution(), MultiGridSolver< NDIM, T >::make_new_source(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 532 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_verbose, MultiGridSolver< NDIM, T >::calculate_residual(), MultiGridSolver< NDIM, T >::check_solution(), MultiGridSolver< NDIM, T >::correct_sol(), MultiGridSolver< NDIM, T >::make_prolongation_array(), MultiGridSolver< NDIM, T >::prolonge_up_array(), and MultiGridSolver< NDIM, T >::solve_current_level().
| void MultiGridSolver< NDIM, T >::set_convergence_criterion_residual | ( | bool | use_residual | ) |
Definition at line 171 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
| void MultiGridSolver< NDIM, T >::set_epsilon | ( | double | eps_converge | ) |
Definition at line 155 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and main().
| void MultiGridSolver< NDIM, T >::set_initial_guess | ( | T | guess | ) |
Definition at line 231 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_Ntot, and growth_allz::T.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and main().
| void MultiGridSolver< NDIM, T >::set_initial_guess | ( | T * | guess | ) |
Definition at line 237 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_Ntot, and growth_allz::T.
| void MultiGridSolver< NDIM, T >::set_initial_guess | ( | Grid< NDIM, T > & | guess | ) |
Definition at line 243 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_Ntot, Grid< NDIM, T >::get_y(), and growth_allz::T.
| void MultiGridSolver< NDIM, T >::set_maxsteps | ( | size_t | maxsteps | ) |
Definition at line 166 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
| void MultiGridSolver< NDIM, T >::set_ngs_sweeps | ( | size_t | ngs_fine, |
| size_t | ngs_coarse | ||
| ) |
Definition at line 176 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and main().
| void MultiGridSolver< NDIM, T >::set_Nlevel | ( | size_t | N | ) |
Definition at line 182 of file multigrid_solver.cpp.
References power().
Referenced by MultiGridSolver< 3, T >::get_multigrid_source().
| MultiGridSolver< NDIM, T >::Exit_Status MultiGridSolver< NDIM, T >::solve | ( | ) |
Definition at line 89 of file multigrid_solver.cpp.
Referenced by MultiGridSolver< 3, T >::get_multigrid_source(), and main().
|
private |
Definition at line 478 of file multigrid_solver.cpp.
References MultiGridSolver< NDIM, T >::_f, MultiGridSolver< NDIM, T >::_ngridcolours, MultiGridSolver< NDIM, T >::_ngs_coarse, MultiGridSolver< NDIM, T >::_ngs_fine, MultiGridSolver< NDIM, T >::_res, MultiGridSolver< NDIM, T >::_res_domain_array, MultiGridSolver< NDIM, T >::_rms_res, MultiGridSolver< NDIM, T >::_rms_res_old, MultiGridSolver< NDIM, T >::_store_all_residual, MultiGridSolver< NDIM, T >::_tot_sweeps_domain_grid, MultiGridSolver< NDIM, T >::_verbose, MultiGridSolver< NDIM, T >::calculate_residual(), and MultiGridSolver< NDIM, T >::GaussSeidelSweep().
Referenced by MultiGridSolver< NDIM, T >::recursive_go_down(), and MultiGridSolver< NDIM, T >::recursive_go_up().
|
virtual |
Reimplemented in anonymous_namespace{chameleon.cpp}::ChiSolver< T >.
Definition at line 77 of file multigrid_solver.cpp.
References cl_cmbl_bm::l, and growth_allz::T.
Referenced by MultiGridSolver< NDIM, T >::GaussSeidelSweep(), and MultiGridSolver< 3, T >::get_multigrid_source().
|
protected |
Definition at line 93 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence().
|
protected |
Definition at line 94 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence().
|
private |
Definition at line 63 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear().
|
private |
Definition at line 57 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), MultiGridSolver< 3, T >::get_mlt_grid(), MultiGridSolver< NDIM, T >::MultiGridSolver(), MultiGridSolver< NDIM, T >::recursive_go_down(), MultiGridSolver< NDIM, T >::recursive_go_up(), MultiGridSolver< NDIM, T >::set_initial_guess(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
protected |
Definition at line 96 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence(), and MultiGridSolver< 3, T >::get_istep().
|
protected |
Definition at line 95 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence().
|
private |
Definition at line 51 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), and MultiGridSolver< NDIM, T >::MultiGridSolver().
|
private |
Definition at line 68 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::GaussSeidelSweep(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 66 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 67 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 54 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), MultiGridSolver< NDIM, T >::MultiGridSolver(), and MultiGridSolver< NDIM, T >::recursive_go_down().
|
private |
Definition at line 53 of file multigrid_solver.h.
|
private |
Definition at line 52 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), and MultiGridSolver< NDIM, T >::set_initial_guess().
|
private |
Definition at line 58 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), MultiGridSolver< NDIM, T >::make_new_source(), MultiGridSolver< NDIM, T >::MultiGridSolver(), MultiGridSolver< NDIM, T >::recursive_go_down(), MultiGridSolver< NDIM, T >::recursive_go_up(), and MultiGridSolver< NDIM, T >::solve_current_level().
| std::vector<double> MultiGridSolver< NDIM, T >::_res_domain_array |
Definition at line 108 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
protected |
Definition at line 99 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
protected |
Definition at line 100 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence().
|
protected |
Definition at line 101 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence(), and MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 59 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::clear(), MultiGridSolver< NDIM, T >::make_new_source(), and MultiGridSolver< NDIM, T >::MultiGridSolver().
| bool MultiGridSolver< NDIM, T >::_store_all_residual = false |
Definition at line 107 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::solve_current_level().
|
private |
Definition at line 72 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::solve_current_level().
|
protected |
Definition at line 87 of file multigrid_solver.h.
Referenced by MultiGridSolver< NDIM, T >::check_convergence(), MultiGridSolver< NDIM, T >::recursive_go_down(), MultiGridSolver< NDIM, T >::recursive_go_up(), and MultiGridSolver< NDIM, T >::solve_current_level().