40 #include "hex-arrays.h" 109 void parse (
int argc,
char* argv[]);
392 std::vector<std::tuple<int,int,int>> instates,
outstates;
422 int L,
int S,
int Pi,
423 int ni,
int li,
int mi,
425 std::vector<std::pair<int,int>>
const & ang,
426 std::vector<std::pair<int,int>>
const & chann = std::vector<std::pair<int,int>>(),
427 std::string prefix =
"psi" 428 ) : L_(L), S_(S), Pi_(Pi),
429 ni_(ni), li_(li), mi_(mi),
430 E_(E), ang_(ang), prefix_(prefix)
435 chann_.resize(ang.size(), std::make_pair(0,0));
440 if (ang.size() != chann.size())
441 HexException(
"Incompatible size of angular momentum pairs list and channel count list.");
449 static const int All = -1;
455 return format(
"%s-%g-%d-%d-%d-%d-%d-%d.hdf", prefix_.c_str(), E_ + 1, L_, S_, Pi_, ni_, li_, mi_);
457 return format(
"%s-%g-%d-%d-%d-%d-%d-%d-(%d,%d).hdf", prefix_.c_str(), E_ + 1, L_, S_, Pi_, ni_, li_, mi_, ang_[ill].first, ang_[ill].second);
461 bool check (
int ill, std::size_t & total_size)
const 466 HDFFile fsingle (name(ill), HDFFile::readonly);
467 return fsingle.valid() ? fsingle.size(
"array")/2 : 0;
471 std::vector<std::size_t> size (ang_.size());
472 for (
unsigned illp = 0; illp < ang_.size(); illp++)
474 HDFFile fsingle (name(illp), HDFFile::readonly);
475 size[illp] = (fsingle.valid() ? fsingle.size(
"array")/2 : 0);
479 total_size = std::accumulate(size.begin(), size.end(), 0);
482 return std::find(size.begin(), size.end(), 0) == size.end();
486 std::size_t total_size = 0;
487 return check(ill, total_size);
505 iArray segments_to_load = { ill };
507 segments_to_load = linspace<int>(0, solution.size() - 1, solution.size());
510 for (
int i : segments_to_load)
516 HDFFile hdf (name(), HDFFile::readonly);
520 std::size_t segsize = hdf.size(
"array") / ang_.size();
523 solution[i].resize(segsize);
526 if (not hdf.read(
"array", solution[i].data(), segsize, i * segsize))
530 if (not solution.inmemory())
544 if (not solution[i].hdfload(name(i)))
548 if (not solution.inmemory())
555 HDFFile hdf (name(i), HDFFile::readonly);
558 hdf.read(
"Nchan1", &chann_[i].first, 1);
559 hdf.read(
"Nchan2", &chann_[i].second, 1);
578 iArray segments_to_save = { ill };
580 segments_to_save = linspace<int>(0, solution.size() - 1, solution.size());
583 for (
int iseg : segments_to_save)
586 if (not solution.inmemory())
587 const_cast<BlockArray<Complex>&
>(solution).hdfload(iseg);
590 if (not save_segment(solution[iseg], iseg))
594 if (not solution.inmemory())
595 const_cast<BlockArray<Complex>&
>(solution)[iseg].drop();
605 HDFFile hdf (name(ill), HDFFile::overwrite);
613 success = (success and hdf.write(
"L", &L_, 1));
614 success = (success and hdf.write(
"S", &S_, 1));
615 success = (success and hdf.write(
"Pi", &Pi_, 1));
616 success = (success and hdf.write(
"ni", &ni_, 1));
617 success = (success and hdf.write(
"li", &li_, 1));
618 success = (success and hdf.write(
"mi", &mi_, 1));
619 success = (success and hdf.write(
"E", &E_, 1));
620 success = (success and hdf.write(
"l1", &ang_[ill].first, 1));
621 success = (success and hdf.write(
"l2", &ang_[ill].second, 1));
622 success = (success and hdf.write(
"Nchan1", &chann_[ill].first, 1));
623 success = (success and hdf.write(
"Nchan2", &chann_[ill].second, 1));
624 success = (success and hdf.write(
"array", solution.data(), solution.size()));
628 std::vector<std::pair<int,int>>
const &
channels ()
const {
return chann_; }
632 int L_, S_, Pi_, ni_, li_, mi_;
634 std::vector<std::pair<int,int>> ang_, chann_;
662 std::vector<std::pair<int,int>>
const & ll
671 std::string
const & basename
bool check(int ill, std::size_t &total_size) const
Check that the file exists.
Definition: io.h:461
Real prec_itertol
Tolerance for terminating block preconditioner.
Definition: io.h:162
bool extract_extrapolate
Whether to radially extrapolate the extracted T-matrix.
Definition: io.h:216
void zip_solution(CommandLine const &cmd, InputFile const &inp, Parallel const &par, Bspline const &bspline_inner, Bspline const &bspline_full, std::vector< std::pair< int, int >> const &ll)
Convert solution to VTK file.
Definition: io.cpp:1107
int max_sub_iter
Maximal number of sub-preconditioner iterations.
Definition: io.h:204
bool analytic_eigenstates
Use analytic eigenstates instead of those obtained by diagonalization.
Definition: io.h:285
bool parallel
Whether to use MPI.
Definition: io.h:134
bool outofcore
Whether to keep precomputed data only on disk and spare RAM.
Definition: io.h:146
Real ssor
Apply SSOR coupling.
Definition: io.h:237
void write_grid(Bspline const &bspline, std::string const &basename)
Write grid to a VTK file.
Definition: io.cpp:1307
CommandLine(int argc, char *argv[])
Definition: io.h:86
int dom_y_panels
Definition: io.h:273
std::string dom_preconditioner
Domain preconditioner.
Definition: io.h:276
bool cont
Whether to continue out-of-core computation from last computed solution (needs corresponding ooc file...
Definition: io.h:149
bool cache_all_radint
Whether to keep radial integrals in memory.
Definition: io.h:155
int hyb_additional_levels
Additional levels to be solved by ILU preconditioner when using HYB preconditioner.
Definition: io.h:264
bool carry_initial_guess
Whether to use previous-energy solution as an initial guess.
Definition: io.h:210
Extract the T-matrices.
Definition: io.h:82
int itinerary
Which parts of the computation to run.
Definition: io.h:143
A B-spline expansion of a solution to "zip". See Bspline::zip .
Definition: io.h:122
bool mumps_outofcore
MUMPS out of core.
Definition: io.h:249
int parallel_factorization
Allow parallel factorization.
Definition: io.h:195
B-spline environment.
Definition: bspline.h:57
int nY
Definition: io.h:129
int nX
Definition: io.h:129
std::string scratch
Scratch directory for out-of-core data.
Definition: io.h:282
bool refine_solution
Load also existing solutions and check that they are within tolerance.
Definition: io.h:228
int groupsize
Size of the local MPI communicator, used for distributed SuperLU.
Definition: io.h:192
Real Ymax
Definition: io.h:128
std::string preconditioner
Preconditioner to use.
Definition: io.h:137
std::string factorizer
LU-factorizer.
Definition: io.h:189
bool save(BlockArray< Complex > const &solution, int ill=SolutionIO::All) const
Write solution to disk.
Definition: io.h:575
bool fail_on_sub_iter
Stop with error message when sub-preconditioner fails to converge.
Definition: io.h:207
bool write_intermediate_solutions
Write intermediate solutions.
Definition: io.h:258
int extract_samples
Extraction averaging/extrapolation sample count.
Definition: io.h:225
Solution input/output class.
Definition: io.h:414
std::string map_solution_target
Target mapping basis.
Definition: io.h:234
static const int All
All blocks flag.
Definition: io.h:449
Real itertol
Tolerance for terminating iterative solution.
Definition: io.h:159
bool lightweight_radial_cache
Definition: io.h:171
bool kpa_simple_rad
Use simplified radial integral matrix for nested KPA iterations (experimental).
Definition: io.h:180
bool gpu_host_multiply
Keep vectors in host memory when doing multiplication on GPU.
Definition: io.h:246
Command line parameters.
Definition: io.h:57
struct CommandLine::s_zipdata zipdata
std::vector< std::pair< int, int > > const & channels() const
Definition: io.h:628
bool fast_bessel
Use faster Bessel function evaluation routine (not the Steed/Barnett) when calculating RHS...
Definition: io.h:261
s_zipdata()
Definition: io.h:125
bool gpu_multiply
Do the sparse matrix multiplication on the OpenCL device (memory intensive!).
Definition: io.h:213
int mumps_verbose
MUMPS diagnostic information.
Definition: io.h:252
unsigned ocl_device
Index of OpenCL device to use.
Definition: io.h:186
unsigned ocl_platform
Index of OpenCL platform to use.
Definition: io.h:183
Solve the equations.
Definition: io.h:80
bool noluupdate
Keep calculated LU also for next energy.
Definition: io.h:240
bool reuse_dia_blocks
Whether to use diagonal blocks as present in the scratch directory. (For debugging purposes only...
Definition: io.h:177
Compute only the radial integrals necessary for the construction of the equations.
Definition: io.h:78
bool runtime_postprocess
Calculate T-matrices after every iteration.
Definition: io.h:288
Real extract_rho
Extraction radius.
Definition: io.h:219
bool gpu_large_data
Keep large data in RAM instead of copying to the OpenCL compute device.
Definition: io.h:168
std::string file
Definition: io.h:127
void parse(int argc, char *argv[])
Read options from command line.
Definition: io.cpp:145
bool writegrid
Definition: io.h:119
std::string name(int ill=SolutionIO::All) const
Get name of the solution file.
Definition: io.h:452
HexEcsStg
Stages of the computations.
Definition: io.h:74
bool lightweight_full
Whether to avoid explicitly calculating big matrices and only apply them on the fly.
Definition: io.h:171
MPI info.
Definition: parallel.h:50
std::vector< std::string > map_solution
Map solution between different B-spline bases.
Definition: io.h:231
bool save_segment(const cArrayView solution, int ill) const
Definition: io.h:602
SolutionIO()
Definition: io.h:418
Real extract_rho_begin
Radial distance where to start radial averaging/extrapolation of the T-matrix.
Definition: io.h:222
bool wholematrix
Whether to load full matrix from scratch disk at once when calculating dot product (and not by parts)...
Definition: io.h:152
bool check(int ill=SolutionIO::All) const
Definition: io.h:484
int multigrid_depth
Depth of the geometric multigrid.
Definition: io.h:267
bool load(BlockArray< Complex > &solution, int ill=SolutionIO::All)
Load the solution from disk.
Definition: io.h:498
int coupling_limit
Maximal multipole considered by the coupled preconditioner.
Definition: io.h:243
Real Ymin
Definition: io.h:128
Do not start any intensive computations.
Definition: io.h:76
int multigrid_coarse_prec
What preconditioner to use for solution of the coarse problem.
Definition: io.h:270
bool shared_scratch
Whether to compute only a subset of radial integrals in shared scratch architecture.
Definition: io.h:174
int ilu_max_iter
Maximal number of ILU iterations for hybrid preconditioner.
Definition: io.h:201
Real Xmin
Definition: io.h:128
bool cache_own_radint
Definition: io.h:156
int dom_sweeps
Domain decomposition sweeps.
Definition: io.h:279
Real Xmax
Definition: io.h:128
bool parallel_precondition
Whether to use OpenMP parallelization to run preconditioner for several blocks simultaneously.
Definition: io.h:165
Real droptol
Drop tolerance for the ILU preconditioner.
Definition: io.h:140
std::ifstream inputfile
Alternative name for the input file. Default is "hex.inp".
Definition: io.h:116
int dom_x_panels
Domain decomposition panels.
Definition: io.h:273
Real kpa_drop
Whether to use drop tolerance for KPA preconditioner.
Definition: io.h:255
bool sub_prec_verbose
Verbosity of the sub-preconditioner.
Definition: io.h:291
int parallel_extraction
Allow parallel extraction.
Definition: io.h:198