CHROMA
mgproto_solver_params.cc
Go to the documentation of this file.
1 /*
2  * mgproto_solver_params.cc
3  *
4  * Created on: Mar 23, 2017
5  * Author: bjoo
6  */
7 
8 #include "chromabase.h"
10 #include "io/xml_group_reader.h"
11 #include <string>
12 
13 using std::string;
14 
15 using namespace QDP;
16 
17 namespace Chroma
18 {
19 
20 // Anonymous namespace
21 namespace {
22  template<typename T>
23  void read(XMLReader& xml, const std::string& path, multi1d<T>& result, int N)
24  {
25  multi1d<T> read_result;
26  read(xml, path, read_result);
27  result.resize(N);
28 
29  if( read_result.size() == 1 ) {
30  // Broadcast
31  for(int i=0; i < N; ++i) {
32  result[i] = read_result[0];
33  }
34  }
35  else {
36  if( read_result.size() == N ) {
37  // Copy
38  for(int i=0; i < N; ++i) {
39  result[i] = read_result[i];
40  }
41  }
42  else {
43  QDPIO::cerr << "Wrong number of elements reading" << path << " should be either 1 or " << N << std::endl;
44  QDP_abort(1);
45  }
46  }
47  }
48 
49 } // end anonymous namespace
50 MGProtoSolverParams::MGProtoSolverParams(XMLReader& xml, const std::string& path)
51 {
52  try {
53  XMLReader paramtop(xml, path);
54  read( paramtop, "CloverParams", CloverParams);
55 
56  read( paramtop, "AntiPeriodicT", AntiPeriodicT );
57  read( paramtop, "MGLevels", MGLevels);
58 
59  read( paramtop, "Blocking", Blocking, MGLevels-1);
60 
61  read( paramtop, "NullVecs", NullVecs, MGLevels-1);
62  read( paramtop, "NullSolverMaxIters", NullSolverMaxIters, MGLevels-1);
63  read( paramtop, "NullSolverRsdTarget", NullSolverRsdTarget, MGLevels-1);
64  read( paramtop, "NullSolverVerboseP", NullSolverVerboseP, MGLevels-1);
65 
66  read( paramtop, "OuterSolverNKrylov", OuterSolverNKrylov);
67  read( paramtop, "OuterSolverRsdTarget", OuterSolverRsdTarget);
68  read( paramtop, "OuterSolverMaxIters", OuterSolverMaxIters);
69  read( paramtop, "OuterSolverVerboseP", OuterSolverVerboseP);
70 
71  read( paramtop, "VCyclePreSmootherMaxIters", VCyclePreSmootherMaxIters, MGLevels-1);
72  read( paramtop, "VCyclePreSmootherRsdTarget", VCyclePreSmootherRsdTarget, MGLevels-1);
73  read( paramtop, "VCyclePreSmootherRelaxOmega", VCyclePreSmootherRelaxOmega, MGLevels-1);
74  read( paramtop, "VCyclePreSmootherVerboseP", VCyclePreSmootherVerboseP, MGLevels-1);
75 
76  read( paramtop, "VCyclePostSmootherMaxIters", VCyclePostSmootherMaxIters, MGLevels-1);
77  read( paramtop, "VCyclePostSmootherRsdTarget", VCyclePostSmootherRsdTarget, MGLevels-1);
78  read( paramtop, "VCyclePostSmootherRelaxOmega", VCyclePostSmootherRelaxOmega, MGLevels-1);
79  read( paramtop, "VCyclePostSmootherVerboseP", VCyclePostSmootherVerboseP, MGLevels-1);
80 
81  read( paramtop, "VCycleBottomSolverNKrylov", VCycleBottomSolverNKrylov, MGLevels-1);
82  read( paramtop, "VCycleBottomSolverMaxIters", VCycleBottomSolverMaxIters, MGLevels-1);
83  read( paramtop, "VCycleBottomSolverRsdTarget", VCycleBottomSolverRsdTarget,MGLevels-1);
84  read( paramtop, "VCycleBottomSolverVerboseP", VCycleBottomSolverVerboseP, MGLevels-1);
85 
86  read( paramtop, "VCycleMaxIters", VCycleMaxIters, MGLevels-1);
87  read( paramtop, "VCycleRsdTarget", VCycleRsdTarget, MGLevels-1);
88  read( paramtop, "VCycleVerboseP", VCycleVerboseP, MGLevels-1);
89 
90  read( paramtop, "SubspaceId", SubspaceId);
91 
92  }
93  catch( const std::string& e) {
94  QDPIO::cout << "Caught exception " << e << std::endl;
95  QDP_abort(1);
96  }
97  catch(...) {
98  QDPIO::cout << "Caught unknown exception " << std::endl;
99  QDP_abort(1);
100  }
101 }
102 
103 
104 void read(XMLReader& xml, const std::string& path, MGProtoSolverParams& p)
105 {
106  MGProtoSolverParams ret_val(xml,path);
107  p = ret_val;
108 }
109 
110 void write(XMLWriter& xml, const std::string& path, const MGProtoSolverParams& p)
111 {
112  push(xml, path);
113  write(xml, "CloverParams", p.CloverParams);
114  write(xml, "AntiPeriodicT", p.AntiPeriodicT);
115 
116  write(xml, "MGLevels", p.MGLevels);
117  write(xml, "Blocking", p.Blocking);
118  write(xml, "NullVecs", p.NullVecs);
119  write(xml, "NullSolverMaxIters", p.NullSolverMaxIters);
120  write(xml, "NullSolverRsdTarget", p.NullSolverRsdTarget);
121  write(xml, "NullSolverVerboseP", p.NullSolverVerboseP);
122 
123  write(xml, "OuterSolverNKrylov", p.OuterSolverNKrylov);
124  write(xml, "OuterSolverRsdTarget", p.OuterSolverRsdTarget);
125  write(xml, "OuterSolverMaxIters", p.OuterSolverMaxIters);
126  write(xml, "OuterSolverVerboseP", p.OuterSolverVerboseP);
127 
128  write(xml, "VCyclePreSmootherMaxIters", p.VCyclePreSmootherMaxIters);
129  write(xml, "VCyclePreSmootherRsdTarget", p.VCyclePreSmootherRsdTarget);
130  write(xml, "VCyclePreSmootherRelaxOmega", p.VCyclePreSmootherRelaxOmega);
131  write(xml, "VCyclePreSmootherVerboseP", p.VCyclePreSmootherVerboseP);
132 
133  write(xml, "VCyclePostSmootherMaxIters", p.VCyclePostSmootherMaxIters);
134  write(xml, "VCyclePostSmootherRsdTarget", p.VCyclePostSmootherRsdTarget);
135  write(xml, "VCyclePostSmootherRelaxOmega", p.VCyclePostSmootherRelaxOmega);
136  write(xml, "VCyclePostSmootherVerboseP", p.VCyclePostSmootherVerboseP);
137 
138  write(xml, "VCycleBottomSolverNKrylov", p.VCycleBottomSolverNKrylov);
139  write(xml, "VCycleBottomSolverMaxIters", p.VCycleBottomSolverMaxIters);
140  write(xml, "VCycleBottomSolverRsdTarget", p.VCycleBottomSolverRsdTarget);
141  write(xml, "VCycleBottomSolverVerboseP", p.VCycleBottomSolverVerboseP);
142 
143  write(xml, "VCycleMaxIters", p.VCycleMaxIters);
144  write(xml, "VCycleRsdTarget", p.VCycleMaxIters);
145  write(xml, "VCycleVerboseP", p.VCycleVerboseP);
146  write(xml, "SubspaceId", p.SubspaceId);
147 
148 }
149 
150 
151 }
Primary include file for CHROMA library code.
unsigned i
Definition: ldumul_w.cc:34
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
void read(XMLReader &xml, const std::string &path, MGProtoSolverParams &p)
void write(XMLWriter &xml, const std::string &path, const MGProtoSolverParams &p)
::std::string string
Definition: gtest.h:1979
push(xml_out,"Cooled_Topology")
Read an XML group as a std::string.