12 #include "lattice/fine_qdpxx/mg_params_qdpxx.h"
13 #include "lattice/fine_qdpxx/mg_level_qdpxx.h"
14 #include "lattice/fine_qdpxx/vcycle_recursive_qdpxx.h"
15 #include "lattice/fine_qdpxx/wilson_clover_linear_operator.h"
20 using std::shared_ptr;
21 using std::make_shared;
28 namespace MGProtoHelpers {
30 shared_ptr<const MG::QDPWilsonCloverLinearOperator>
33 shared_ptr<const MG::QDPWilsonCloverLinearOperator> M_fine=
nullptr;
36 double m_q=toDouble(
params.CloverParams.Mass);
37 double u0 = toDouble(
params.CloverParams.u0);
40 int t_bc =
params.AntiPeriodicT ? -1 : 1; - ignore as links already have BC on.
46 double c_sw=toDouble(
params.CloverParams.clovCoeffR);
47 M_fine = make_shared<const MG::QDPWilsonCloverLinearOperator>(m_q,c_sw,t_bc,
u);
50 QDPIO::cout <<
"Using aniso interface" << std::endl;
52 double xi0 = toDouble(
params.CloverParams.anisoParam.xi_0);
53 double nu=toDouble(
params.CloverParams.anisoParam.nu);
54 double c_sw_r = toDouble(
params.CloverParams.clovCoeffR);
55 double c_sw_t = toDouble(
params.CloverParams.clovCoeffT);
56 M_fine = make_shared<const MG::QDPWilsonCloverLinearOperator>(m_q,
u0,xi0,
nu,c_sw_r,c_sw_t,t_bc,
u);
71 QDPIO::cout <<
"Creating MG_Proto preconditioner with subspaceID=" << subspaceId << std::endl;
73 QDPIO::cout <<
"Looking Up " << subspaceId <<
" in the Named Onject Map" << std::endl;
74 if( TheNamedObjMap::Instance().check(subspaceId) ) {
76 QDPIO::cout <<
" ... Subspace ID found... Deleting" <<std::endl;
82 shared_ptr<MG::MultigridLevels> mg_levels = make_shared<MG::MultigridLevels>();
85 QDPIO::cout <<
"Creating M..." ;
88 QDPIO::cout <<
"Done" << std::endl;
89 QDPIO::cout <<
"Creating MG Levels ... " ;
90 MG::SetupParams level_params;
91 int n_levels =
params.MGLevels;
92 level_params.n_levels = n_levels;
93 level_params.n_vecs.resize(n_levels-1);
94 level_params.null_solver_max_iter.resize(n_levels-1);
95 level_params.null_solver_rsd_target.resize(n_levels -1);
96 level_params.null_solver_verboseP.resize(n_levels -1);
97 for(
int l=0;
l < n_levels-1;++
l) {
98 QDPIO::cout <<
"Level L=" <<
l <<
" Null Vecs=" <<
params.NullVecs[
l] << std::endl;
100 level_params.n_vecs[
l] =
params.NullVecs[
l];
101 level_params.null_solver_max_iter[
l]=
params.NullSolverMaxIters[
l];
102 level_params.null_solver_rsd_target[
l]=toDouble(
params.NullSolverRsdTarget[
l]);
103 level_params.null_solver_verboseP[
l]=toDouble(
params.NullSolverVerboseP[
l]);
105 level_params.block_sizes.resize(n_levels-1);
106 for(
int l=0;
l < n_levels-1;++
l) {
107 for(
int mu=0;
mu < 4; ++
mu) {
108 (level_params.block_sizes[
l])[
mu] = (
params.Blocking[
l])[
mu];
112 MG::SetupMGLevels(level_params, *mg_levels, M_fine );
113 QDPIO::cout <<
"... Done " << std::endl;
115 QDPIO::cout <<
"Creating VCycle Parameters..." << std::endl;
116 vector<MG::VCycleParams> v_params(n_levels-1);
117 for(
int l=0;
l < n_levels-1;++
l) {
118 QDPIO::cout <<
" Level " <<
l << std::endl;
119 v_params[
l].pre_smoother_params.MaxIter=
params.VCyclePreSmootherMaxIters[
l];
120 v_params[
l].pre_smoother_params.RsdTarget=toDouble(
params.VCyclePreSmootherRsdTarget[
l]);
121 v_params[
l].pre_smoother_params.VerboseP =
params.VCyclePreSmootherVerboseP[
l];
122 v_params[
l].pre_smoother_params.Omega =toDouble(
params.VCyclePreSmootherRelaxOmega[
l]);
124 v_params[
l].post_smoother_params.MaxIter=
params.VCyclePostSmootherMaxIters[
l];
125 v_params[
l].post_smoother_params.RsdTarget=toDouble(
params.VCyclePostSmootherRsdTarget[
l]);
126 v_params[
l].post_smoother_params.VerboseP =
params.VCyclePostSmootherVerboseP[
l];
127 v_params[
l].post_smoother_params.Omega =toDouble(
params.VCyclePostSmootherRelaxOmega[
l]);
129 v_params[
l].bottom_solver_params.MaxIter=
params.VCycleBottomSolverMaxIters[
l];
130 v_params[
l].bottom_solver_params.NKrylov =
params.VCycleBottomSolverNKrylov[
l];
131 v_params[
l].bottom_solver_params.RsdTarget= toDouble(
params.VCycleBottomSolverRsdTarget[
l]);
132 v_params[
l].bottom_solver_params.VerboseP =
params.VCycleBottomSolverVerboseP[
l];
134 v_params[
l].cycle_params.MaxIter=
params.VCycleMaxIters[
l];
135 v_params[
l].cycle_params.RsdTarget=toDouble(
params.VCycleRsdTarget[
l]);
136 v_params[
l].cycle_params.VerboseP =
params.VCycleVerboseP[
l];
139 QDPIO::cout <<
"Creating VCycle Preconditioner...";
141 shared_ptr<MG::VCycleRecursiveQDPXX> v_cycle=make_shared<MG::VCycleRecursiveQDPXX>(v_params, *mg_levels);
143 QDPIO::cout <<
"Done";
145 QDPIO::cout <<
"Saving in Map" << std::endl;
146 QDPIO::cout <<
"Creating Named Object Map Entry for subspace" << std::endl;
147 XMLBufferWriter file_xml;
148 push(file_xml,
"FileXML");
151 XMLBufferWriter record_xml;
152 push(record_xml,
"RecordXML");
156 TheNamedObjMap::Instance().create<shared_ptr<MGPreconditioner>>(subspaceId);
157 TheNamedObjMap::Instance().get(subspaceId).setFileXML(file_xml);
158 TheNamedObjMap::Instance().get(subspaceId).setRecordXML(record_xml);
159 TheNamedObjMap::Instance().getData<shared_ptr<MGPreconditioner>>(subspaceId)=make_shared<MGPreconditioner>();
160 TheNamedObjMap::Instance().getData<shared_ptr<MGPreconditioner>>(subspaceId)->mg_levels = mg_levels;
161 TheNamedObjMap::Instance().getData<shared_ptr<MGPreconditioner>>(subspaceId)->v_cycle = v_cycle;
164 QDPIO::cout <<
"MG_PROTO_SETUP: Subspace Creation Took : " << swatch.getTimeInSeconds() <<
" sec" << std::endl;
172 QDPIO::cout <<
"Deleting MG_Proto preconditioner with subspaceID=" << subspaceId << std::endl;
174 QDPIO::cout <<
"Looking Up " << subspaceId <<
" in the Named Onject Map" << std::endl;
175 if( TheNamedObjMap::Instance().check(subspaceId) ) {
177 QDPIO::cout <<
" ... Subspace ID found... Deleting" <<std::endl;
183 TheNamedObjMap::Instance().erase(subspaceId);
189 shared_ptr<MGPreconditioner> ret_val =
nullptr;
190 if( TheNamedObjMap::Instance().check(subspaceId) ) {
192 QDPIO::cout <<
" ... Subspace ID found... returning" <<std::endl;
198 ret_val = TheNamedObjMap::Instance().getData<shared_ptr<MGPreconditioner>>(subspaceId);
202 QDPIO::cout <<
"Object Not Found... Returning Null" << std::endl;
Primary include file for CHROMA library code.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
Named object function std::map.
shared_ptr< MGPreconditioner > getMGPreconditioner(const std::string &subspaceId)
shared_ptr< const MG::QDPWilsonCloverLinearOperator > createFineLinOp(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u)
void createMGPreconditioner(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u)
void deleteMGPreconditioner(const std::string &subspaceId)
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
push(xml_out,"Cooled_Topology")