10 #include "lattice/fine_qdpxx/mg_params_qdpxx.h"
11 #include "lattice/qphix/mg_level_qphix.h"
12 #include "lattice/qphix/vcycle_recursive_qphix.h"
13 #include "lattice/qphix/qphix_clover_linear_operator.h"
18 using std::shared_ptr;
19 using std::make_shared;
26 namespace MGProtoHelpersQPhiX{
28 template<
typename QPhiXLinOpT>
29 shared_ptr<QPhiXLinOpT>
31 const MG::LatticeInfo&
info)
33 shared_ptr<QPhiXLinOpT> M_fine=
nullptr;
36 double m_q=toDouble(
params.CloverParams.Mass);
37 double u0 = toDouble(
params.CloverParams.u0);
39 multi1d<LatticeColorMatrix> working_u(
Nd);
41 working_u[
mu] =
u[
mu];
50 if(
params.AntiPeriodicT ) {
54 working_u[
Nd-1] *= where(Layout::latticeCoordinate(
Nd-1) == (Layout::lattSize()[
Nd-1]-1),
55 Integer(-1), Integer(1));
61 double c_sw=toDouble(
params.CloverParams.clovCoeffR);
62 M_fine = make_shared<QPhiXLinOpT>(
info,m_q,c_sw,t_bc,working_u);
65 QDPIO::cout <<
"Using aniso interface" << std::endl;
67 double xi0 = toDouble(
params.CloverParams.anisoParam.xi_0);
68 double nu=toDouble(
params.CloverParams.anisoParam.nu);
69 double c_sw_r = toDouble(
params.CloverParams.clovCoeffR);
70 double c_sw_t = toDouble(
params.CloverParams.clovCoeffT);
71 M_fine = make_shared<QPhiXLinOpT>(
info,m_q,
u0,xi0,
nu,c_sw_r,c_sw_t,t_bc,working_u);
77 std::shared_ptr<MGPreconditioner::LinOpFT>
79 const MG::LatticeInfo&
info)
81 return createFineLinOpT<typename MGPreconditioner::LinOpFT>(
params,
u,
info);
84 std::shared_ptr<MGPreconditioner::LinOpT>
86 const MG::LatticeInfo&
info)
88 return createFineLinOpT<typename MGPreconditioner::LinOpT>(
params,
u,
info);
91 std::shared_ptr<MGPreconditionerEO::LinOpFT>
93 const MG::LatticeInfo&
info)
95 return createFineLinOpT<typename MGPreconditionerEO::LinOpFT>(
params,
u,
info);
98 std::shared_ptr<MGPreconditionerEO::LinOpT>
100 const MG::LatticeInfo&
info)
102 return createFineLinOpT<typename MGPreconditionerEO::LinOpT>(
params,
u,
info);
105 template<
typename PrecT>
109 QDPIO::cout <<
"Deleting MG_Proto preconditioner with subspaceID=" << subspaceId << std::endl;
111 QDPIO::cout <<
"Looking Up " << subspaceId <<
" in the Named Onject Map" << std::endl;
112 if( TheNamedObjMap::Instance().check(subspaceId) ) {
114 QDPIO::cout <<
" ... Subspace ID found... Deleting" <<std::endl;
120 TheNamedObjMap::Instance().erase(subspaceId);
126 deleteMGPreconditionerT<MGPreconditioner>(subspaceId);
130 deleteMGPreconditionerT<MGPreconditionerEO>(subspaceId);
133 template<
typename PrecT>
143 QDPIO::cout <<
"Creating MG_Proto preconditioner with subspaceID=" << subspaceId << std::endl;
145 QDPIO::cout <<
"Looking Up " << subspaceId <<
" in the Named Onject Map" << std::endl;
146 if( TheNamedObjMap::Instance().check(subspaceId) ) {
148 QDPIO::cout <<
" ... Subspace ID found... Deleting" <<std::endl;
149 deleteMGPreconditionerT<PrecT>(subspaceId);
154 shared_ptr<typename PrecT::LevelT> mg_levels = make_shared<typename PrecT::LevelT>();
157 IndexArray latdims = {{ QDP::Layout::subgridLattSize()[0],
158 QDP::Layout::subgridLattSize()[1],
159 QDP::Layout::subgridLattSize()[2],
160 QDP::Layout::subgridLattSize()[3] }};
162 (mg_levels->fine_level).
info = std::make_shared<LatticeInfo>( latdims, 4,3,NodeInfo());
165 QDPIO::cout <<
"Creating M..." ;
166 shared_ptr<typename PrecT::LinOpT> M=createFineLinOpT<typename PrecT::LinOpT>(
params,
u, *((mg_levels->fine_level).info) );
167 QDPIO::cout <<
"Done" << std::endl;
169 QDPIO::cout <<
"Creating single prec M...";
170 shared_ptr<typename PrecT::LinOpFT> M_f=createFineLinOpT<typename PrecT::LinOpFT>(
params,
u, *((mg_levels->fine_level).info) );
171 QDPIO::cout <<
"Done" << std::endl;
173 QDPIO::cout <<
"Creating MG Levels ... " ;
174 MG::SetupParams level_params;
175 int n_levels =
params.MGLevels;
176 level_params.n_levels = n_levels;
177 level_params.n_vecs.resize(n_levels-1);
178 level_params.null_solver_max_iter.resize(n_levels-1);
179 level_params.null_solver_rsd_target.resize(n_levels -1);
180 level_params.null_solver_verboseP.resize(n_levels -1);
181 for(
int l=0;
l < n_levels-1;++
l) {
182 QDPIO::cout <<
"Level L=" <<
l <<
" Null Vecs=" <<
params.NullVecs[
l] << std::endl;
184 level_params.n_vecs[
l] =
params.NullVecs[
l];
185 level_params.null_solver_max_iter[
l]=
params.NullSolverMaxIters[
l];
186 level_params.null_solver_rsd_target[
l]=toDouble(
params.NullSolverRsdTarget[
l]);
187 level_params.null_solver_verboseP[
l]=toDouble(
params.NullSolverVerboseP[
l]);
189 level_params.block_sizes.resize(n_levels-1);
190 for(
int l=0;
l < n_levels-1;++
l) {
191 for(
int mu=0;
mu < 4; ++
mu) {
192 (level_params.block_sizes[
l])[
mu] = (
params.Blocking[
l])[
mu];
196 MG::SetupQPhiXMGLevels(level_params, *mg_levels, M_f );
197 QDPIO::cout <<
"... Done " << std::endl;
199 if( (mg_levels->fine_level).M ==
nullptr ) {
200 QDPIO::cout <<
"Error... Barfaroni. Fine Level M is null after subspace setup" << std::endl;
204 QDPIO::cout <<
"Creating VCycle Parameters..." << std::endl;
205 vector<MG::VCycleParams> v_params(n_levels-1);
206 for(
int l=0;
l < n_levels-1;++
l) {
207 QDPIO::cout <<
" Level " <<
l << std::endl;
208 v_params[
l].pre_smoother_params.MaxIter=
params.VCyclePreSmootherMaxIters[
l];
209 v_params[
l].pre_smoother_params.RsdTarget=toDouble(
params.VCyclePreSmootherRsdTarget[
l]);
210 v_params[
l].pre_smoother_params.VerboseP =
params.VCyclePreSmootherVerboseP[
l];
211 v_params[
l].pre_smoother_params.Omega =toDouble(
params.VCyclePreSmootherRelaxOmega[
l]);
213 v_params[
l].post_smoother_params.MaxIter=
params.VCyclePostSmootherMaxIters[
l];
214 v_params[
l].post_smoother_params.RsdTarget=toDouble(
params.VCyclePostSmootherRsdTarget[
l]);
215 v_params[
l].post_smoother_params.VerboseP =
params.VCyclePostSmootherVerboseP[
l];
216 v_params[
l].post_smoother_params.Omega =toDouble(
params.VCyclePostSmootherRelaxOmega[
l]);
218 v_params[
l].bottom_solver_params.MaxIter=
params.VCycleBottomSolverMaxIters[
l];
219 v_params[
l].bottom_solver_params.NKrylov =
params.VCycleBottomSolverNKrylov[
l];
220 v_params[
l].bottom_solver_params.RsdTarget= toDouble(
params.VCycleBottomSolverRsdTarget[
l]);
221 v_params[
l].bottom_solver_params.VerboseP =
params.VCycleBottomSolverVerboseP[
l];
223 v_params[
l].cycle_params.MaxIter=
params.VCycleMaxIters[
l];
224 v_params[
l].cycle_params.RsdTarget=toDouble(
params.VCycleRsdTarget[
l]);
225 v_params[
l].cycle_params.VerboseP =
params.VCycleVerboseP[
l];
228 QDPIO::cout <<
"Creating VCycle Preconditioner...";
230 shared_ptr<typename PrecT::VCycleT> v_cycle=make_shared<typename PrecT::VCycleT>(v_params, *mg_levels);
232 QDPIO::cout <<
"Done";
234 QDPIO::cout <<
"Saving in Map" << std::endl;
235 QDPIO::cout <<
"Creating Named Object Map Entry for subspace" << std::endl;
236 XMLBufferWriter file_xml;
237 push(file_xml,
"FileXML");
240 XMLBufferWriter record_xml;
241 push(record_xml,
"RecordXML");
245 TheNamedObjMap::Instance().create<shared_ptr<PrecT>>(subspaceId);
246 TheNamedObjMap::Instance().get(subspaceId).setFileXML(file_xml);
247 TheNamedObjMap::Instance().get(subspaceId).setRecordXML(record_xml);
248 TheNamedObjMap::Instance().getData<shared_ptr<PrecT>>(subspaceId)=make_shared<PrecT>();
249 TheNamedObjMap::Instance().getData<shared_ptr<PrecT>>(subspaceId)->mg_levels = mg_levels;
250 TheNamedObjMap::Instance().getData<shared_ptr<PrecT>>(subspaceId)->v_cycle = v_cycle;
251 TheNamedObjMap::Instance().getData<shared_ptr<PrecT>>(subspaceId)->M = M;
254 QDPIO::cout <<
"MG_PROTO_QPHIX_SETUP: Subspace Creation Took : " << swatch.getTimeInSeconds() <<
" sec" << std::endl;
262 createMGPreconditionerT<MGPreconditioner>(
params,
u);
269 createMGPreconditionerT<MGPreconditionerEO>(
params,
u);
274 template<
typename PrecT>
277 shared_ptr<PrecT> ret_val =
nullptr;
278 if( TheNamedObjMap::Instance().check(subspaceId) ) {
280 QDPIO::cout <<
" ... Subspace ID found... returning" <<std::endl;
286 ret_val = TheNamedObjMap::Instance().getData<shared_ptr<PrecT>>(subspaceId);
290 QDPIO::cout <<
"Object Not Found... Returning Null" << std::endl;
300 return getMGPreconditionerT<MGPreconditioner>(subspaceId);
306 return getMGPreconditionerT<MGPreconditionerEO>(subspaceId);
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.
std::shared_ptr< MGPreconditionerEO::LinOpFT > createFineEOLinOpF(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u, const MG::LatticeInfo &info)
shared_ptr< PrecT > getMGPreconditionerT(const std::string &subspaceId)
void createMGPreconditioner(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u)
void deleteMGPreconditionerT(const std::string &subspaceId)
shared_ptr< MGPreconditionerEO > getMGPreconditionerEO(const std::string &subspaceId)
shared_ptr< QPhiXLinOpT > createFineLinOpT(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u, const MG::LatticeInfo &info)
void deleteMGPreconditionerEO(const std::string &subspaceId)
void createMGPreconditionerT(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u)
std::shared_ptr< MGPreconditioner::LinOpFT > createFineLinOpF(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u, const MG::LatticeInfo &info)
void deleteMGPreconditioner(const std::string &subspaceId)
std::shared_ptr< MGPreconditioner::LinOpT > createFineLinOp(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u, const MG::LatticeInfo &info)
shared_ptr< MGPreconditioner > getMGPreconditioner(const std::string &subspaceId)
std::shared_ptr< MGPreconditionerEO::LinOpT > createFineEOLinOp(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u, const MG::LatticeInfo &info)
void createMGPreconditionerEO(const MGProtoSolverParams ¶ms, const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
push(xml_out,"Cooled_Topology")