CHROMA
syssolver_qop_mg_params.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Parameters for the external QDP clover multigrid solver
3  */
4 
6 
7 namespace Chroma
8 {
9 
10  // Read parameters
11  void read(XMLReader& xml, const std::string& path, SysSolverQOPMGParams& param)
12  {
13  XMLReader paramtop(xml, path);
14 
15 #define defaultread(PARAM,DEFAULT) if (paramtop.count(#PARAM)) {read(paramtop, #PARAM, param.PARAM);} else {param.PARAM = DEFAULT;}
16 
17  defaultread( AnisoXi, 1.0 );
18  defaultread( AnisoNu, 1.0 );
19 
20  if (paramtop.count("Mass") > 0) {
21  read(paramtop, "Mass", param.Mass);
22  param.Kappa = 0.5/(1.0 + 3.0*param.AnisoNu/param.AnisoXi + param.Mass);
23  } else {
24  read(paramtop, "Kappa", param.Kappa); // die if not input!
25  }
26 
27  if (paramtop.count("MassCrit") > 0) {
28  read(paramtop, "MassCrit", param.MassCrit);
29  param.KappaCrit = 0.5/(1.0 + 3.0*param.AnisoNu/param.AnisoXi + param.MassCrit);
30  } else {
31  if (paramtop.count("KappaCrit") > 0) {
32  read(paramtop, "KappaCrit", param.KappaCrit);
33  } else {
34  param.KappaCrit = param.Kappa;
35  }
36  }
37 
38  defaultread( Clover, 0.0 );
39  defaultread( CloverT, param.Clover );
40  defaultread( Residual, 1e-6 );
41  defaultread( MaxIter, 40 );
42  defaultread( RefreshThreshold, param.MaxIter);
43  defaultread( NumGCRVecs, 8 );
44  defaultread( Verbose, 0 );
45  defaultread( Levels, 1 );
46 
47  defaultread( ExternalSubspace, false);
48 
49  if ( param.ExternalSubspace ) {
50  read(paramtop, "SubspaceId", param.SubspaceId );
51  }
52 
53  defaultread( TerminateOnFail, true);
54  defaultread( RsdToleranceFactor, Real(1.0)); // Default: No slack
55 
56  if (param.Levels > 0) {
57  if (paramtop.count("Blocking")) {
58  read(paramtop, "Blocking", param.Blocking);
59  } else {
60  param.Blocking.resize(param.Levels);
61  for (int l=0; l<param.Levels; l++) {
62  param.Blocking[l].resize(4);
63  param.Blocking[l][0] = param.Blocking[l][1] = param.Blocking[l][2] =
64  param.Blocking[l][3] = 4;
65  }
66  }
67 
68 
69 #define defaultreadvec(PARAM,DEFAULT) if (paramtop.count(#PARAM)) { \
70  read(paramtop, #PARAM, param.PARAM); \
71  } else { \
72  param.PARAM.resize(param.Levels); \
73  for (int l=0; l<param.Levels; l++) { \
74  param.PARAM[l] = DEFAULT; \
75  } \
76  }
77 
78  defaultreadvec( NumNullVecs, 24 );
79  defaultreadvec( NullMaxIter, 100 );
80  defaultreadvec( NullResidual, 0.4 );
81  defaultreadvec( NullConvergence, 0.5 );
82  defaultreadvec( NumExtraVecs, 0 );
83  defaultreadvec( Underrelax, 1.0 );
84  defaultreadvec( NumPreHits, 0 );
85  defaultreadvec( NumPostHits, 4 );
86  defaultreadvec( CoarseNumGCRVecs, 8 );
87  defaultreadvec( CoarseMaxIter, 12 );
88  defaultreadvec( CoarseResidual, 0.2 );
89 
90 #undef defaultread
91 #undef defaultreadvec
92  }
93 
94  }
95 
96  // Writer parameters
97  void write(XMLWriter& xml, const std::string& path, const SysSolverQOPMGParams& param)
98  {
99  push(xml, path);
100 
101 // int version = 1;
102 // write(xml, "version", version);
103  write(xml, "invType", "QDP_WILSON_MULTIGRID");
104 
105 #define writeparam(PARAM) write(xml, #PARAM, param.PARAM)
106  writeparam(AnisoXi);
107  writeparam(AnisoNu);
108  writeparam(Kappa);
109  writeparam(KappaCrit);
110  writeparam(Clover);
111  writeparam(CloverT);
112 
113  writeparam(Residual);
114  writeparam(MaxIter);
115  writeparam(RefreshThreshold);
116  writeparam(NumGCRVecs);
117 
118  writeparam(Verbose);
119 
120  writeparam(Levels);
121 
122  if (param.Levels > 0) {
123  writeparam(Blocking);
124  writeparam(NumNullVecs);
125 
126  writeparam(NullMaxIter);
127  writeparam(NullResidual);
128  writeparam(NullConvergence);
129  writeparam(NumExtraVecs);
130 
131  writeparam(Underrelax);
132  writeparam(NumPreHits);
133  writeparam(NumPostHits);
134  writeparam(CoarseNumGCRVecs);
135  writeparam(CoarseMaxIter);
136  writeparam(CoarseResidual);
137 
138  writeparam(ExternalSubspace);
139  if( param.ExternalSubspace ) {
140  writeparam(SubspaceId);
141  }
142  writeparam(TerminateOnFail);
143  writeparam(RsdToleranceFactor);
144  }
145 #undef writeparam
146  pop(xml);
147  }
148 
149  //! Default constructor
150  //SysSolverQOPMGParams::SysSolverQOPMGParams()
151  //{
152  //}
153 
154  //! Read parameters
156  {
157  read(xml, path, *this);
158  }
159 
160 }
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
::std::string string
Definition: gtest.h:1979
int l
Definition: pade_trln_w.cc:111
Parameters for the external QDP multigrid inverter.
multi1d< multi1d< int > > Blocking
#define defaultread(PARAM, DEFAULT)
#define writeparam(PARAM)
#define defaultreadvec(PARAM, DEFAULT)
Parameters for the external QDP clover multigrid solver.